Bug 1765931 [wpt PR 33748] - Fix line cache for simplified layout, a=testonly
[gecko.git] / build / cargo-linker
blob0673d9c59f1c115b6c4b29505ffda5070170ea41
1 #!/bin/sh
3 # If you want to use a custom linker with Cargo, Cargo requires that you
4 # specify it in Cargo.toml or via the matching environment variable.
5 # Passing extra options to the linker is possible with Cargo via
6 # RUSTFLAGS='-C link-args', but testing showed that doing this reliably
7 # was difficult.
9 # Our solution to these problems is to use this wrapper script. We pass
10 # in the LD and the LDFLAGS to use via environment variables. Note that
11 # we do *not* quote either MOZ_CARGO_WRAP variable:
13 # * MOZ_CARGO_WRAP_LD is equivalent to CC on Unix-y platforms, and CC
14 # frequently has additional arguments in addition to the compiler
15 # itself.
16 # * MOZ_CARGO_WRAP_LDFLAGS contains space-separated arguments to pass,
17 # and not quoting it ensures that each of those arguments is passed
18 # as a separate argument to the actual LD.
20 # * In rare cases, we also need MOZ_CARGO_WRAP_LD_CXX, which is the
21 # equivalent of CXX, when linking C++ code. Usually, this should
22 # simply work by the use of CC and -lstdc++ (added by cc-rs).
23 # However, in the case of sanitizer runtimes, there is a separate
24 # runtime for C and C++ and linking C++ code with the C runtime can
25 # fail if the requested feature is in the C++ runtime only (bug 1747298).
27 # $@ is doubly quoted for the eval. See bug 1418598.
29 WRAP_LD=${MOZ_CARGO_WRAP_LD}
30 for opt; do
31 case "$opt" in
32 -lc++|-lstdc++)
33 WRAP_LD=${MOZ_CARGO_WRAP_LD_CXX};
34 break;
36 esac
37 done
38 eval ${WRAP_LD} ${MOZ_CARGO_WRAP_LDFLAGS} '"$@"'