Skip to content

Commit 6162637

Browse files
committed
travis: Add i586 linux and i686 musl
This commit expands the existing x86_64-musl entry in the Travis matrix to also build/test i586-unknown-linux-gnu and i686-unknown-linux-musl. cc #38531 Closes #39053
1 parent ff591b6 commit 6162637

File tree

9 files changed

+152
-77
lines changed

9 files changed

+152
-77
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ matrix:
1515
# Linux builders, all docker images
1616
- env: IMAGE=arm-android DEPLOY=1
1717
- env: IMAGE=cross DEPLOY=1
18+
- env: IMAGE=linux-tested-targets DEPLOY=1
1819
- env: IMAGE=dist-arm-linux DEPLOY=1
1920
- env: IMAGE=dist-armv7-aarch64-linux DEPLOY=1
2021
- env: IMAGE=dist-freebsd DEPLOY=1
@@ -32,7 +33,6 @@ matrix:
3233
- env: IMAGE=x86_64-gnu-nopt
3334
- env: IMAGE=x86_64-gnu-make
3435
- env: IMAGE=x86_64-gnu-llvm-3.7 ALLOW_PR=1 RUST_BACKTRACE=1
35-
- env: IMAGE=x86_64-musl DEPLOY=1
3636
- env: IMAGE=x86_64-gnu-distcheck
3737

3838
# OSX builders
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM ubuntu:16.04
22

33
RUN apt-get update && apt-get install -y --no-install-recommends \
4-
g++ \
4+
g++-multilib \
55
make \
66
file \
77
curl \
@@ -11,10 +11,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1111
cmake \
1212
xz-utils \
1313
sudo \
14-
gdb
14+
gdb \
15+
patch
1516

1617
WORKDIR /build/
17-
COPY build-musl.sh /build/
18+
COPY musl-libunwind-patch.patch build-musl.sh /build/
1819
RUN sh /build/build-musl.sh && rm -rf /build
1920

2021
RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \
@@ -27,9 +28,17 @@ RUN curl -L https://api.pub.build.mozilla.org/tooltool/sha512/$SCCACHE_DIGEST |
2728
tar xJf - -C /usr/local/bin --strip-components=1
2829

2930
ENV RUST_CONFIGURE_ARGS \
30-
--target=x86_64-unknown-linux-musl \
31-
--musl-root-x86_64=/musl-x86_64
32-
ENV PATH=$PATH:/musl-x86_64/bin
31+
--target=x86_64-unknown-linux-musl,i686-unknown-linux-musl,i586-unknown-linux-gnu \
32+
--musl-root-x86_64=/musl-x86_64 \
33+
--musl-root-i686=/musl-i686
34+
3335
ENV SCRIPT \
34-
python2.7 ../x.py test --target x86_64-unknown-linux-musl && \
35-
python2.7 ../x.py dist --target x86_64-unknown-linux-musl
36+
python2.7 ../x.py test \
37+
--target x86_64-unknown-linux-musl \
38+
--target i686-unknown-linux-musl \
39+
--target i586-unknown-linux-gnu \
40+
&& \
41+
python2.7 ../x.py dist \
42+
--target x86_64-unknown-linux-musl \
43+
--target i686-unknown-linux-musl \
44+
--target i586-unknown-linux-gnu
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/bin/sh
2+
# Copyright 2016 The Rust Project Developers. See the COPYRIGHT
3+
# file at the top-level directory of this distribution and at
4+
# http://rust-lang.org/COPYRIGHT.
5+
#
6+
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
7+
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
8+
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
9+
# option. This file may not be copied, modified, or distributed
10+
# except according to those terms.
11+
12+
set -ex
13+
14+
export CFLAGS="-fPIC"
15+
MUSL=musl-1.1.14
16+
curl https://www.musl-libc.org/releases/$MUSL.tar.gz | tar xzf -
17+
cd $MUSL
18+
./configure --prefix=/musl-x86_64 --disable-shared
19+
make -j10
20+
make install
21+
make clean
22+
# for i686
23+
CFLAGS="$CFLAGS -m32" ./configure --prefix=/musl-i686 --disable-shared --target=i686
24+
make -j10
25+
make install
26+
cd ..
27+
28+
# To build MUSL we're going to need a libunwind lying around, so acquire that
29+
# here and build it.
30+
curl -L https://github.com/llvm-mirror/llvm/archive/release_37.tar.gz | tar xzf -
31+
curl -L https://github.com/llvm-mirror/libunwind/archive/release_37.tar.gz | tar xzf -
32+
33+
# Whoa what's this mysterious patch we're applying to libunwind! Why are we
34+
# swapping the values of ESP/EBP in libunwind?!
35+
#
36+
# Discovered in #35599 it turns out that the vanilla build of libunwind is not
37+
# suitable for unwinding 32-bit musl. After some investigation it ended up
38+
# looking like the register values for ESP/EBP were indeed incorrect (swapped)
39+
# in the source. Similar commits in libunwind (r280099 and r282589) have noticed
40+
# this for other platforms, and we just need to realize it for musl linux as
41+
# well.
42+
#
43+
# More technical info can be found at #35599
44+
cd libunwind-release_37
45+
patch -Np1 < /build/musl-libunwind-patch.patch
46+
cd ..
47+
48+
mkdir libunwind-build
49+
cd libunwind-build
50+
cmake ../libunwind-release_37 -DLLVM_PATH=/build/llvm-release_37 \
51+
-DLIBUNWIND_ENABLE_SHARED=0
52+
make -j10
53+
cp lib/libunwind.a /musl-x86_64/lib
54+
55+
# (Note: the next cmake call doesn't fully override the previous cached one, so remove the cached
56+
# configuration manually. IOW, if don't do this or call make clean we'll end up building libunwind
57+
# for x86_64 again)
58+
rm -rf *
59+
# for i686
60+
CFLAGS="$CFLAGS -m32 -g" CXXFLAGS="$CXXFLAGS -m32 -g" cmake ../libunwind-release_37 \
61+
-DLLVM_PATH=/build/llvm-release_37 \
62+
-DLIBUNWIND_ENABLE_SHARED=0
63+
make -j10
64+
cp lib/libunwind.a /musl-i686/lib
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
diff --git a/include/libunwind.h b/include/libunwind.h
2+
index c5b9633..1360eb2 100644
3+
--- a/include/libunwind.h
4+
+++ b/include/libunwind.h
5+
@@ -151,8 +151,8 @@ enum {
6+
UNW_X86_ECX = 1,
7+
UNW_X86_EDX = 2,
8+
UNW_X86_EBX = 3,
9+
- UNW_X86_EBP = 4,
10+
- UNW_X86_ESP = 5,
11+
+ UNW_X86_ESP = 4,
12+
+ UNW_X86_EBP = 5,
13+
UNW_X86_ESI = 6,
14+
UNW_X86_EDI = 7
15+
};

src/ci/docker/x86_64-musl/build-musl.sh

-33
This file was deleted.

src/test/run-pass/issue-21634.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(cfg_target_feature)]
1112

