-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Musl host toolchain #58575
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Musl host toolchain #58575
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
880b041
Enable dist-x86_64-musl as a host architexture
strfry 3729e48
Set RUSTFLAGS env to make dylib work
strfry aecb32c
build a proper c++-enabled musl toolchain with musl-cross-make
strfry 8e2aa52
Make the musl dynamic loader known to the system, so it can execute t…
strfry 3f107fd
musl-toolchain: fix global lib paths (dont create /lib/libc.so)
strfry 52a3311
Address review comments
martell cacb305
musl: update LLVM to 7
mati865 cbc1ce0
Drop copyright notice from musl-toolchain
mati865 4dd57ef
Disable relax relocations again
mati865 66de5c6
Move testing to test-various
mati865 17464a7
Final cleanups
mati865 f364f48
Address final review
mati865 451343e
Fix TARGET variable in musl-toolchain.sh
mati865 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# This script runs `musl-cross-make` to prepare C toolchain (Binutils, GCC, musl itself) | ||
# and builds static libunwind that we distribute for static target. | ||
# | ||
# Versions of the toolchain components are configurable in `musl-cross-make/Makefile` and | ||
# musl unlike GLIBC is forward compatible so upgrading it shouldn't break old distributions. | ||
# Right now we have: Binutils 2.27, GCC 6.3.0, musl 1.1.18 | ||
set -ex | ||
mati865 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
hide_output() { | ||
mati865 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
set +x | ||
on_err=" | ||
echo ERROR: An error was encountered with the build. | ||
cat /tmp/build.log | ||
exit 1 | ||
" | ||
trap "$on_err" ERR | ||
bash -c "while true; do sleep 30; echo \$(date) - building ...; done" & | ||
PING_LOOP_PID=$! | ||
$@ &> /tmp/build.log | ||
trap - ERR | ||
kill $PING_LOOP_PID | ||
rm /tmp/build.log | ||
set -x | ||
} | ||
|
||
ARCH=$1 | ||
TARGET=$ARCH-linux-musl | ||
|
||
OUTPUT=/usr/local | ||
shift | ||
|
||
git clone https://github.com/richfelker/musl-cross-make -b v0.9.7 | ||
cd musl-cross-make | ||
|
||
hide_output make -j$(nproc) TARGET=$TARGET | ||
hide_output make install TARGET=$TARGET OUTPUT=$OUTPUT | ||
|
||
cd - | ||
|
||
# Install musl library to make binaries executable | ||
ln -s $OUTPUT/$TARGET/lib/libc.so /lib/ld-musl-$ARCH.so.1 | ||
echo $OUTPUT/$TARGET/lib >> /etc/ld-musl-$ARCH.path | ||
|
||
|
||
export CC=$TARGET-gcc | ||
export CXX=$TARGET-g++ | ||
|
||
LLVM=70 | ||
|
||
# may have been downloaded in a previous run | ||
if [ ! -d libunwind-release_$LLVM ]; then | ||
curl -L https://github.com/llvm-mirror/llvm/archive/release_$LLVM.tar.gz | tar xzf - | ||
curl -L https://github.com/llvm-mirror/libunwind/archive/release_$LLVM.tar.gz | tar xzf - | ||
fi | ||
|
||
# fixme(mati865): Replace it with https://github.com/rust-lang/rust/pull/59089 | ||
mkdir libunwind-build | ||
cd libunwind-build | ||
cmake ../libunwind-release_$LLVM \ | ||
-DLLVM_PATH=/build/llvm-release_$LLVM \ | ||
-DLIBUNWIND_ENABLE_SHARED=0 \ | ||
-DCMAKE_C_COMPILER=$CC \ | ||
-DCMAKE_CXX_COMPILER=$CXX \ | ||
-DCMAKE_C_FLAGS="$CFLAGS" \ | ||
-DCMAKE_CXX_FLAGS="$CXXFLAGS" | ||
|
||
hide_output make -j$(nproc) | ||
cp lib/libunwind.a $OUTPUT/$TARGET/lib | ||
cd - && rm -rf libunwind-build | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.