Skip to content

Commit 102881d

Browse files
committed
Fix tests, linkers, and specifications for various targets.
This PR: - Fixes linking to libgcc for `armv5te-unknown-linux-musleabi`. - Adds C++ support for FreeBSD targets by linking to `libstdc++`. - Tests dynamic library support for Android targets in CI. - Tests C++ support for `mips64el-unknown-linux-muslabi64` in CI. - Convert mips64el-unknown-linux-muslabi64 to a hard-float toolchain to match the rust target. - Convert mips64el-unknown-linux-muslabi64 to use the mips64r2 architecture. - Convert mips-unknown-linux-musl and mipsel-unknown-linux-musl to use the mips32r2 architecture, identical to the rust targets. - Document whether MIPS musl targets are hard or soft float.
1 parent ab01c6e commit 102881d

12 files changed

+132
-11
lines changed

.changes/1028.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[
2+
{
3+
"description": "link to libgcc for armv5te-unknown-linux-musleabi.",
4+
"type": "fixed"
5+
},
6+
{
7+
"description": "add C++ support for FreeBSD targets.",
8+
"type": "added"
9+
},
10+
{
11+
"description": "test dynamic library support for Android targets in CI.",
12+
"type": "internal"
13+
},
14+
{
15+
"description": "test partial C++ support for mips64el-unknown-linux-muslabi64 in CI.",
16+
"type": "internal"
17+
},
18+
{
19+
"description": "convert mips64el-unknown-linux-muslabi64 to a hard-float toolchain to match the rust target.",
20+
"type": "changed",
21+
"breaking": true
22+
},
23+
{
24+
"description": "convert mips64el-unknown-linux-muslabi64 to use the mips64r2 architecture, identical to the rust target.",
25+
"type": "changed",
26+
"breaking": true
27+
},
28+
{
29+
"description": "document whether MIPS musl targets are hard or soft float.",
30+
"type": "internal"
31+
},
32+
{
33+
"description": "convert mips-unknown-linux-musl and mipsel-unknown-linux-musl to use the mips32r2 architecture, identical to the rust targets.",
34+
"type": "changed",
35+
"breaking": true
36+
}
37+
]

docker/Dockerfile.armv5te-unknown-linux-musleabi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ RUN /musl-symlink.sh $CROSS_MUSL_SYSROOT arm
2626

2727
COPY qemu-runner base-runner.sh /
2828

29-
ENV CARGO_TARGET_ARMV5TE_UNKNOWN_LINUX_MUSLEABI_LINKER=arm-linux-musleabi-gcc \
29+
COPY arm-linux-musleabi-gcc.sh /usr/bin/
30+
31+
ENV CARGO_TARGET_ARMV5TE_UNKNOWN_LINUX_MUSLEABI_LINKER=arm-linux-musleabi-gcc.sh \
3032
CARGO_TARGET_ARMV5TE_UNKNOWN_LINUX_MUSLEABI_RUNNER="/qemu-runner arm" \
3133
CC_armv5te_unknown_linux_musleabi=arm-linux-musleabi-gcc \
3234
CXX_armv5te_unknown_linux_musleabi=arm-linux-musleabi-g++ \

docker/Dockerfile.i686-unknown-freebsd

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ COPY freebsd-install.sh /
1919
COPY freebsd-extras.sh /
2020
RUN /freebsd-extras.sh
2121

22-
ENV CARGO_TARGET_I686_UNKNOWN_FREEBSD_LINKER=i686-unknown-freebsd12-gcc \
22+
COPY i686-unknown-freebsd12-gcc.sh /usr/bin
23+
24+
ENV CARGO_TARGET_I686_UNKNOWN_FREEBSD_LINKER=i686-unknown-freebsd12-gcc.sh \
2325
CC_i686_unknown_freebsd=i686-unknown-freebsd12-gcc \
2426
CXX_i686_unknown_freebsd=i686-unknown-freebsd12-g++ \
2527
BINDGEN_EXTRA_CLANG_ARGS_i686_unknown_freebsd="--sysroot=/usr/local/i686-unknown-freebsd12" \

docker/Dockerfile.mips-unknown-linux-musl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ RUN /xargo.sh
1313
COPY qemu.sh /
1414
RUN /qemu.sh mips
1515

16+
# this is a soft-float target for the mips32r2 architecture
17+
# https://github.com/rust-lang/rust/blob/75d3027fb5ce1af6712e4503c9574802212101bd/compiler/rustc_target/src/spec/mips_unknown_linux_musl.rs#L7
1618
COPY musl.sh /
1719
RUN /musl.sh \
1820
TARGET=mips-linux-muslsf \

docker/Dockerfile.mips64-unknown-linux-muslabi64

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ RUN /xargo.sh
1212
COPY qemu.sh /
1313
RUN /qemu.sh mips64
1414

15+
# this is a hard-float target for the mips64r2 architecture
16+
# https://github.com/rust-lang/rust/blob/75d3027fb5ce1af6712e4503c9574802212101bd/compiler/rustc_target/src/spec/mips64_unknown_linux_muslabi64.rs#L7
1517
COPY musl.sh /
1618
RUN /musl.sh \
1719
TARGET=mips64-linux-musl \

docker/Dockerfile.mips64el-unknown-linux-muslabi64

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,29 @@ RUN /xargo.sh
1212
COPY qemu.sh /
1313
RUN /qemu.sh mips64el
1414

