summaryrefslogtreecommitdiff
path: root/mesonbuild/linkers/detect.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2025-11-12 11:10:25 -0800
committerDylan Baker <dylan@pnwbakers.com>2025-11-19 10:48:48 -0800
commit377fde5cf1ad8aa31c8731efabad13c1b49dbee2 (patch)
treeab521260df46a1de1d25f1cfcb3645fd07c5a26e /mesonbuild/linkers/detect.py
parent8b3a35d5c24816dc0fcdc7145d0911d032a35361 (diff)
downloadmeson-377fde5cf1ad8aa31c8731efabad13c1b49dbee2.tar.gz
linkers: Store a reference to the Environment in the DynamicLinker
For the same reason that the StaticLinker needs this, we need it in the DynamicLinker as well.
Diffstat (limited to 'mesonbuild/linkers/detect.py')
-rw-r--r--mesonbuild/linkers/detect.py34
1 files changed, 17 insertions, 17 deletions
diff --git a/mesonbuild/linkers/detect.py b/mesonbuild/linkers/detect.py
index 5ff19ae3d..d9be37925 100644
--- a/mesonbuild/linkers/detect.py
+++ b/mesonbuild/linkers/detect.py
@@ -73,11 +73,11 @@ def guess_win_linker(env: 'Environment', compiler: T.List[str], comp_class: T.Ty
if 'LLD' in o.split('\n', maxsplit=1)[0]:
if 'compatible with GNU linkers' in o:
return linkers.LLVMDynamicLinker(
- compiler, for_machine, comp_class.LINKER_PREFIX,
+ compiler, env, for_machine, comp_class.LINKER_PREFIX,
override, version=search_version(o))
elif not invoked_directly:
return linkers.ClangClDynamicLinker(
- for_machine, override, exelist=compiler, prefix=comp_class.LINKER_PREFIX,
+ env, for_machine, override, exelist=compiler, prefix=comp_class.LINKER_PREFIX,
version=search_version(o), direct=False, machine=None,
rsp_syntax=rsp_syntax)
@@ -88,13 +88,13 @@ def guess_win_linker(env: 'Environment', compiler: T.List[str], comp_class: T.Ty
p, o, e = Popen_safe(compiler + check_args)
if 'LLD' in o.split('\n', maxsplit=1)[0]:
return linkers.ClangClDynamicLinker(
- for_machine, [],
+ env, for_machine, [],
prefix=comp_class.LINKER_PREFIX if use_linker_prefix else [],
exelist=compiler, version=search_version(o), direct=invoked_directly,
rsp_syntax=rsp_syntax)
elif 'OPTLINK' in o:
# Optlink's stdout *may* begin with a \r character.
- return linkers.OptlinkDynamicLinker(compiler, for_machine, version=search_version(o))
+ return linkers.OptlinkDynamicLinker(compiler, env, for_machine, version=search_version(o))
elif o.startswith('Microsoft') or e.startswith('Microsoft'):
out = o or e
match = re.search(r'.*(X86|X64|ARM|ARM64).*', out)
@@ -104,7 +104,7 @@ def guess_win_linker(env: 'Environment', compiler: T.List[str], comp_class: T.Ty
target = 'x86'
return linkers.MSVCDynamicLinker(
- for_machine, [], machine=target, exelist=compiler,
+ env, for_machine, [], machine=target, exelist=compiler,
prefix=comp_class.LINKER_PREFIX if use_linker_prefix else [],
version=search_version(out), direct=invoked_directly,
rsp_syntax=rsp_syntax)
@@ -170,13 +170,13 @@ def guess_nix_linker(env: 'Environment', compiler: T.List[str], comp_class: T.Ty
lld_cls = linkers.LLVMDynamicLinker
linker = lld_cls(
- compiler, for_machine, comp_class.LINKER_PREFIX, override, system=system, version=v)
+ compiler, env, for_machine, comp_class.LINKER_PREFIX, override, system=system, version=v)
elif o.startswith("eld"):
linker = linkers.ELDDynamicLinker(
- compiler, for_machine, comp_class.LINKER_PREFIX, override, version=v)
+ compiler, env, for_machine, comp_class.LINKER_PREFIX, override, version=v)
elif 'Snapdragon' in e and 'LLVM' in e:
linker = linkers.QualcommLLVMDynamicLinker(
- compiler, for_machine, comp_class.LINKER_PREFIX, override, version=v)
+ compiler, env, for_machine, comp_class.LINKER_PREFIX, override, version=v)
elif e.startswith('lld-link: '):
# The LLD MinGW frontend didn't respond to --version before version 9.0.0,
# and produced an error message about failing to link (when no object
@@ -194,7 +194,7 @@ def guess_nix_linker(env: 'Environment', compiler: T.List[str], comp_class: T.Ty
_, o, e = Popen_safe([linker_cmd, '--version'])
v = search_version(o)
- linker = linkers.LLVMDynamicLinker(compiler, for_machine, comp_class.LINKER_PREFIX, override, version=v)
+ linker = linkers.LLVMDynamicLinker(compiler, env, for_machine, comp_class.LINKER_PREFIX, override, version=v)
elif 'GNU' in o or 'GNU' in e:
gnu_cls: T.Type[GnuDynamicLinker]
# this is always the only thing on stdout, except for swift
@@ -205,7 +205,7 @@ def guess_nix_linker(env: 'Environment', compiler: T.List[str], comp_class: T.Ty
gnu_cls = linkers.MoldDynamicLinker
else:
gnu_cls = linkers.GnuBFDDynamicLinker
- linker = gnu_cls(compiler, for_machine, comp_class.LINKER_PREFIX, override, version=v)
+ linker = gnu_cls(compiler, env, for_machine, comp_class.LINKER_PREFIX, override, version=v)
elif 'Solaris' in e or 'Solaris' in o:
for line in (o+e).split('\n'):
if 'ld: Software Generation Utilities' in line:
@@ -214,7 +214,7 @@ def guess_nix_linker(env: 'Environment', compiler: T.List[str], comp_class: T.Ty
else:
v = 'unknown version'
linker = linkers.SolarisDynamicLinker(
- compiler, for_machine, comp_class.LINKER_PREFIX, override,
+ compiler, env, for_machine, comp_class.LINKER_PREFIX, override,
version=v)
elif 'ld: 0706-012 The -- flag is not recognized' in e:
if isinstance(comp_class.LINKER_PREFIX, str):
@@ -222,17 +222,17 @@ def guess_nix_linker(env: 'Environment', compiler: T.List[str], comp_class: T.Ty
else:
_, _, e = Popen_safe(compiler + comp_class.LINKER_PREFIX + ['-V'] + extra_args)
linker = linkers.AIXDynamicLinker(
- compiler, for_machine, comp_class.LINKER_PREFIX, override,
+ compiler, env, for_machine, comp_class.LINKER_PREFIX, override,
version=search_version(e))
elif o.startswith('zig ld'):
linker = linkers.ZigCCDynamicLinker(
- compiler, for_machine, comp_class.LINKER_PREFIX, override, version=v)
+ compiler, env, for_machine, comp_class.LINKER_PREFIX, override, version=v)
# detect xtools first, bug #10805
elif 'xtools-' in o.split('\n', maxsplit=1)[0]:
xtools = o.split(' ', maxsplit=1)[0]
v = xtools.split('-', maxsplit=2)[1]
linker = linkers.AppleDynamicLinker(
- compiler, for_machine, comp_class.LINKER_PREFIX, override,
+ compiler, env, for_machine, comp_class.LINKER_PREFIX, override,
system=system, version=v
)
# detect linker on MacOS - must be after other platforms because the
@@ -254,16 +254,16 @@ def guess_nix_linker(env: 'Environment', compiler: T.List[str], comp_class: T.Ty
else:
__failed_to_detect_linker(compiler, check_args, o, e)
linker = linkers.AppleDynamicLinker(
- compiler, for_machine, comp_class.LINKER_PREFIX, override,
+ compiler, env, for_machine, comp_class.LINKER_PREFIX, override,
system=system, version=v
)
elif 'ld.exe: unrecognized option' in e:
linker = linkers.OS2AoutDynamicLinker(
- compiler, for_machine, comp_class.LINKER_PREFIX, override,
+ compiler, env, for_machine, comp_class.LINKER_PREFIX, override,
version='none')
elif 'emxomfld: invalid option' in e:
linker = linkers.OS2OmfDynamicLinker(
- compiler, for_machine, comp_class.LINKER_PREFIX, override,
+ compiler, env, for_machine, comp_class.LINKER_PREFIX, override,
version='none')
else:
__failed_to_detect_linker(compiler, check_args, o, e)