Skip to content

Commit 6fcbebf

Browse files
bonzinielmarco
authored andcommitted
rust: query linker in addition to compiler for verbatim support
Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 641fd36 commit 6fcbebf

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

mesonbuild/backend/ninjabackend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2049,7 +2049,7 @@ def _link_library(libname: str, static: bool, bundle: bool = False) -> None:
20492049
linkdirs.add(dir_)
20502050
if not bundle and static:
20512051
modifiers.append('-bundle')
2052-
if has_verbatim:
2052+
if rustc.has_verbatim():
20532053
modifiers.append('+verbatim')
20542054
else:
20552055
# undo the effects of -l without verbatim

mesonbuild/compilers/rust.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import typing as T
1212

1313
from .. import options
14-
from ..mesonlib import EnvironmentException, MesonException, Popen_safe_logged
14+
from ..mesonlib import EnvironmentException, MesonException, Popen_safe_logged, version_compare
1515
from ..options import OptionKey
1616
from .compilers import Compiler, CompileCheckMode, clike_debug_args
1717

@@ -194,6 +194,20 @@ def get_cfgs(self) -> T.List[str]:
194194
def get_crt_static(self) -> bool:
195195
return 'target_feature="crt-static"' in self.get_cfgs()
196196

197+
@functools.lru_cache(maxsize=None)
198+
def has_verbatim(self) -> bool:
199+
if version_compare(self.version, '< 1.67.0'):
200+
return False
201+
# GNU ld support '-l:PATH'
202+
if 'ld.' in self.linker.id:
203+
return True
204+
# -l:+verbatim does not work (yet?) with MSVC link or Apple ld64
205+
# (https://github.com/rust-lang/rust/pull/138753). For ld64, it
206+
# works together with -l:+whole_archive because -force_load (the macOS
207+
# equivalent of --whole-archive), receives the full path to the library
208+
# being linked. However, Meson uses "bundle", not "whole_archive".
209+
return False
210+
197211
def get_debug_args(self, is_debug: bool) -> T.List[str]:
198212
return clike_debug_args[is_debug]
199213

0 commit comments

Comments
 (0)