Skip to content

Commit

Permalink
Bug 1916426 - Pass our LDFLAGS last to the linker command line cargo …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
glandium committed Sep 20, 2024
1 parent a2513f0 commit 908ba79
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build/cargo-host-linker
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh
# See comment in cargo-linker.
eval ${MOZ_CARGO_WRAP_HOST_LD} ${MOZ_CARGO_WRAP_HOST_LDFLAGS} '"$@"'
eval ${MOZ_CARGO_WRAP_HOST_LD} '"$@"' ${MOZ_CARGO_WRAP_HOST_LDFLAGS}
2 changes: 1 addition & 1 deletion build/cargo-host-linker.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
@echo off
REM See comment in cargo-linker (without extension)
%MOZ_CARGO_WRAP_HOST_LD% %MOZ_CARGO_WRAP_HOST_LDFLAGS% %*
%MOZ_CARGO_WRAP_HOST_LD% %* %MOZ_CARGO_WRAP_HOST_LDFLAGS%
3 changes: 2 additions & 1 deletion build/cargo-linker
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ SANITIZERS = {

use_clang_sanitizer = os.environ.get("MOZ_CLANG_NEWER_THAN_RUSTC_LLVM")
wrap_ld = os.environ["MOZ_CARGO_WRAP_LD"]
args = split(os.environ["MOZ_CARGO_WRAP_LDFLAGS"])
args = []
for arg in sys.argv[1:]:
if arg in ["-lc++", "-lstdc++"]:
wrap_ld = os.environ["MOZ_CARGO_WRAP_LD_CXX"]
Expand All @@ -60,6 +60,7 @@ for arg in sys.argv[1:]:
args.append(f"-fsanitize={SANITIZERS[suffix]}")
continue
args.append(arg)
args.extend(split(os.environ["MOZ_CARGO_WRAP_LDFLAGS"]))

wrap_ld = split(wrap_ld)
os.execvp(wrap_ld[0], wrap_ld + args)
2 changes: 1 addition & 1 deletion build/cargo-linker.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@echo off
%MOZ_CARGO_WRAP_LD% %MOZ_CARGO_WRAP_LDFLAGS% %*
%MOZ_CARGO_WRAP_LD% %* %MOZ_CARGO_WRAP_LDFLAGS%

0 comments on commit 908ba79

Please sign in to comment.