diff options
| -rw-r--r-- | mesonbuild/backend/ninjabackend.py | 4 | ||||
| -rw-r--r-- | mesonbuild/compilers/rust.py | 16 |
2 files changed, 16 insertions, 4 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index fb5d164b1..cab4547ee 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -2038,8 +2038,6 @@ class NinjaBackend(backends.Backend): except (KeyError, AttributeError): pass - has_verbatim = mesonlib.version_compare(rustc.version, '>= 1.67.0') - def _link_library(libname: str, static: bool, bundle: bool = False) -> None: orig_libname = libname type_ = 'static' if static else 'dylib' @@ -2049,7 +2047,7 @@ class NinjaBackend(backends.Backend): linkdirs.add(dir_) if not bundle and static: modifiers.append('-bundle') - if has_verbatim: + if rustc.has_verbatim(): modifiers.append('+verbatim') else: # undo the effects of -l without verbatim diff --git a/mesonbuild/compilers/rust.py b/mesonbuild/compilers/rust.py index d0f92668a..c0b01bb3f 100644 --- a/mesonbuild/compilers/rust.py +++ b/mesonbuild/compilers/rust.py @@ -11,7 +11,7 @@ import re import typing as T from .. import options -from ..mesonlib import EnvironmentException, MesonException, Popen_safe_logged +from ..mesonlib import EnvironmentException, MesonException, Popen_safe_logged, version_compare from ..options import OptionKey from .compilers import Compiler, CompileCheckMode, clike_debug_args @@ -194,6 +194,20 @@ class RustCompiler(Compiler): def get_crt_static(self) -> bool: return 'target_feature="crt-static"' in self.get_cfgs() + @functools.lru_cache(maxsize=None) + def has_verbatim(self) -> bool: + if version_compare(self.version, '< 1.67.0'): + return False + # GNU ld support '-l:PATH' + if 'ld.' in self.linker.id: + return True + # -l:+verbatim does not work (yet?) with MSVC link or Apple ld64 + # (https://github.com/rust-lang/rust/pull/138753). For ld64, it + # works together with -l:+whole_archive because -force_load (the macOS + # equivalent of --whole-archive), receives the full path to the library + # being linked. However, Meson uses "bundle", not "whole_archive". + return False + def get_debug_args(self, is_debug: bool) -> T.List[str]: return clike_debug_args[is_debug] |
