diff options
author | Olexa Bilaniuk <obilaniu@gmail.com> | 2021-03-12 18:09:22 -0500 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2021-03-28 20:12:45 +0300 |
commit | 2579420a72b64c020f9538d8ccbb52fd57c804a1 (patch) | |
tree | 9e921ada04ce37f5639f4bf7fa24f4f1593e4777 | |
parent | 5941e94ff8242591761c634f96efc56e49fedecf (diff) | |
download | meson-cudafix0572.zip meson-cudafix0572.tar.gz meson-cudafix0572.tar.bz2 |
Strip host-compiler -std flag from NVCC line.cudafix0572
Closes #8523.
-rw-r--r-- | mesonbuild/compilers/cuda.py | 13 | ||||
-rw-r--r-- | test cases/cuda/16 multistd/main.cu | 20 | ||||
-rw-r--r-- | test cases/cuda/16 multistd/meson.build | 4 |
3 files changed, 36 insertions, 1 deletions
diff --git a/mesonbuild/compilers/cuda.py b/mesonbuild/compilers/cuda.py index 0ef92b5..145b7c8 100644 --- a/mesonbuild/compilers/cuda.py +++ b/mesonbuild/compilers/cuda.py @@ -617,8 +617,19 @@ class CudaCompiler(Compiler): return opts def _to_host_compiler_options(self, options: 'KeyedOptionDictType') -> 'KeyedOptionDictType': + """ + Convert an NVCC Option set to a host compiler's option set. + """ + + # We must strip the -std option from the host compiler option set, as NVCC has + # its own -std flag that may not agree with the host compiler's. overrides = {name: opt.value for name, opt in options.items()} - return OptionOverrideProxy(overrides, self.host_compiler.get_options()) + overrides.pop(OptionKey('std', machine=self.for_machine, + lang=self.host_compiler.language), None) + host_options = self.host_compiler.get_options().copy() + if 'std' in host_options: + del host_options['std'] # type: ignore + return OptionOverrideProxy(overrides, host_options) def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]: args = self.get_ccbin_args(options) diff --git a/test cases/cuda/16 multistd/main.cu b/test cases/cuda/16 multistd/main.cu new file mode 100644 index 0000000..a2ffba4 --- /dev/null +++ b/test cases/cuda/16 multistd/main.cu @@ -0,0 +1,20 @@ +#include <cuda_runtime.h> +#include <iostream> + +auto cuda_devices(void) { + int result = 0; + cudaGetDeviceCount(&result); + return result; +} + + +int main(void) { + int n = cuda_devices(); + if (n == 0) { + std::cout << "No Cuda hardware found. Exiting.\n"; + return 0; + } + + std::cout << "Found " << n << "Cuda devices.\n"; + return 0; +} diff --git a/test cases/cuda/16 multistd/meson.build b/test cases/cuda/16 multistd/meson.build new file mode 100644 index 0000000..4769a87 --- /dev/null +++ b/test cases/cuda/16 multistd/meson.build @@ -0,0 +1,4 @@ +project('C++-CUDA multi-std', 'cpp', 'cuda', version : '1.0.0', default_options : ['cpp_std=c++17', 'cuda_std=c++14']) + +exe = executable('prog', 'main.cu') +test('cudatest', exe) |