2020-01-02 15:16:20 +00:00
|
|
|
#!/bin/sh -e
|
|
|
|
|
2023-07-06 08:20:23 +00:00
|
|
|
if [ -n "$CROSSDIRECT_DEBUG" ]; then
|
|
|
|
set -x
|
|
|
|
fi
|
2020-01-02 15:16:20 +00:00
|
|
|
|
2023-07-06 08:20:23 +00:00
|
|
|
# return the correct host architecture when cargo requests it
|
2023-08-06 12:08:21 +00:00
|
|
|
if [ "$*" = "-vV" ] || [ "$*" = "-V" ]; then
|
|
|
|
exec /usr/bin/rustc "$*"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# pmbootstrap installs sccache when building a rust program, unless --no-ccache
|
|
|
|
# is set. In that case it also sets CCACHE_DISABLE.
|
|
|
|
SCCACHE=/native/usr/bin/sccache
|
|
|
|
if ! [ -e "$SCCACHE" ] || [ -n "$CCACHE_DISABLE" ]; then
|
|
|
|
SCCACHE=""
|
2023-07-06 08:20:23 +00:00
|
|
|
fi
|
2020-01-02 15:16:20 +00:00
|
|
|
|
2023-07-06 08:20:23 +00:00
|
|
|
# We expect the right target to be set in the arguments if compiling for the
|
|
|
|
# target architecture. Our cargo wrapper passes the right "--target" argument
|
|
|
|
# automatically. If no target is provided, this is probably a macro or a
|
|
|
|
# build script, so it should be compiled for the native architecture.
|
|
|
|
if echo "$*" | grep -qFe "--target"; then
|
2023-08-06 12:08:21 +00:00
|
|
|
# Not using sccache when building for foreign architecture, as it
|
|
|
|
# doesn't cache the output with "Non-cacheable reasons: --sysroot"
|
|
|
|
LD_LIBRARY_PATH=/native/lib:/native/usr/lib \
|
|
|
|
/native/usr/bin/rustc \
|
2020-01-02 15:16:20 +00:00
|
|
|
-Clinker=/native/usr/lib/crossdirect/rust-qemu-linker \
|
|
|
|
--sysroot=/usr \
|
2023-07-06 08:20:23 +00:00
|
|
|
"$@"
|
|
|
|
else
|
2023-08-06 12:08:21 +00:00
|
|
|
PATH=/native/usr/bin:/native/bin \
|
|
|
|
LD_LIBRARY_PATH=/native/lib:/native/usr/lib \
|
|
|
|
$SCCACHE \
|
2023-07-06 08:20:23 +00:00
|
|
|
/native/usr/bin/rustc \
|
|
|
|
-Clink-arg=-Wl,-rpath,/native/lib:/native/usr/lib \
|
|
|
|
"$@"
|
2020-01-02 15:16:20 +00:00
|
|
|
fi
|