mirror of
https://codeberg.org/kiss-community/repo
synced 2024-08-21 13:46:17 +00:00
108 lines
2.7 KiB
Bash
Executable File
108 lines
2.7 KiB
Bash
Executable File
#!/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
|
|
# connection requirement per build.
|
|
{
|
|
mkdir -p "${cache_dir:=build/cache/2021-07-29}"
|
|
|
|
for tarball in *.tar.xz\?no-extract; do
|
|
mv -f "$tarball" "$cache_dir/${tarball%%\?no-extract}"
|
|
done
|
|
}
|
|
|
|
# Set shared linking as the default.
|
|
for f in \
|
|
compiler/rustc_target/src/spec/linux_musl_base.rs \
|
|
vendor/rustc-ap-rustc_target/src/spec/linux_musl_base.rs
|
|
do
|
|
sed 's/\(crt_static_default = \)true/\1false/' "$f" > _
|
|
mv -f _ "$f"
|
|
done
|
|
|
|
# Ignore checksums of files modified above.
|
|
sed 's/\("files":{\)[^}]*/\1/' \
|
|
vendor/rustc-ap-rustc_target/.cargo-checksum.json > _
|
|
mv -f _ vendor/rustc-ap-rustc_target/.cargo-checksum.json
|
|
|
|
cat > config.toml <<EOF
|
|
[llvm]
|
|
link-shared = true
|
|
skip-rebuild = true
|
|
|
|
[build]
|
|
build = "x86_64-unknown-linux-musl"
|
|
host = [ "x86_64-unknown-linux-musl" ]
|
|
target = [ "x86_64-unknown-linux-musl" ]
|
|
|
|
docs = false
|
|
compiler-docs = false
|
|
extended = true
|
|
submodules = false
|
|
python = "python3"
|
|
locked-deps = true
|
|
vendor = true
|
|
tools = [ "cargo", "rustfmt" ]
|
|
sanitizers = false
|
|
profiler = false
|
|
full-bootstrap = false
|
|
|
|
[install]
|
|
prefix = "/usr"
|
|
|
|
[target.x86_64-unknown-linux-musl]
|
|
llvm-config = "/usr/bin/llvm-config"
|
|
crt-static = false
|
|
sanitizers = false
|
|
|
|
[dist]
|
|
src-tarball = false
|
|
|
|
[rust]
|
|
backtrace = false
|
|
channel = "stable"
|
|
codegen-tests = false
|
|
codegen-units-std = 1
|
|
codegen-units = 0
|
|
debug = false
|
|
debug-assertions = false
|
|
debuginfo-level = 0
|
|
incremental = false
|
|
jemalloc = false
|
|
rpath = false
|
|
dist-src = false
|
|
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
|
|
|
|
rm -rf \
|
|
"$1/usr/lib/rustlib/src/" \
|
|
"$1/usr/share/doc" \
|
|
"$1/usr/share/zsh" \
|
|
"$1/usr/lib/rustlib/uninstall.sh"
|
|
|