From 7ec3af95e5b93845e5d757bfc3b8bab53ce895b1 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Mon, 6 Jan 2020 16:49:34 +0200 Subject: [PATCH] Updated linker MR (#6407) * environment: Fix passing always args to a number of less common linkers These are mostly (oops xilink) proprietary linkers I can't use for various reasons. Fixes: #6332 * Add intelfix from scivision. * Ifort fix from scivision. * PGI fix from scivision. * Cuda fix from scivision. * Fix linker passing for armclang. --- cross/armclang-linux.txt | 2 +- mesonbuild/compilers/c.py | 2 +- mesonbuild/environment.py | 29 +++++++++++++++++++---------- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/cross/armclang-linux.txt b/cross/armclang-linux.txt index 2772d827b..6df78d61a 100644 --- a/cross/armclang-linux.txt +++ b/cross/armclang-linux.txt @@ -26,7 +26,7 @@ ar = '/opt/arm/developmentstudio-2019.0/sw/ARMCompiler6.12/bin/armar' [properties] -#c_args = ['--target=aarch64-arm-none-eabi'] +c_args = ['--target=aarch64-arm-none-eabi'] [host_machine] system = 'baremetal' diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py index aa48f7abb..8a1560973 100644 --- a/mesonbuild/compilers/c.py +++ b/mesonbuild/compilers/c.py @@ -146,7 +146,7 @@ class EmscriptenCCompiler(LinkerEnvVarsMixin, EmscriptenMixin, BasicLinkerIsComp class ArmclangCCompiler(ArmclangCompiler, CCompiler): def __init__(self, exelist, version, for_machine: MachineChoice, - info: 'MachineInfo', is_cross, exe_wrapper=None, **kwargs): + is_cross, info: 'MachineInfo', exe_wrapper=None, **kwargs): CCompiler.__init__(self, exelist, version, for_machine, is_cross, info, exe_wrapper, **kwargs) ArmclangCompiler.__init__(self) diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index 26727ad14..cc726ce78 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -819,7 +819,8 @@ class Environment: _, o, e = Popen_safe(compiler + check_args) v = search_version(o) if o.startswith('LLD'): - linker = LLVMDynamicLinker(compiler, for_machine, 'lld', comp_class.LINKER_PREFIX, override, version=v) # type: DynamicLinker + linker = LLVMDynamicLinker( + compiler, for_machine, 'lld', comp_class.LINKER_PREFIX, override, version=v) # type: DynamicLinker elif e.startswith('lld-link: '): # Toolchain wrapper got in the way; this happens with e.g. https://github.com/mstorsjo/llvm-mingw # Let's try to extract the linker invocation command to grab the version. @@ -963,7 +964,7 @@ class Environment: version = search_version(arm_ver_str) full_version = arm_ver_str cls = ArmclangCCompiler if lang == 'c' else ArmclangCPPCompiler - linker = ArmClangDynamicLinker(for_machine, [], version=version) + linker = ArmClangDynamicLinker(for_machine, version=version) return cls( ccache + compiler, version, for_machine, is_cross, info, exe_wrap, full_version=full_version, linker=linker) @@ -1010,11 +1011,13 @@ class Environment: return cls( ccache + compiler, version, for_machine, is_cross, info, exe_wrap, full_version=full_version, linker=linker) + if 'Intel(R) C++ Intel(R)' in err: version = search_version(err) target = 'x86' if 'IA-32' in err else 'x86_64' cls = IntelClCCompiler if lang == 'c' else IntelClCPPCompiler - linker = XilinkDynamicLinker(for_machine, version=version) + self.coredata.add_lang_args(cls.language, cls, for_machine, self) + linker = XilinkDynamicLinker(for_machine, [], version=version) return cls( compiler, version, for_machine, is_cross, info=info, exe_wrap=exe_wrap, target=target, linker=linker) @@ -1044,6 +1047,7 @@ class Environment: target, linker=linker) if 'PGI Compilers' in out: cls = PGICCompiler if lang == 'c' else PGICPPCompiler + self.coredata.add_lang_args(cls.language, cls, for_machine, self) linker = PGIDynamicLinker(compiler, for_machine, 'pgi', cls.LINKER_PREFIX, [], version=version) return cls( ccache + compiler, version, for_machine, is_cross, @@ -1111,8 +1115,10 @@ class Environment: # the full version: version = out.strip().split('V')[-1] cpp_compiler = self.detect_cpp_compiler(for_machine) - linker = CudaLinker(compiler, for_machine, 'nvlink', CudaCompiler.LINKER_PREFIX, version=CudaLinker.parse_version()) - return CudaCompiler(ccache + compiler, version, for_machine, is_cross, exe_wrap, host_compiler=cpp_compiler, info=info, linker=linker) + cls = CudaCompiler + self.coredata.add_lang_args(cls.language, cls, for_machine, self) + linker = CudaLinker(compiler, for_machine, 'nvlink', CudaCompiler.LINKER_PREFIX, [], version=CudaLinker.parse_version()) + return cls(ccache + compiler, version, for_machine, is_cross, exe_wrap, host_compiler=cpp_compiler, info=info, linker=linker) raise EnvironmentException('Could not find suitable CUDA compiler: "' + ' '.join(compilers) + '"') def detect_fortran_compiler(self, for_machine: MachineChoice): @@ -1175,8 +1181,10 @@ class Environment: if 'Intel(R) Visual Fortran' in err: version = search_version(err) target = 'x86' if 'IA-32' in err else 'x86_64' + cls = IntelClFortranCompiler + self.coredata.add_lang_args(cls.language, cls, for_machine, self) linker = XilinkDynamicLinker(for_machine, [], version=version) - return IntelClFortranCompiler( + return cls( compiler, version, for_machine, is_cross, target, info, exe_wrap, linker=linker) @@ -1192,10 +1200,11 @@ class Environment: exe_wrap, full_version=full_version) if 'PGI Compilers' in out: - linker = PGIDynamicLinker( - compiler, for_machine, 'pgi', - PGIFortranCompiler.LINKER_PREFIX, version=version) - return PGIFortranCompiler( + cls = PGIFortranCompiler + self.coredata.add_lang_args(cls.language, cls, for_machine, self) + linker = PGIDynamicLinker(compiler, for_machine, 'pgi', + cls.LINKER_PREFIX, [], version=version) + return cls( compiler, version, for_machine, is_cross, info, exe_wrap, full_version=full_version, linker=linker)