15+
# this is a hard-float target for the mips64r2 architecture
16+
# https://github.com/rust-lang/rust/blob/75d3027fb5ce1af6712e4503c9574802212101bd/compiler/rustc_target/src/spec/mips64el_unknown_linux_muslabi64.rs#L6
1517
COPY musl.sh /
1618
RUN /musl.sh \
17-
TARGET=mips64el-linux-muslsf \
18-
"COMMON_CONFIG += -with-arch=mips64"
19+
TARGET=mips64el-linux-musl \
20+
"COMMON_CONFIG += -with-arch=mips64r2"
1921

20-
ENV CROSS_MUSL_SYSROOT=/usr/local/mips64el-linux-muslsf
22+
ENV CROSS_MUSL_SYSROOT=/usr/local/mips64el-linux-musl
2123
COPY musl-symlink.sh /
22-
RUN /musl-symlink.sh $CROSS_MUSL_SYSROOT mips64el-sf
24+
RUN /musl-symlink.sh $CROSS_MUSL_SYSROOT mips64el
25+
RUN mkdir -p $CROSS_MUSL_SYSROOT/usr/lib64
26+
# needed for the C/C++ runners
27+
RUN ln -s $CROSS_MUSL_SYSROOT/usr/lib/libc.so $CROSS_MUSL_SYSROOT/usr/lib64/libc.so
28+
RUN ln -s $CROSS_MUSL_SYSROOT/usr/lib/libc.so.1 $CROSS_MUSL_SYSROOT/usr/lib64/libc.so.1
29+
30+
COPY mips64el-linux-musl-gcc.sh /usr/bin/
2331

2432
COPY qemu-runner base-runner.sh /
2533

26-
ENV CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_MUSLABI64_LINKER=mips64el-linux-muslsf-gcc \
34+
ENV CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_MUSLABI64_LINKER=mips64el-linux-musl-gcc.sh \
2735
CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_MUSLABI64_RUNNER="/qemu-runner mips64el" \
28-
CC_mips64el_unknown_linux_muslabi64=mips64el-linux-muslsf-gcc \
29-
CXX_mips64el_unknown_linux_muslabi64=mips64el-linux-muslsf-g++ \
36+
CC_mips64el_unknown_linux_muslabi64=mips64el-linux-musl-gcc \
37+
CXX_mips64el_unknown_linux_muslabi64=mips64el-linux-musl-g++ \
3038
BINDGEN_EXTRA_CLANG_ARGS_mips64el_unknown_linux_muslabi64="--sysroot=$CROSS_MUSL_SYSROOT" \
3139
QEMU_LD_PREFIX=$CROSS_MUSL_SYSROOT \
3240
RUST_TEST_THREADS=1

docker/Dockerfile.mipsel-unknown-linux-musl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ RUN /xargo.sh
1313
COPY qemu.sh /
1414
RUN /qemu.sh mipsel
1515

16+
# this is a soft-float target for the mips32r2 architecture
17+
# https://github.com/rust-lang/rust/blob/75d3027fb5ce1af6712e4503c9574802212101bd/compiler/rustc_target/src/spec/mipsel_unknown_linux_musl.rs#L6
1618
COPY musl.sh /
1719
RUN /musl.sh \
1820
TARGET=mipsel-linux-muslsf \
19-
"COMMON_CONFIG += -with-arch=mips32"
21+
"COMMON_CONFIG += -with-arch=mips32r2"
2022

2123
ENV CROSS_MUSL_SYSROOT=/usr/local/mipsel-linux-muslsf
2224
COPY musl-symlink.sh /

docker/Dockerfile.x86_64-unknown-freebsd

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ COPY freebsd-install.sh /
1919
COPY freebsd-extras.sh /
2020
RUN /freebsd-extras.sh
2121

22-
ENV CARGO_TARGET_X86_64_UNKNOWN_FREEBSD_LINKER=x86_64-unknown-freebsd12-gcc \
22+
COPY x86_64-unknown-freebsd12-gcc.sh /usr/bin
23+
24+
ENV CARGO_TARGET_X86_64_UNKNOWN_FREEBSD_LINKER=x86_64-unknown-freebsd12-gcc.sh \
2325
CC_x86_64_unknown_freebsd=x86_64-unknown-freebsd12-gcc \
2426
CXX_x86_64_unknown_freebsd=x86_64-unknown-freebsd12-g++ \
2527
BINDGEN_EXTRA_CLANG_ARGS_x86_64_unknown_freebsd="--sysroot=/usr/local/x86_64-unknown-freebsd12" \
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
# the freebsd images need libstdc++ to be linked as well
4+
# otherwise, we get `undefined reference to `std::ios_base::Init::Init()'`
5+
6+
set -x
7+
set -euo pipefail
8+
9+
main() {
10+
if [[ $# -eq 0 ]]; then
11+
exec i686-unknown-freebsd12-gcc "${@}"
12+
else
13+
exec i686-unknown-freebsd12-gcc "${@}" -lc++ -lstdc++
14+
fi
15+
}
16+
17+
main "${@}"

docker/mips64el-linux-musl-gcc.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
# this linker wrapper works around the missing soft-fp routine __trunctfsf2
4+
# this affects rust versions with compiler-builtins <= 0.1.77,
5+
# which has not yet been merged into stable. this requires the `-lgcc`
6+
# linker flag to provide the missing builtin.
7+
# https://github.com/rust-lang/compiler-builtins/pull/483
8+
9+
set -x
10+
set -euo pipefail
11+
12+
main() {
13+
if [[ $# -eq 0 ]]; then
14+
exec mips64el-linux-musl-gcc "${@}"
15+
else
16+
exec mips64el-linux-musl-gcc "${@}" -lgcc -static-libgcc
17+
fi
18+
}
19+
20+
main "${@}"

0 commit comments

Comments
 (0)