Strip host-compiler -std flag from NVCC line.

Closes #8523.
pull/8596/head
Olexa Bilaniuk 4 years ago committed by Jussi Pakkanen
parent 5941e94ff8
commit 2579420a72
  1. 13
      mesonbuild/compilers/cuda.py
  2. 20
      test cases/cuda/16 multistd/main.cu
  3. 4
      test cases/cuda/16 multistd/meson.build

@ -617,8 +617,19 @@ class CudaCompiler(Compiler):
return opts return opts
def _to_host_compiler_options(self, options: 'KeyedOptionDictType') -> 'KeyedOptionDictType': 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()} 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]: def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
args = self.get_ccbin_args(options) args = self.get_ccbin_args(options)

@ -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;
}

@ -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)
Loading…
Cancel
Save