gecko-dev/build/cargo-linker
Mike Hommey 49a0cbadc9 Bug 1524396 - Unify how target/host linker/flags are passed to rust. r=chmanchester
The current setup uses different ways for different platforms, with
different workarounds, even using extra configuration items for Windows.

Now that there can't be a difference between the host per the build
system and the host per rust, we can get rid of those configuration
items, and use a more common infrastructure.

We cannot, however, avoid using wrapper scripts, because per-target rust
link-arg flags don't work up great.

The downside is that multiplies the number of wrappers, as we now have
to have a different one for host and target, and then we have .bat files
and shell scripts for, respectively, Windows hosts, and other hosts.

Depends on D24321

Differential Revision: https://phabricator.services.mozilla.com/D24322

--HG--
extra : moz-landing-system : lando
2019-03-22 11:05:18 +00:00

23 lines
960 B
Bash
Executable File

#!/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 each of those arguments is passed
# as a separate argument to the actual LD.
#
# $@ is doubly quoted for the eval. See bug 1418598.
eval ${MOZ_CARGO_WRAP_LD} ${MOZ_CARGO_WRAP_LDFLAGS} '"$@"'