diff --git a/.travis.yml b/.travis.yml
index 24efbdfc93..f4c3439c71 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 }
+ - { os: 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/docker/x86_64-unknown-linux-musl/Dockerfile b/ci/docker/x86_64-unknown-linux-musl/Dockerfile
new file mode 100644
index 0000000000..6c2a57f66b
--- /dev/null
+++ b/ci/docker/x86_64-unknown-linux-musl/Dockerfile
@@ -0,0 +1,13 @@
+FROM ubuntu:18.04
+
+RUN apt-get update && apt-get install -y \
+ musl-dev \
+ musl-tools \
+ curl \
+ ca-certificates \
+ perl \
+ make \
+ gcc
+
+RUN curl -L https://github.com/mozilla/sccache/releases/download/0.2.8/sccache-0.2.8-x86_64-unknown-linux-musl.tar.gz | tar xzf - \
+ && mv ./sccache-0.2.8-x86_64-unknown-linux-musl/sccache /usr/bin/sccache && rm -rf ./sccache-0.2.8-x86_64-unknown-linux-musl
diff --git a/rustup-init.sh b/rustup-init.sh
index c16c50e7ca..c345957d66 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 '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 b4e14201b5..b65369e20a 100644
--- a/src/dist/dist.rs
+++ b/src/dist/dist.rs
@@ -96,6 +96,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()
@@ -175,7 +182,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),