12-
13+
#[cfg(any(not(target_arch = "x86"), target_feature = "sse2"))]
1314
fn main() {
1415
if let Ok(x) = "3.1415".parse::<f64>() {
1516
assert_eq!(false, x <= 0.0);
@@ -21,3 +22,6 @@ fn main() {
2122
assert_eq!(8.1415, { x += 5.0; x });
2223
}
2324
}
25+
26+
#[cfg(all(target_arch = "x86", not(target_feature = "sse2")))]
27+
fn main() {}

src/test/run-pass/sse2.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,16 @@
1010

1111
#![feature(cfg_target_feature)]
1212

13-
pub fn main() {
13+
use std::env;
14+
15+
fn main() {
16+
// Skip this tests on i586-unknown-linux-gnu where sse2 is disabled
17+
let real_target = env::var("TARGET").unwrap();
18+
if real_target.contains("i586") {
19+
return
20+
}
1421
if cfg!(any(target_arch = "x86", target_arch = "x86_64")) {
1522
assert!(cfg!(target_feature = "sse2"),
16-
"SSE2 was not detected as available on an x86 platform");
23+
"SSE2 was not detected as available on an x86 platform");
1724
}
1825
}

src/tools/compiletest/src/main.rs

+4
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,10 @@ pub fn run_tests(config: &Config) {
319319
// Prevent issue #21352 UAC blocking .exe containing 'patch' etc. on Windows
320320
// If #11207 is resolved (adding manifest to .exe) this becomes unnecessary
321321
env::set_var("__COMPAT_LAYER", "RunAsInvoker");
322+
323+
// Let tests know which target they're running as
324+
env::set_var("TARGET", &config.target);
325+
322326
let res = test::run_tests_console(&opts, tests.into_iter().collect());
323327
match res {
324328
Ok(true) => {}

src/tools/compiletest/src/util.rs

+37-32
Original file line numberDiff line numberDiff line change
@@ -12,39 +12,44 @@ use std::env;
1212
use common::Config;
1313

1414
/// Conversion table from triple OS name to Rust SYSNAME
15-
const OS_TABLE: &'static [(&'static str, &'static str)] = &[("android", "android"),
16-
("bitrig", "bitrig"),
17-
("darwin", "macos"),
18-
("dragonfly", "dragonfly"),
19-
("freebsd", "freebsd"),
20-
("haiku", "haiku"),
21-
("ios", "ios"),
22-
("linux", "linux"),
23-
("mingw32", "windows"),
24-
("netbsd", "netbsd"),
25-
("openbsd", "openbsd"),
26-
("win32", "windows"),
27-
("windows", "windows"),
28-
("solaris", "solaris"),
29-
("emscripten", "emscripten")];
15+
const OS_TABLE: &'static [(&'static str, &'static str)] = &[
16+
("android", "android"),
17+
("bitrig", "bitrig"),
18+
("darwin", "macos"),
19+
("dragonfly", "dragonfly"),
20+
("freebsd", "freebsd"),
21+
("haiku", "haiku"),
22+
("ios", "ios"),
23+
("linux", "linux"),
24+
("mingw32", "windows"),
25+
("netbsd", "netbsd"),
26+
("openbsd", "openbsd"),
27+
("win32", "windows"),
28+
("windows", "windows"),
29+
("solaris", "solaris"),
30+
("emscripten", "emscripten"),
31+
];
3032

31-
const ARCH_TABLE: &'static [(&'static str, &'static str)] = &[("aarch64", "aarch64"),
32-
("amd64", "x86_64"),
33-
("arm", "arm"),
34-
("arm64", "aarch64"),
35-
("hexagon", "hexagon"),
36-
("i386", "x86"),
37-
("i686", "x86"),
38-
("mips", "mips"),
39-
("msp430", "msp430"),
40-
("powerpc", "powerpc"),
41-
("powerpc64", "powerpc64"),
42-
("s390x", "s390x"),
43-
("sparc", "sparc"),
44-
("x86_64", "x86_64"),
45-
("xcore", "xcore"),
46-
("asmjs", "asmjs"),
47-
("wasm32", "wasm32")];
33+
const ARCH_TABLE: &'static [(&'static str, &'static str)] = &[
34+
("aarch64", "aarch64"),
35+
("amd64", "x86_64"),
36+
("arm", "arm"),
37+
("arm64", "aarch64"),
38+
("hexagon", "hexagon"),
39+
("i386", "x86"),
40+
("i586", "x86"),
41+
("i686", "x86"),
42+
("mips", "mips"),
43+
("msp430", "msp430"),
44+
("powerpc", "powerpc"),
45+
("powerpc64", "powerpc64"),
46+
("s390x", "s390x"),
47+
("sparc", "sparc"),
48+
("x86_64", "x86_64"),
49+
("xcore", "xcore"),
50+
("asmjs", "asmjs"),
51+
("wasm32", "wasm32"),
52+
];
4853

4954
pub fn get_os(triple: &str) -> &'static str {
5055
for &(triple_os, os) in OS_TABLE {

0 commit comments

Comments
 (0)