Compare commits

...

3 Commits

Author SHA1 Message Date
Kramer Peace caec875fe1 Create CUDA linker with CUDA compiler 5 years ago
Kramer Peace 7e8febaa8c Add get_soname_args method to CUDA linker 5 years ago
Kramer Peace fb9a5ce867 Add a CUDA linker object 5 years ago
  1. 2
      mesonbuild/compilers/cuda.py
  2. 3
      mesonbuild/environment.py
  3. 34
      mesonbuild/linkers.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

@ -55,6 +55,7 @@ from .linkers import (
XildAppleDynamicLinker,
XildLinuxDynamicLinker,
XilinkDynamicLinker,
CudaLinker,
)
from functools import lru_cache
from .compilers import (
@ -959,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) + '"')

@ -909,3 +909,37 @@ class OptlinkDynamicLinker(VisualStudioLikeLinkerMixin, DynamicLinker):
def get_allow_undefined_args(self) -> typing.List[str]:
return []
class CudaLinker(DynamicLinker):
"""Cuda linker (nvlink)"""
@staticmethod
def parse_version():
version_cmd = ['nvlink', '--version']
try:
_, out, _ = mesonlib.Popen_safe(version_cmd)
except OSError:
return 'unknown version'
# Output example:
# nvlink: NVIDIA (R) Cuda linker
# Copyright (c) 2005-2018 NVIDIA Corporation
# Built on Sun_Sep_30_21:09:22_CDT_2018
# Cuda compilation tools, release 10.0, V10.0.166
# we need the most verbose version output. Luckily starting with V
return out.strip().split('V')[-1]
def get_output_args(self, outname: str) -> typing.List[str]:
return ['-o', outname]
def get_search_args(self, dirname: str) -> typing.List[str]:
return ['-L', dirname]
def fatal_warnings(self) -> typing.List[str]:
return ['--warning-as-error']
def get_allow_undefined_args(self) -> typing.List[str]:
return []
def get_soname_args(self, env: 'Environment', prefix: str, shlib_name: str,
suffix: str, soversion: str, darwin_versions: typing.Tuple[str, str],
is_shared_module: bool) -> typing.List[str]:
return []

Loading…
Cancel
Save