diff --git a/.travis.yml b/.travis.yml index d192deadb0..9574201c18 100644 --- a/.travis.yml +++ b/.travis.yml @@ -42,6 +42,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 } diff --git a/README.md b/README.md index 419344d0f4..07e8664b61 100644 --- a/README.md +++ b/README.md @@ -670,6 +670,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)[†](#vs2019) - [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) diff --git a/ci/cloudfront-invalidation.txt b/ci/cloudfront-invalidation.txt index 265fff4a64..8750a11d04 100644 --- a/ci/cloudfront-invalidation.txt +++ b/ci/cloudfront-invalidation.txt @@ -53,5 +53,7 @@ rustup/dist/x86_64-unknown-freebsd/rustup-init rustup/dist/x86_64-unknown-freebsd/rustup-init.sha256 rustup/dist/x86_64-unknown-linux-gnu/rustup-init rustup/dist/x86_64-unknown-linux-gnu/rustup-init.sha256 +rustup/dist/x86_64-unknown-linux-musl/rustup-init +rustup/dist/x86_64-unknown-linux-musl/rustup-init.sha256 rustup/dist/x86_64-unknown-netbsd/rustup-init rustup/dist/x86_64-unknown-netbsd/rustup-init.sha256 diff --git a/ci/docker/x86_64-unknown-linux-musl/Dockerfile b/ci/docker/x86_64-unknown-linux-musl/Dockerfile new file mode 100644 index 0000000000..e287786430 --- /dev/null +++ b/ci/docker/x86_64-unknown-linux-musl/Dockerfile @@ -0,0 +1,15 @@ +FROM ubuntu:18.04 + +COPY ci/docker/scripts/sccache.sh /scripts/ + +RUN \ + apt-get update && \ + apt-get install -qy \ + musl-dev \ + musl-tools \ + curl \ + ca-certificates \ + perl \ + make \ + gcc && \ + sh /scripts/sccache.sh diff --git a/rustup-init.sh b/rustup-init.sh index 059243bff9..753f93ea9b 100755 --- a/rustup-init.sh +++ b/rustup-init.sh @@ -163,14 +163,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 -q 'musl'; then + _clibtype="musl" + fi fi if [ "$_ostype" = Darwin ] && [ "$_cputype" = i386 ]; then @@ -187,7 +191,7 @@ get_architecture() { ;; Linux) - _ostype=unknown-linux-gnu + _ostype=unknown-linux-$_clibtype _bitness=$(get_bitness) ;; diff --git a/src/dist/dist.rs b/src/dist/dist.rs index dd06d4bb3e..5c1e1c2e89 100644 --- a/src/dist/dist.rs +++ b/src/dist/dist.rs @@ -97,6 +97,13 @@ static LIST_ENVS: &[&str] = &[ "musl", ]; +// Linux hosts don't indicate clib in uname, however binaries only +// run on boxes with the same clib, as expected. +#[cfg(all(not(windows), not(target_env = "musl")))] +const TRIPLE_X86_64_UNKNOWN_LINUX: &str = "x86_64-unknown-linux-gnu"; +#[cfg(all(not(windows), target_env = "musl"))] +const TRIPLE_X86_64_UNKNOWN_LINUX: &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() @@ -176,7 +183,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),