forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1329737 - part 3 - use an alternate linker for Cargo invocations;…
… r=rillian For linking static libraries, rustc will use whatever `cc` it finds (or the equivalent on Windows). For our purposes, however, `cc` is not what we use to link and we may have additional options we would like to pass to the linker. To do this, we need to tell Cargo about our alternate linker (currently only used for target compilations, on the theory that the host compiler rustc finds is probably good enough) and we also need to pass our linker options into the process. We do this with environment variables, which is not a great solution, but works surprisingly well. This alternate linker is disabled for ASan builds due to peculiar crashes when running Rust build scripts and for Windows, because we don't do any interesting cross-compiling there.
- Loading branch information
Showing
2 changed files
with
42 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/sh | ||
|
||
# If you want to use a custom linker with Cargo, Cargo requires that you | ||
# specify it in Cargo.toml or via the matching environment variable. | ||
# Passing extra options to the linker is possible with Cargo via | ||
# RUSTFLAGS='-C link-args', but testing showed that doing this reliably | ||
# was difficult. | ||
# | ||
# Our solution to these problems is to use this wrapper script. We pass | ||
# in the LD and the LDFLAGS to use via environment variables. Note that | ||
# we do *not* quote either MOZ_CARGO_WRAP variable: | ||
# | ||
# * MOZ_CARGO_WRAP_LD is equivalent to CC on Unix-y platforms, and CC | ||
# frequently has additional arguments in addition to the compiler | ||
# itself. | ||
# * MOZ_CARGO_WRAP_LDFLAGS contains space-separated arguments to pass, | ||
# and not quoting it ensures that either of those arguments is passed | ||
# as a separate argument to the actual LD. | ||
|
||
${MOZ_CARGO_WRAP_LD} ${MOZ_CARGO_WRAP_LDFLAGS} "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters