2019-07-21 03:11:03 -06:00
|
|
|
#!/bin/sh -e
|
|
|
|
|
2023-03-02 07:40:00 -07:00
|
|
|
export DESTDIR="$1"
|
|
|
|
|
2023-07-19 19:08:30 -06:00
|
|
|
for p in *.patch; do
|
|
|
|
patch -p1 < "$p"
|
|
|
|
done
|
2021-10-07 23:21:08 -06:00
|
|
|
|
2023-08-28 11:35:10 -06:00
|
|
|
: "${AR:=ar}"
|
|
|
|
: "${CC:=cc}"
|
|
|
|
|
2023-08-26 11:45:25 -06:00
|
|
|
mkdir _lib
|
|
|
|
|
|
|
|
(
|
|
|
|
cd _lib
|
|
|
|
|
|
|
|
$CC ../liblfs64.c -c -fPIC -o liblfs64.o
|
|
|
|
$AR rcs liblfs64.a liblfs64.o
|
|
|
|
|
|
|
|
cat > cc <<EOF
|
|
|
|
#!/bin/sh
|
|
|
|
set -x
|
|
|
|
PATH="$PATH"
|
|
|
|
exec $CC \$@ -L$PWD -llfs64
|
|
|
|
EOF
|
|
|
|
chmod +x cc
|
|
|
|
)
|
|
|
|
|
|
|
|
export PATH="$PWD/_lib:$PATH"
|
|
|
|
|
2021-09-02 03:17:51 -06:00
|
|
|
# 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=."
|
|
|
|
|
2021-06-30 17:46:09 -06:00
|
|
|
# Set shared linking as the default.
|
2022-04-08 02:26:54 -06:00
|
|
|
sed 's/\(crt_static_default = \)true/\1false/' \
|
|
|
|
compiler/rustc_target/src/spec/linux_musl_base.rs > _
|
|
|
|
mv -f _ compiler/rustc_target/src/spec/linux_musl_base.rs
|
2021-06-30 17:46:09 -06:00
|
|
|
|
2023-08-26 11:45:25 -06:00
|
|
|
sed 's/\("files":{\)[^}]*/\1/' vendor/curl-sys/.cargo-checksum.json > _
|
|
|
|
mv -f _ vendor/curl-sys/.cargo-checksum.json
|
2019-07-21 03:11:03 -06:00
|
|
|
|
2019-08-24 14:34:01 -06:00
|
|
|
cat > config.toml <<EOF
|
|
|
|
[llvm]
|
|
|
|
link-shared = true
|
|
|
|
|
|
|
|
[build]
|
2020-10-09 02:55:38 -06:00
|
|
|
build = "x86_64-unknown-linux-musl"
|
|
|
|
host = [ "x86_64-unknown-linux-musl" ]
|
|
|
|
target = [ "x86_64-unknown-linux-musl" ]
|
2020-02-27 13:05:15 -07:00
|
|
|
|
|
|
|
docs = false
|
|
|
|
compiler-docs = false
|
|
|
|
extended = true
|
|
|
|
submodules = false
|
|
|
|
python = "python3"
|
|
|
|
locked-deps = true
|
|
|
|
vendor = true
|
2021-09-03 09:04:27 -06:00
|
|
|
tools = [ "cargo", "rustfmt" ]
|
2020-02-27 13:05:15 -07:00
|
|
|
sanitizers = false
|
|
|
|
profiler = false
|
|
|
|
full-bootstrap = false
|
2022-07-05 14:57:58 -06:00
|
|
|
EOF
|
|
|
|
|
2022-11-03 12:02:34 -06:00
|
|
|
# If possible, use system rust to bootstrap.
|
2022-07-05 21:20:59 -06:00
|
|
|
maj="${2%%.*}"
|
|
|
|
min="${2%.*}"
|
|
|
|
min="${min#*.}"
|
|
|
|
|
2022-11-03 12:02:34 -06:00
|
|
|
# Fall back to vendor binaries if rustc, et al are not present, or if one of
|
|
|
|
# them suffered ABI breakage.
|
2022-07-05 21:20:59 -06:00
|
|
|
rust_version=$(rustc --version 2>/dev/null) || rust_version=null
|
2022-11-03 12:02:34 -06:00
|
|
|
cargo --version 2>/dev/null || rust_version=null
|
|
|
|
rustfmt --version 2>/dev/null || rust_version=null
|
2022-07-05 21:20:59 -06:00
|
|
|
rust_version="${rust_version#rustc }"
|
|
|
|
|
|
|
|
case "$rust_version" in
|
2022-07-19 10:02:00 -06:00
|
|
|
"$maj.$min".*|"$maj.$((min - 1))".*)
|
2022-07-05 14:57:58 -06:00
|
|
|
cat >> config.toml <<EOF
|
|
|
|
cargo = "/usr/bin/cargo"
|
|
|
|
rustc = "/usr/bin/rustc"
|
|
|
|
rustfmt = "/usr/bin/rustfmt"
|
|
|
|
EOF
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
# This mimics the download process of rust's 'x.py'
|
|
|
|
# bootstrap library to allow for the removal of the internet
|
|
|
|
# connection requirement per build.
|
2023-08-26 11:45:25 -06:00
|
|
|
mkdir -p "${cache_dir:=build/cache/2023-07-13}"
|
2022-07-05 14:57:58 -06:00
|
|
|
|
|
|
|
for tarball in *.tar.xz\?no-extract; do
|
|
|
|
mv -f "$tarball" "$cache_dir/${tarball%%\?no-extract}"
|
|
|
|
done
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
cat >> config.toml <<EOF
|
2019-08-24 14:34:01 -06:00
|
|
|
|
|
|
|
[install]
|
|
|
|
prefix = "/usr"
|
|
|
|
|
2021-08-16 06:35:06 -06:00
|
|
|
[target.x86_64-unknown-linux-musl]
|
|
|
|
llvm-config = "/usr/bin/llvm-config"
|
|
|
|
crt-static = false
|
2021-09-02 03:17:51 -06:00
|
|
|
sanitizers = false
|
2021-08-16 06:35:06 -06:00
|
|
|
|
2021-09-03 00:55:25 -06:00
|
|
|
[dist]
|
|
|
|
src-tarball = false
|
|
|
|
|
2019-08-24 14:34:01 -06:00
|
|
|
[rust]
|
2021-09-02 03:17:51 -06:00
|
|
|
backtrace = false
|
2020-10-09 02:55:38 -06:00
|
|
|
channel = "stable"
|
2021-09-02 03:17:51 -06:00
|
|
|
codegen-tests = false
|
2021-09-03 09:04:27 -06:00
|
|
|
codegen-units-std = 1
|
2021-09-03 00:55:25 -06:00
|
|
|
codegen-units = 0
|
2020-10-09 02:55:38 -06:00
|
|
|
debug = false
|
|
|
|
debug-assertions = false
|
2021-09-02 03:17:51 -06:00
|
|
|
debuginfo-level = 0
|
|
|
|
incremental = false
|
|
|
|
jemalloc = false
|
|
|
|
rpath = false
|
2021-09-03 00:55:25 -06:00
|
|
|
dist-src = false
|
2019-08-24 14:34:01 -06:00
|
|
|
EOF
|
|
|
|
|
2021-08-16 06:35:06 -06:00
|
|
|
# Workaround to get Rust to build in llvm-only environments.
|
2021-09-02 03:17:51 -06:00
|
|
|
# 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.
|
2022-03-28 04:46:10 -06:00
|
|
|
libunwind_path=$("$CC" -print-file-name=libunwind.so)
|
|
|
|
case $libunwind_path in */*)
|
2021-08-16 06:35:06 -06:00
|
|
|
printf 'llvm-libunwind = "system"\n' >> config.toml
|
|
|
|
|
2021-09-02 03:17:51 -06:00
|
|
|
mkdir -p libgcc
|
2021-08-16 06:35:06 -06:00
|
|
|
|
2021-09-02 03:17:51 -06:00
|
|
|
printf 'INPUT(-lunwind)\n' > \
|
|
|
|
libgcc/libgcc_s.so
|
2021-08-16 06:35:06 -06:00
|
|
|
|
2022-03-28 04:46:10 -06:00
|
|
|
ln -sf "$libunwind_path" \
|
2021-09-02 03:17:51 -06:00
|
|
|
libgcc/libgcc_s.so.1
|
2021-08-16 06:35:06 -06:00
|
|
|
|
2021-09-02 03:17:51 -06:00
|
|
|
export \
|
|
|
|
LD_LIBRARY_PATH="$PWD/libgcc:$LD_LIBRARY_PATH" \
|
|
|
|
LIBRARY_PATH="$PWD/libgcc:$LIBRARY_PATH"
|
2021-08-16 06:35:06 -06:00
|
|
|
esac
|
|
|
|
|
2022-09-22 13:48:03 -06:00
|
|
|
python x.py build -j "$(grep -scF 'core id' /proc/cpuinfo)"
|
|
|
|
python x.py install
|
2020-05-05 15:56:59 -06:00
|
|
|
|
2021-07-06 07:03:16 -06:00
|
|
|
rm -rf \
|
|
|
|
"$1/usr/lib/rustlib/src/" \
|
|
|
|
"$1/usr/share/doc" \
|
|
|
|
"$1/usr/share/zsh" \
|
|
|
|
"$1/usr/lib/rustlib/uninstall.sh"
|
|
|
|
|