Skip to content

Commit c5a22c6

Browse files
committed
Add x86_64-unknown-linux-musl build support
1 parent 5580890 commit c5a22c6

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
@@ -42,6 +42,7 @@ matrix:
4242
- { <<: *linux, env: SKIP_TESTS=1 TARGET=mips64-unknown-linux-gnuabi64 }
4343
- { <<: *linux, env: SKIP_TESTS=1 TARGET=mips64el-unknown-linux-gnuabi64 }
4444
- { <<: *linux, env: SKIP_TESTS=1 TARGET=s390x-unknown-linux-gnu }
45+
- { <<: *linux, env: SKIP_TESTS=1 TARGET=x86_64-unknown-linux-musl }
4546
- { <<: *linux, env: SKIP_TESTS=1 TARGET=arm-linux-androideabi }
4647
- { <<: *linux, env: SKIP_TESTS=1 TARGET=armv7-linux-androideabi }
4748
- { <<: *linux, env: SKIP_TESTS=1 TARGET=aarch64-linux-android }

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,7 @@ platform of your choice:
670670
- [x86_64-pc-windows-msvc](https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe)<sup>[](#vs2019)</sup>
671671
- [x86_64-unknown-freebsd](https://static.rust-lang.org/rustup/dist/x86_64-unknown-freebsd/rustup-init)
672672
- [x86_64-unknown-linux-gnu](https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init)
673+
- [x86_64-unknown-linux-musl](https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-musl/rustup-init)
673674
- [x86_64-unknown-netbsd](https://static.rust-lang.org/rustup/dist/x86_64-unknown-netbsd/rustup-init)
674675

675676
<a name="vs2019">†</a>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM ubuntu:18.04
2+
3+
RUN apt-get update && apt-get install -y \
4+
musl-dev \
5+
musl-tools \
6+
curl \
7+
ca-certificates \
8+
perl \
9+
make \
10+
gcc

rustup-init.sh

+6-2
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,18 @@ get_endianness() {
163163
}
164164

165165
get_architecture() {
166-
local _ostype _cputype _bitness _arch
166+
local _ostype _cputype _bitness _arch _clibtype
167167
_ostype="$(uname -s)"
168168
_cputype="$(uname -m)"
169+
_clibtype="gnu"
169170

170171
if [ "$_ostype" = Linux ]; then
171172
if [ "$(uname -o)" = Android ]; then
172173
_ostype=Android
173174
fi
175+
if [ "$(ldd --version 2>&1 | grep 'musl')" ]; then
176+
_clibtype="musl"
177+
fi
174178
fi
175179

176180
if [ "$_ostype" = Darwin ] && [ "$_cputype" = i386 ]; then
@@ -187,7 +191,7 @@ get_architecture() {
187191
;;
188192

189193
Linux)
190-
_ostype=unknown-linux-gnu
194+
_ostype=unknown-linux-$_clibtype
191195
_bitness=$(get_bitness)
192196
;;
193197

src/dist/dist.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ static LIST_ENVS: &[&str] = &[
9696
"musl",
9797
];
9898

99+
// Linux hosts don't indicate clib in uname, however binaries only
100+
// run on boxes with the same clib, as expected.
101+
#[cfg(all(not(windows), not(target_env = "musl")))]
102+
const TRIPLE_X86_64_UNKNOWN_LINUX: &'static str = "x86_64-unknown-linux-gnu";
103+
#[cfg(all(not(windows), target_env = "musl"))]
104+
const TRIPLE_X86_64_UNKNOWN_LINUX: &'static str = "x86_64-unknown-linux-musl";
105+
99106
// MIPS platforms don't indicate endianness in uname, however binaries only
100107
// run on boxes with the same endianness, as expected.
101108
// Hence we could distinguish between the variants with compile-time cfg()
@@ -175,7 +182,7 @@ impl TargetTriple {
175182
(_, b"aarch64") if cfg!(target_os = "android") => Some("aarch64-linux-android"),
176183
(_, b"i686") if cfg!(target_os = "android") => Some("i686-linux-android"),
177184
(_, 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"),
185+
(b"Linux", b"x86_64") => Some(TRIPLE_X86_64_UNKNOWN_LINUX),
179186
(b"Linux", b"i686") => Some("i686-unknown-linux-gnu"),
180187
(b"Linux", b"mips") => Some(TRIPLE_MIPS_UNKNOWN_LINUX_GNU),
181188
(b"Linux", b"mips64") => Some(TRIPLE_MIPS64_UNKNOWN_LINUX_GNUABI64),

0 commit comments

Comments
 (0)