Skip to content

Commit 4549859

Browse files
committed
Add x86_64-unknown-linux-musl build support
1 parent 819ddda commit 4549859

File tree

5 files changed

+26
-3
lines changed

5 files changed

+26
-3
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ matrix:
3131
- { <<: *linux, env: SKIP_TESTS=1 TARGET=mips64-unknown-linux-gnuabi64 }
3232
- { <<: *linux, env: SKIP_TESTS=1 TARGET=mips64el-unknown-linux-gnuabi64 }
3333
- { <<: *linux, env: SKIP_TESTS=1 TARGET=s390x-unknown-linux-gnu }
34+
- { <<: *linux, env: SKIP_TESTS=1 TARGET=x86_64-unknown-linux-musl }
3435
- { <<: *linux, env: SKIP_TESTS=1 TARGET=arm-linux-androideabi }
3536
- { <<: *linux, env: SKIP_TESTS=1 TARGET=armv7-linux-androideabi }
3637
- { <<: *linux, env: SKIP_TESTS=1 TARGET=aarch64-linux-android }

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,7 @@ platform of your choice:
659659
- [x86_64-pc-windows-msvc](https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe)<sup>[](#vs2015)</sup>
660660
- [x86_64-unknown-freebsd](https://static.rust-lang.org/rustup/dist/x86_64-unknown-freebsd/rustup-init)
661661
- [x86_64-unknown-linux-gnu](https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init)
662+
- [x86_64-unknown-linux-musl](https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-musl/rustup-init)
662663
- [x86_64-unknown-netbsd](https://static.rust-lang.org/rustup/dist/x86_64-unknown-netbsd/rustup-init)
663664

664665
<a name="vs2015">†</a>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM alpine:3.9
2+
3+
RUN apk update && \
4+
apk add \
5+
curl \
6+
ca-certificates \
7+
perl \
8+
make \
9+
gcc
10+
11+
ENV CC_x86_64_unknown_linux_musl=gcc

rustup-init.sh

+6-2
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,18 @@ get_endianness() {
172172
}
173173

174174
get_architecture() {
175-
local _ostype _cputype _bitness _arch
175+
local _ostype _cputype _bitness _arch _clibtype
176176
_ostype="$(uname -s)"
177177
_cputype="$(uname -m)"
178+
_clibtype="gnu"
178179

179180
if [ "$_ostype" = Linux ]; then
180181
if [ "$(uname -o)" = Android ]; then
181182
_ostype=Android
182183
fi
184+
if [ "$(ldd --version 2>&1 | grep 'musl')" ]; then
185+
_clibtype="musl"
186+
fi
183187
fi
184188

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

198202
Linux)
199-
_ostype=unknown-linux-gnu
203+
_ostype=unknown-linux-$_clibtype
200204
_bitness=$(get_bitness)
201205
;;
202206

src/dist/dist.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ static LIST_ENVS: &'static [&'static str] = &[
9595
"musl",
9696
];
9797

98+
// MUSL and GNU targets are both linux
99+
#[cfg(not(target_env="musl"))]
100+
const TRIPLE_X86_64_UNKNOWN_LINUX: &'static str = "x86_64-unknown-linux-gnu";
101+
#[cfg(target_env="musl")]
102+
const TRIPLE_X86_64_UNKNOWN_LINUX: &'static str = "x86_64-unknown-linux-musl";
103+
98104
// MIPS platforms don't indicate endianness in uname, however binaries only
99105
// run on boxes with the same endianness, as expected.
100106
// Hence we could distinguish between the variants with compile-time cfg()
@@ -175,7 +181,7 @@ impl TargetTriple {
175181
(_, b"aarch64") if cfg!(target_os = "android") => Some("aarch64-linux-android"),
176182
(_, b"i686") if cfg!(target_os = "android") => Some("i686-linux-android"),
177183
(_, b"x86_64") if cfg!(target_os = "android") => Some("x86_64-linux-android"),
178-
(b"Linux", b"x86_64") => Some("x86_64-unknown-linux-gnu"),
184+
(b"Linux", b"x86_64") => Some(TRIPLE_X86_64_UNKNOWN_LINUX),
179185
(b"Linux", b"i686") => Some("i686-unknown-linux-gnu"),
180186
(b"Linux", b"mips") => Some(TRIPLE_MIPS_UNKNOWN_LINUX_GNU),
181187
(b"Linux", b"mips64") => Some(TRIPLE_MIPS64_UNKNOWN_LINUX_GNUABI64),

0 commit comments

Comments
 (0)