Create CUDA linker with CUDA compiler

Since they are laways paired there is no need to "search" for the cuda
linker.
pull/5891/head
Kramer Peace 5 years ago committed by Dylan Baker
parent 7e8febaa8c
commit caec875fe1
  1. 8
      mesonbuild/compilers/cuda.py
  2. 5
      mesonbuild/environment.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

@ -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) + '"')

Loading…
Cancel
Save