From caec875fe1922b40037e1fd9229433ede64f9f25 Mon Sep 17 00:00:00 2001 From: Kramer Peace Date: Tue, 3 Sep 2019 19:33:11 +0300 Subject: [PATCH] Create CUDA linker with CUDA compiler Since they are laways paired there is no need to "search" for the cuda linker. --- mesonbuild/compilers/cuda.py | 8 ++------ mesonbuild/environment.py | 5 +---- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/mesonbuild/compilers/cuda.py b/mesonbuild/compilers/cuda.py index 0a26bedb8..57935d8fa 100644 --- a/mesonbuild/compilers/cuda.py +++ b/mesonbuild/compilers/cuda.py @@ -18,7 +18,7 @@ import typing from .. import mlog from ..mesonlib import EnvironmentException, MachineChoice, Popen_safe from .compilers import (Compiler, cuda_buildtype_args, cuda_optimization_args, - cuda_debug_args, CompilerType) + cuda_debug_args) if typing.TYPE_CHECKING: from ..environment import Environment # noqa: F401 @@ -34,7 +34,7 @@ class CudaCompiler(Compiler): super().__init__(exelist, version, for_machine, **kwargs) self.is_cross = is_cross self.exe_wrapper = exe_wrapper - self.id = CudaCompiler.cuda_id() + self.id = 'nvcc' default_warn_args = [] self.warn_args = {'0': [], '1': default_warn_args, @@ -42,10 +42,6 @@ class CudaCompiler(Compiler): '3': default_warn_args + ['-Xcompiler=-Wextra', '-Xcompiler=-Wpedantic']} - @staticmethod - def cuda_id(): - return 'nvcc' - def needs_static_linker(self): return False diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index b53c6f5c2..7e1ca9dc1 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -697,9 +697,6 @@ class Environment: `-Xlinker=--version`) you must pass as a list. :extra_args: Any addtional arguments rquired (such as a source file) """ - if CudaCompiler.cuda_id() in compiler: - return CudaLinker(compiler, for_machine, 'nvlink', prefix, version=CudaLinker.parse_version()) - extra_args = typing.cast(typing.List[str], extra_args or []) if isinstance(prefix, str): check_args = [prefix + '--version'] + extra_args @@ -963,7 +960,7 @@ class Environment: # Luckily, the "V" also makes it very simple to extract # the full version: version = out.strip().split('V')[-1] - linker = self._guess_nix_linker(compiler, for_machine, CudaCompiler.LINKER_PREFIX) + linker = CudaLinker(compiler, for_machine, 'nvlink', CudaCompiler.LINKER_PREFIX, version=CudaLinker.parse_version()) return CudaCompiler(ccache + compiler, version, for_machine, exe_wrap, linker=linker) raise EnvironmentException('Could not find suitable CUDA compiler: "' + ' '.join(compilers) + '"')