From 66c018fdbbe7f8a54a788a69c3b0cb7d731e9c99 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 16 Aug 2021 15:35:06 +0300 Subject: [PATCH] rust: support llvm-only systems. closes #304 --- extra/rust/build | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/extra/rust/build b/extra/rust/build index edfbd012..fd8bb7b9 100755 --- a/extra/rust/build +++ b/extra/rust/build @@ -49,6 +49,10 @@ full-bootstrap = false [install] prefix = "/usr" +[target.x86_64-unknown-linux-musl] +llvm-config = "/usr/bin/llvm-config" +crt-static = false + [rust] channel = "stable" rpath = false @@ -59,12 +63,31 @@ jemalloc = false debug-assertions = false codegen-tests = false codegen-units-std = 1 - -[target.x86_64-unknown-linux-musl] -llvm-config = "/usr/bin/llvm-config" -crt-static = false EOF +# Workaround to get Rust to build in llvm-only environments. +case $("$CC" -print-file-name=libunwind.so) in */*) + printf 'llvm-libunwind = "system"\n' >> config.toml + + # 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. + { + 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" + } + + echo hello world +esac + python3 ./x.py build -j "$(nproc)" python3 ./x.py install