diff options
author | Fini Jastrow <ulf.fini.jastrow@desy.de> | 2022-03-08 18:41:08 +0100 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2022-04-30 10:06:22 -0400 |
commit | c16fdaeecafe94461d6048b90bd337a04c25ad3c (patch) | |
tree | 7ebffc621f5ad4d75459dff1d5b5f05cc6481993 /mesonbuild/linkers/detect.py | |
parent | 93ed7531c4a1e08defc5ea3b37427e59f67582db (diff) | |
download | meson-c16fdaeecafe94461d6048b90bd337a04c25ad3c.zip meson-c16fdaeecafe94461d6048b90bd337a04c25ad3c.tar.gz meson-c16fdaeecafe94461d6048b90bd337a04c25ad3c.tar.bz2 |
linkers: Add support for mold linker
[why]
Support for the relatively new mold linker is missing. If someone wants
to use mold as linker `LDFLAGS="-B/path/to/mold"` has to be added instead
of the usual `CC_LD=mold meson ...` or `CXX_LD=mold meson ...`.
[how]
Allow `mold' as linker for clang and newer GCC versions (that versions
that have support).
The error message can be a bit off, because it is generic for all GNU
like compilers, but I guess that is ok. (i.e. 'mold' is not listed as
possible linker, even if it would be possible for the given compiler.)
[note]
GCC Version 12.0.1 is not sufficient to say `mold` is supported. The
expected release with support will be 12.1.0.
On the other hand people that use the un-released 12.0.1 will probably
have built it from trunk. Allowing 12.0.1 is helping bleeding edge
developers to use mold in Meson already now.
Fixes: #9072
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
Diffstat (limited to 'mesonbuild/linkers/detect.py')
-rw-r--r-- | mesonbuild/linkers/detect.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/mesonbuild/linkers/detect.py b/mesonbuild/linkers/detect.py index 80e0948..62719e0 100644 --- a/mesonbuild/linkers/detect.py +++ b/mesonbuild/linkers/detect.py @@ -1,4 +1,4 @@ -# Copyright 2012-2021 The Meson development team +# Copyright 2012-2022 The Meson development team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ from .linkers import ( AppleDynamicLinker, GnuGoldDynamicLinker, GnuBFDDynamicLinker, + MoldDynamicLinker, LLVMDynamicLinker, QualcommLLVMDynamicLinker, MSVCDynamicLinker, @@ -56,7 +57,7 @@ def __failed_to_detect_linker(compiler: T.List[str], args: T.List[str], stdout: def guess_win_linker(env: 'Environment', compiler: T.List[str], comp_class: T.Type['Compiler'], - for_machine: MachineChoice, *, + comp_version: str, for_machine: MachineChoice, *, use_linker_prefix: bool = True, invoked_directly: bool = True, extra_args: T.Optional[T.List[str]] = None) -> 'DynamicLinker': env.coredata.add_lang_args(comp_class.language, comp_class, for_machine, env) @@ -74,7 +75,7 @@ def guess_win_linker(env: 'Environment', compiler: T.List[str], comp_class: T.Ty override = [] # type: T.List[str] value = env.lookup_binary_entry(for_machine, comp_class.language + '_ld') if value is not None: - override = comp_class.use_linker_args(value[0]) + override = comp_class.use_linker_args(value[0], comp_version) check_args += override if extra_args is not None: @@ -126,12 +127,13 @@ def guess_win_linker(env: 'Environment', compiler: T.List[str], comp_class: T.Ty __failed_to_detect_linker(compiler, check_args, o, e) def guess_nix_linker(env: 'Environment', compiler: T.List[str], comp_class: T.Type['Compiler'], - for_machine: MachineChoice, *, + comp_version:str, for_machine: MachineChoice, *, extra_args: T.Optional[T.List[str]] = None) -> 'DynamicLinker': """Helper for guessing what linker to use on Unix-Like OSes. :compiler: Invocation to use to get linker :comp_class: The Compiler Type (uninstantiated) + :comp_version: The compiler version string :for_machine: which machine this linker targets :extra_args: Any additional arguments required (such as a source file) """ @@ -147,7 +149,7 @@ def guess_nix_linker(env: 'Environment', compiler: T.List[str], comp_class: T.Ty override = [] # type: T.List[str] value = env.lookup_binary_entry(for_machine, comp_class.language + '_ld') if value is not None: - override = comp_class.use_linker_args(value[0]) + override = comp_class.use_linker_args(value[0], comp_version) check_args += override _, o, e = Popen_safe(compiler + check_args) @@ -194,6 +196,8 @@ def guess_nix_linker(env: 'Environment', compiler: T.List[str], comp_class: T.Ty cls: T.Type[GnuDynamicLinker] if 'gold' in o or 'gold' in e: cls = GnuGoldDynamicLinker + elif 'mold' in o or 'mold' in e: + cls = MoldDynamicLinker else: cls = GnuBFDDynamicLinker linker = cls(compiler, for_machine, comp_class.LINKER_PREFIX, override, version=v) |