Skip to content

Commit 33534a6

Browse files
authored
Merge pull request #1882 from lzutao/musl-x86_64
Add x86_64-unknown-linux-musl build
2 parents a540515 + bc20830 commit 33534a6

File tree

6 files changed

+33
-3
lines changed

6 files changed

+33
-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>

ci/cloudfront-invalidation.txt

+2
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,7 @@ rustup/dist/x86_64-unknown-freebsd/rustup-init
5353
rustup/dist/x86_64-unknown-freebsd/rustup-init.sha256
5454
rustup/dist/x86_64-unknown-linux-gnu/rustup-init
5555
rustup/dist/x86_64-unknown-linux-gnu/rustup-init.sha256
56+
rustup/dist/x86_64-unknown-linux-musl/rustup-init
57+
rustup/dist/x86_64-unknown-linux-musl/rustup-init.sha256
5658
rustup/dist/x86_64-unknown-netbsd/rustup-init
5759
rustup/dist/x86_64-unknown-netbsd/rustup-init.sha256
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM ubuntu:18.04
2+
3+
COPY ci/docker/scripts/sccache.sh /scripts/
4+
5+
RUN \
6+
apt-get update && \
7+
apt-get install -qy \
8+
musl-dev \
9+
musl-tools \
10+
curl \
11+
ca-certificates \
12+
perl \
13+
make \
14+
gcc && \
15+
sh /scripts/sccache.sh

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 -q '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
@@ -97,6 +97,13 @@ static LIST_ENVS: &[&str] = &[
9797
"musl",
9898
];
9999

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

0 commit comments

Comments
 (0)