From 10e8995fc8394c71e5def6d055f542c5f80ca06c Mon Sep 17 00:00:00 2001 From: David Seifert Date: Tue, 22 Aug 2023 18:34:03 +0200 Subject: [PATCH] Use `cudart_static` by default in dependency('cuda') * Without this, using nvcc as the sole driver vs dependency('cuda') and host compiler driver yields differently linked binaries. --- mesonbuild/dependencies/cuda.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mesonbuild/dependencies/cuda.py b/mesonbuild/dependencies/cuda.py index 45df11b41..aaed6b32c 100644 --- a/mesonbuild/dependencies/cuda.py +++ b/mesonbuild/dependencies/cuda.py @@ -46,8 +46,10 @@ class CudaDependency(SystemDependency): self.lib_modules: T.Dict[str, T.List[str]] = {} self.requested_modules = self.get_requested(kwargs) if not any(runtime in self.requested_modules for runtime in ['cudart', 'cudart_static']): + # By default, we prefer to link the static CUDA runtime, since this is what nvcc also does by default: + # https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html#cudart-none-shared-static-cudart req_modules = ['cudart'] - if kwargs.get('static', False): + if kwargs.get('static', True): req_modules = ['cudart_static'] machine = self.env.machines[self.for_machine] if machine.is_linux():