Skip to content

Commit b2438f7

Browse files
committed
Bug 1916426 - Pass our LDFLAGS last to the linker command line cargo invokes r=firefox-build-system-reviewers,sergesanspaille
See llvm/llvm-project#107365 (comment) for an example of how things can go wrong when they are passed first. I don't think there was a specific reason for them to have been put first in the first place. Differential Revision: https://phabricator.services.mozilla.com/D222899 UltraBlame original commit: f6cff71bfc6cba2b1d37d79fce2cb6b5d0b00852
1 parent 44b3bc8 commit b2438f7

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

build/cargo-host-linker

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/sh
22
# See comment in cargo-linker.
3-
eval ${MOZ_CARGO_WRAP_HOST_LD} ${MOZ_CARGO_WRAP_HOST_LDFLAGS} '"$@"'
3+
eval ${MOZ_CARGO_WRAP_HOST_LD} '"$@"' ${MOZ_CARGO_WRAP_HOST_LDFLAGS}

build/cargo-host-linker.bat

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
@echo off
22
REM See comment in cargo-linker (without extension)
3-
%MOZ_CARGO_WRAP_HOST_LD% %MOZ_CARGO_WRAP_HOST_LDFLAGS% %*
3+
%MOZ_CARGO_WRAP_HOST_LD% %* %MOZ_CARGO_WRAP_HOST_LDFLAGS%

build/cargo-linker

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ SANITIZERS = {
4444

4545
use_clang_sanitizer = os.environ.get("MOZ_CLANG_NEWER_THAN_RUSTC_LLVM")
4646
wrap_ld = os.environ["MOZ_CARGO_WRAP_LD"]
47-
args = split(os.environ["MOZ_CARGO_WRAP_LDFLAGS"])
47+
args = []
4848
for arg in sys.argv[1:]:
4949
if arg in ["-lc++", "-lstdc++"]:
5050
wrap_ld = os.environ["MOZ_CARGO_WRAP_LD_CXX"]
@@ -60,6 +60,7 @@ for arg in sys.argv[1:]:
6060
args.append(f"-fsanitize={SANITIZERS[suffix]}")
6161
continue
6262
args.append(arg)
63+
args.extend(split(os.environ["MOZ_CARGO_WRAP_LDFLAGS"]))
6364

6465
wrap_ld = split(wrap_ld)
6566
os.execvp(wrap_ld[0], wrap_ld + args)

build/cargo-linker.bat

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
@echo off
2-
%MOZ_CARGO_WRAP_LD% %MOZ_CARGO_WRAP_LDFLAGS% %*
2+
%MOZ_CARGO_WRAP_LD% %* %MOZ_CARGO_WRAP_LDFLAGS%

0 commit comments

Comments
 (0)