Skip to content

Commit fde7200

Browse files
bonzinifreakboy3742
andcommitted
linkers: pass system to DynamicLinker.__init__ for Darwin linkers
Apple linkers need to use different arguments on macOS and iOS-like platforms. Pass the system to the constructor so that it can be examined. Co-authored-by: Russell Keith-Magee <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 58cb456 commit fde7200

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

mesonbuild/compilers/detect.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,8 +1062,8 @@ def detect_rust_compiler(env: 'Environment', for_machine: MachineChoice) -> Rust
10621062
version=cc.linker.version, **extra_args) # type: ignore
10631063
else:
10641064
linker = type(cc.linker)(compiler, for_machine, cc.LINKER_PREFIX,
1065-
always_args=always_args, version=cc.linker.version,
1066-
**extra_args)
1065+
always_args=always_args, system=cc.linker.system,
1066+
version=cc.linker.version, **extra_args)
10671067
elif 'link' in override[0]:
10681068
linker = guess_win_linker(env,
10691069
override, cls, version, for_machine, use_linker_prefix=False)

mesonbuild/linkers/detect.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ def guess_nix_linker(env: 'Environment', compiler: T.List[str], comp_class: T.Ty
122122
env.coredata.add_lang_args(comp_class.language, comp_class, for_machine, env)
123123
extra_args = extra_args or []
124124

125+
system = env.machines[for_machine].system
125126
ldflags = env.coredata.get_external_link_args(for_machine, comp_class.language)
126127
extra_args += comp_class._unix_args_to_native(ldflags, env.machines[for_machine])
127128

@@ -155,7 +156,7 @@ def guess_nix_linker(env: 'Environment', compiler: T.List[str], comp_class: T.Ty
155156
lld_cls = linkers.LLVMDynamicLinker
156157

157158
linker = lld_cls(
158-
compiler, for_machine, comp_class.LINKER_PREFIX, override, version=v)
159+
compiler, for_machine, comp_class.LINKER_PREFIX, override, system=system, version=v)
159160
elif 'Snapdragon' in e and 'LLVM' in e:
160161
linker = linkers.QualcommLLVMDynamicLinker(
161162
compiler, for_machine, comp_class.LINKER_PREFIX, override, version=v)
@@ -213,7 +214,10 @@ def guess_nix_linker(env: 'Environment', compiler: T.List[str], comp_class: T.Ty
213214
elif 'xtools-' in o.split('\n', maxsplit=1)[0]:
214215
xtools = o.split(' ', maxsplit=1)[0]
215216
v = xtools.split('-', maxsplit=2)[1]
216-
linker = linkers.AppleDynamicLinker(compiler, for_machine, comp_class.LINKER_PREFIX, override, version=v)
217+
linker = linkers.AppleDynamicLinker(
218+
compiler, for_machine, comp_class.LINKER_PREFIX, override,
219+
system=system, version=v
220+
)
217221
# detect linker on MacOS - must be after other platforms because the
218222
# "(use -v to see invocation)" will match clang on other platforms,
219223
# but the rest of the checks will fail and call __failed_to_detect_linker.
@@ -232,7 +236,10 @@ def guess_nix_linker(env: 'Environment', compiler: T.List[str], comp_class: T.Ty
232236
break
233237
else:
234238
__failed_to_detect_linker(compiler, check_args, o, e)
235-
linker = linkers.AppleDynamicLinker(compiler, for_machine, comp_class.LINKER_PREFIX, override, version=v)
239+
linker = linkers.AppleDynamicLinker(
240+
compiler, for_machine, comp_class.LINKER_PREFIX, override,
241+
system=system, version=v
242+
)
236243
else:
237244
__failed_to_detect_linker(compiler, check_args, o, e)
238245
return linker

mesonbuild/linkers/linkers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,11 @@ def _apply_prefix(self, arg: T.Union[str, T.List[str]]) -> T.List[str]:
130130

131131
def __init__(self, exelist: T.List[str],
132132
for_machine: mesonlib.MachineChoice, prefix_arg: T.Union[str, T.List[str]],
133-
always_args: T.List[str], *, version: str = 'unknown version'):
133+
always_args: T.List[str], *, system: str = 'unknown system',
134+
version: str = 'unknown version'):
134135
self.exelist = exelist
135136
self.for_machine = for_machine
137+
self.system = system
136138
self.version = version
137139
self.prefix_arg = prefix_arg
138140
self.always_args = always_args

0 commit comments

Comments
 (0)