repo/extra/rust/build

102 lines
2.6 KiB
Plaintext
Raw Normal View History

2019-07-21 09:11:03 +00:00
#!/bin/sh -e
# Instruct the compiler to trim absolute paths in resulting binaries and instead
# change them to relative paths ($PWD/... ./...).
export RUSTFLAGS="$RUSTFLAGS --remap-path-prefix=$PWD=."
# This package mimics the download process of rust's 'x.py'
# bootstrap library to allow for the removal of the internet
2020-02-11 12:55:58 +00:00
# connection requirement per build.
{
2021-07-30 07:08:08 +00:00
mkdir -p "${cache_dir:=build/cache/2021-06-17}"
2020-01-31 09:30:15 +00:00
for tarball in *.tar.xz\?no-extract; do
2019-11-26 10:55:52 +00:00
mv -f "$tarball" "$cache_dir/${tarball%%\?no-extract}"
done
}
2021-06-30 23:46:09 +00:00
# Set shared linking as the default.
2021-07-03 21:24:51 +00:00
for f in \
2021-06-30 23:46:09 +00:00
compiler/rustc_target/src/spec/linux_musl_base.rs \
vendor/rustc-ap-rustc_target/src/spec/linux_musl_base.rs
2021-07-03 21:24:51 +00:00
do
sed 's/\(crt_static_default = \)true/\1false/' "$f" > _
mv -f _ "$f"
done
2021-06-30 23:46:09 +00:00
# Ignore checksums of files modified above.
2021-07-07 21:02:10 +00:00
sed 's/\("files":{\)[^}]*/\1/' \
vendor/rustc-ap-rustc_target/.cargo-checksum.json > _
mv -f _ vendor/rustc-ap-rustc_target/.cargo-checksum.json
2019-07-21 09:11:03 +00:00
2019-08-24 20:34:01 +00:00
cat > config.toml <<EOF
[llvm]
link-shared = true
[build]
2020-10-09 08:55:38 +00:00
build = "x86_64-unknown-linux-musl"
host = [ "x86_64-unknown-linux-musl" ]
target = [ "x86_64-unknown-linux-musl" ]
2020-02-27 20:05:15 +00:00
docs = false
compiler-docs = false
extended = true
submodules = false
python = "python3"
locked-deps = true
vendor = true
tools = [ "cargo" ]
2020-02-27 20:05:15 +00:00
sanitizers = false
profiler = false
full-bootstrap = false
2019-08-24 20:34:01 +00:00
[install]
prefix = "/usr"
[target.x86_64-unknown-linux-musl]
llvm-config = "/usr/bin/llvm-config"
crt-static = false
sanitizers = false
2019-08-24 20:34:01 +00:00
[rust]
backtrace = false
2020-10-09 08:55:38 +00:00
channel = "stable"
codegen-tests = false
codegen-units-std = 0
2020-10-09 08:55:38 +00:00
debug = false
debug-assertions = false
debuginfo-level = 0
incremental = false
jemalloc = false
rpath = false
2019-08-24 20:34:01 +00:00
EOF
# Workaround to get Rust to build in llvm-only environments.
# libgcc_s.so is needed for Rust's bootstrap binaries, on llvm-only systems
# this library does not exist. This hack creates it as alias to libunwind.
case $("$CC" -print-file-name=libunwind.so) in */*)
printf 'llvm-libunwind = "system"\n' >> config.toml
mkdir -p libgcc
printf 'INPUT(-lunwind)\n' > \
libgcc/libgcc_s.so
ln -sf "$KISS_ROOT/usr/lib/libunwind.so.1" \
libgcc/libgcc_s.so.1
export \
LD_LIBRARY_PATH="$PWD/libgcc:$LD_LIBRARY_PATH" \
LIBRARY_PATH="$PWD/libgcc:$LIBRARY_PATH"
esac
./x.py build -j "$(grep -scF 'core id' /proc/cpuinfo)"
./x.py install
2020-05-05 21:56:59 +00:00
2021-07-06 13:03:16 +00:00
rm -rf \
"$1/usr/lib/rustlib/src/" \
"$1/usr/share/doc" \
"$1/usr/share/zsh" \
"$1/usr/lib/rustlib/uninstall.sh"