Skip to content

Commit

Permalink
Add x86_64-unknown-linux-musl build support
Browse files Browse the repository at this point in the history
  • Loading branch information
martell committed Mar 23, 2019
1 parent 819ddda commit 4549859
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 3 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ matrix:
- { <<: *linux, env: SKIP_TESTS=1 TARGET=mips64-unknown-linux-gnuabi64 }
- { <<: *linux, env: SKIP_TESTS=1 TARGET=mips64el-unknown-linux-gnuabi64 }
- { <<: *linux, env: SKIP_TESTS=1 TARGET=s390x-unknown-linux-gnu }
- { <<: *linux, env: SKIP_TESTS=1 TARGET=x86_64-unknown-linux-musl }
- { <<: *linux, env: SKIP_TESTS=1 TARGET=arm-linux-androideabi }
- { <<: *linux, env: SKIP_TESTS=1 TARGET=armv7-linux-androideabi }
- { <<: *linux, env: SKIP_TESTS=1 TARGET=aarch64-linux-android }
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,7 @@ platform of your choice:
- [x86_64-pc-windows-msvc](https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe)<sup>[](#vs2015)</sup>
- [x86_64-unknown-freebsd](https://static.rust-lang.org/rustup/dist/x86_64-unknown-freebsd/rustup-init)
- [x86_64-unknown-linux-gnu](https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init)
- [x86_64-unknown-linux-musl](https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-musl/rustup-init)
- [x86_64-unknown-netbsd](https://static.rust-lang.org/rustup/dist/x86_64-unknown-netbsd/rustup-init)

<a name="vs2015">†</a>
Expand Down
11 changes: 11 additions & 0 deletions ci/docker/x86_64-unknown-linux-musl/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM alpine:3.9

RUN apk update && \
apk add \
curl \
ca-certificates \
perl \
make \
gcc

ENV CC_x86_64_unknown_linux_musl=gcc
8 changes: 6 additions & 2 deletions rustup-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,18 @@ get_endianness() {
}

get_architecture() {
local _ostype _cputype _bitness _arch
local _ostype _cputype _bitness _arch _clibtype
_ostype="$(uname -s)"
_cputype="$(uname -m)"
_clibtype="gnu"

if [ "$_ostype" = Linux ]; then
if [ "$(uname -o)" = Android ]; then
_ostype=Android
fi
if [ "$(ldd --version 2>&1 | grep 'musl')" ]; then
_clibtype="musl"
fi
fi

if [ "$_ostype" = Darwin ] && [ "$_cputype" = i386 ]; then
Expand All @@ -196,7 +200,7 @@ get_architecture() {
;;

Linux)
_ostype=unknown-linux-gnu
_ostype=unknown-linux-$_clibtype
_bitness=$(get_bitness)
;;

Expand Down
8 changes: 7 additions & 1 deletion src/dist/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ static LIST_ENVS: &'static [&'static str] = &[
"musl",
];

// MUSL and GNU targets are both linux
#[cfg(not(target_env="musl"))]
const TRIPLE_X86_64_UNKNOWN_LINUX: &'static str = "x86_64-unknown-linux-gnu";
#[cfg(target_env="musl")]
const TRIPLE_X86_64_UNKNOWN_LINUX: &'static str = "x86_64-unknown-linux-musl";

// MIPS platforms don't indicate endianness in uname, however binaries only
// run on boxes with the same endianness, as expected.
// Hence we could distinguish between the variants with compile-time cfg()
Expand Down Expand Up @@ -175,7 +181,7 @@ impl TargetTriple {
(_, b"aarch64") if cfg!(target_os = "android") => Some("aarch64-linux-android"),
(_, b"i686") if cfg!(target_os = "android") => Some("i686-linux-android"),
(_, b"x86_64") if cfg!(target_os = "android") => Some("x86_64-linux-android"),
(b"Linux", b"x86_64") => Some("x86_64-unknown-linux-gnu"),
(b"Linux", b"x86_64") => Some(TRIPLE_X86_64_UNKNOWN_LINUX),
(b"Linux", b"i686") => Some("i686-unknown-linux-gnu"),
(b"Linux", b"mips") => Some(TRIPLE_MIPS_UNKNOWN_LINUX_GNU),
(b"Linux", b"mips64") => Some(TRIPLE_MIPS64_UNKNOWN_LINUX_GNUABI64),
Expand Down

0 comments on commit 4549859

Please sign in to comment.