Skip to content

Commit

Permalink
Fix tests, linkers, and specifications for various targets.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Alexhuszagh committed Sep 30, 2022
1 parent ab01c6e commit 0445d3d
Show file tree
Hide file tree
Showing 12 changed files with 132 additions and 11 deletions.
37 changes: 37 additions & 0 deletions .changes/1028.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[
{
"description": "link to libgcc for armv5te-unknown-linux-musleabi.",
"type": "fixed"
},
{
"description": "add C++ support for FreeBSD targets.",
"type": "added"
},
{
"description": "test dynamic library support for Android targets in CI.",
"type": "internal"
},
{
"description": "test partial C++ support for mips64el-unknown-linux-muslabi64 in CI.",
"type": "internal"
},
{
"description": "convert mips64el-unknown-linux-muslabi64 to a hard-float toolchain to match the rust target.",
"type": "changed",
"breaking": true
},
{
"description": "convert mips64el-unknown-linux-muslabi64 to use the mips64r2 architecture, identical to the rust target.",
"type": "changed",
"breaking": true
},
{
"description": "document whether MIPS musl targets are hard or soft float.",
"type": "internal"
},
{
"description": "convert mips-unknown-linux-musl and mipsel-unknown-linux-musl to use the mips32r2 architecture, identical to the rust targets.",
"type": "changed",
"breaking": true
},
]
4 changes: 3 additions & 1 deletion docker/Dockerfile.armv5te-unknown-linux-musleabi
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ RUN /musl-symlink.sh $CROSS_MUSL_SYSROOT arm

COPY qemu-runner base-runner.sh /

ENV CARGO_TARGET_ARMV5TE_UNKNOWN_LINUX_MUSLEABI_LINKER=arm-linux-musleabi-gcc \
COPY arm-linux-musleabi-gcc.sh /usr/bin/

ENV CARGO_TARGET_ARMV5TE_UNKNOWN_LINUX_MUSLEABI_LINKER=arm-linux-musleabi-gcc.sh \
CARGO_TARGET_ARMV5TE_UNKNOWN_LINUX_MUSLEABI_RUNNER="/qemu-runner arm" \
CC_armv5te_unknown_linux_musleabi=arm-linux-musleabi-gcc \
CXX_armv5te_unknown_linux_musleabi=arm-linux-musleabi-g++ \
Expand Down
4 changes: 3 additions & 1 deletion docker/Dockerfile.i686-unknown-freebsd
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ COPY freebsd-install.sh /
COPY freebsd-extras.sh /
RUN /freebsd-extras.sh

ENV CARGO_TARGET_I686_UNKNOWN_FREEBSD_LINKER=i686-unknown-freebsd12-gcc \
COPY i686-unknown-freebsd12-gcc.sh /usr/bin

ENV CARGO_TARGET_I686_UNKNOWN_FREEBSD_LINKER=i686-unknown-freebsd12-gcc.sh \
CC_i686_unknown_freebsd=i686-unknown-freebsd12-gcc \
CXX_i686_unknown_freebsd=i686-unknown-freebsd12-g++ \
BINDGEN_EXTRA_CLANG_ARGS_i686_unknown_freebsd="--sysroot=/usr/local/i686-unknown-freebsd12" \
Expand Down
2 changes: 2 additions & 0 deletions docker/Dockerfile.mips-unknown-linux-musl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ RUN /xargo.sh
COPY qemu.sh /
RUN /qemu.sh mips

# this is a soft-float target for the mips32r2 architecture
# https://github.com/rust-lang/rust/blob/75d3027fb5ce1af6712e4503c9574802212101bd/compiler/rustc_target/src/spec/mips_unknown_linux_musl.rs#L7
COPY musl.sh /
RUN /musl.sh \
TARGET=mips-linux-muslsf \
Expand Down
2 changes: 2 additions & 0 deletions docker/Dockerfile.mips64-unknown-linux-muslabi64
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ RUN /xargo.sh
COPY qemu.sh /
RUN /qemu.sh mips64

# this is a hard-float target for the mips64r2 architecture
# https://github.com/rust-lang/rust/blob/75d3027fb5ce1af6712e4503c9574802212101bd/compiler/rustc_target/src/spec/mips64_unknown_linux_muslabi64.rs#L7
COPY musl.sh /
RUN /musl.sh \
TARGET=mips64-linux-musl \
Expand Down
22 changes: 15 additions & 7 deletions docker/Dockerfile.mips64el-unknown-linux-muslabi64
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,29 @@ RUN /xargo.sh
COPY qemu.sh /
RUN /qemu.sh mips64el

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

ENV CROSS_MUSL_SYSROOT=/usr/local/mips64el-linux-muslsf
ENV CROSS_MUSL_SYSROOT=/usr/local/mips64el-linux-musl
COPY musl-symlink.sh /
RUN /musl-symlink.sh $CROSS_MUSL_SYSROOT mips64el-sf
RUN /musl-symlink.sh $CROSS_MUSL_SYSROOT mips64el
RUN mkdir -p $CROSS_MUSL_SYSROOT/usr/lib64
# needed for the C/C++ runners
RUN ln -s $CROSS_MUSL_SYSROOT/usr/lib/libc.so $CROSS_MUSL_SYSROOT/usr/lib64/libc.so
RUN ln -s $CROSS_MUSL_SYSROOT/usr/lib/libc.so.1 $CROSS_MUSL_SYSROOT/usr/lib64/libc.so.1

COPY mips64el-linux-musl-gcc.sh /usr/bin/

COPY qemu-runner base-runner.sh /

ENV CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_MUSLABI64_LINKER=mips64el-linux-muslsf-gcc \
ENV CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_MUSLABI64_LINKER=mips64el-linux-musl-gcc.sh \
CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_MUSLABI64_RUNNER="/qemu-runner mips64el" \
CC_mips64el_unknown_linux_muslabi64=mips64el-linux-muslsf-gcc \
CXX_mips64el_unknown_linux_muslabi64=mips64el-linux-muslsf-g++ \
CC_mips64el_unknown_linux_muslabi64=mips64el-linux-musl-gcc \
CXX_mips64el_unknown_linux_muslabi64=mips64el-linux-musl-g++ \
BINDGEN_EXTRA_CLANG_ARGS_mips64el_unknown_linux_muslabi64="--sysroot=$CROSS_MUSL_SYSROOT" \
QEMU_LD_PREFIX=$CROSS_MUSL_SYSROOT \
RUST_TEST_THREADS=1
4 changes: 3 additions & 1 deletion docker/Dockerfile.mipsel-unknown-linux-musl
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ RUN /xargo.sh
COPY qemu.sh /
RUN /qemu.sh mipsel

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

ENV CROSS_MUSL_SYSROOT=/usr/local/mipsel-linux-muslsf
COPY musl-symlink.sh /
Expand Down
4 changes: 3 additions & 1 deletion docker/Dockerfile.x86_64-unknown-freebsd
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ COPY freebsd-install.sh /
COPY freebsd-extras.sh /
RUN /freebsd-extras.sh

ENV CARGO_TARGET_X86_64_UNKNOWN_FREEBSD_LINKER=x86_64-unknown-freebsd12-gcc \
COPY x86_64-unknown-freebsd12-gcc.sh /usr/bin

ENV CARGO_TARGET_X86_64_UNKNOWN_FREEBSD_LINKER=x86_64-unknown-freebsd12-gcc.sh \
CC_x86_64_unknown_freebsd=x86_64-unknown-freebsd12-gcc \
CXX_x86_64_unknown_freebsd=x86_64-unknown-freebsd12-g++ \
BINDGEN_EXTRA_CLANG_ARGS_x86_64_unknown_freebsd="--sysroot=/usr/local/x86_64-unknown-freebsd12" \
Expand Down
17 changes: 17 additions & 0 deletions docker/i686-unknown-freebsd12-gcc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

# the freebsd images need libstdc++ to be linked as well
# otherwise, we get `undefined reference to `std::ios_base::Init::Init()'`

set -x
set -euo pipefail

main() {
if [[ $# -eq 0 ]]; then
exec i686-unknown-freebsd12-gcc "${@}"
else
exec i686-unknown-freebsd12-gcc "${@}" -lc++ -lstdc++
fi
}

main "${@}"
20 changes: 20 additions & 0 deletions docker/mips64el-linux-musl-gcc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

# this linker wrapper works around the missing soft-fp routine __trunctfsf2
# this affects rust versions with compiler-builtins <= 0.1.77,
# which has not yet been merged into stable. this requires the `-lgcc`
# linker flag to provide the missing builtin.
# https://github.com/rust-lang/compiler-builtins/pull/483

set -x
set -euo pipefail

main() {
if [[ $# -eq 0 ]]; then
exec mips64el-linux-musl-gcc "${@}"
else
exec mips64el-linux-musl-gcc "${@}" -lgcc -static-libgcc
fi
}

main "${@}"
17 changes: 17 additions & 0 deletions docker/x86_64-unknown-freebsd12-gcc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

# the freebsd images need libstdc++ to be linked as well
# otherwise, we get `undefined reference to `std::ios_base::Init::Init()'`

set -x
set -euo pipefail

main() {
if [[ $# -eq 0 ]]; then
exec x86_64-unknown-freebsd12-gcc "${@}"
else
exec x86_64-unknown-freebsd12-gcc "${@}" -lc++ -lstdc++
fi
}

main "${@}"
10 changes: 10 additions & 0 deletions targets.toml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ run = true
[[target]]
target = "mips64el-unknown-linux-muslabi64"
os = "ubuntu-latest"
# FIXME: Lacking partial C++ support due to missing compiler builtins.
cpp = true
std = true
run = true

Expand Down Expand Up @@ -191,6 +193,7 @@ runners = "qemu-user qemu-system"
target = "riscv64gc-unknown-linux-gnu"
os = "ubuntu-latest"
cpp = true
dylib = true
std = true
run = true
runners = "qemu-user qemu-system"
Expand Down Expand Up @@ -309,20 +312,23 @@ run = true
target = "aarch64-linux-android"
os = "ubuntu-latest"
cpp = true
dylib = true
std = true
run = true

[[target]]
target = "arm-linux-androideabi"
os = "ubuntu-latest"
cpp = true
dylib = true
std = true
run = true

[[target]]
target = "armv7-linux-androideabi"
os = "ubuntu-latest"
cpp = true
dylib = true
std = true
run = true

Expand All @@ -337,13 +343,15 @@ run = true
target = "i686-linux-android"
os = "ubuntu-latest"
cpp = true
dylib = true
std = true
run = true

[[target]]
target = "x86_64-linux-android"
os = "ubuntu-latest"
cpp = true
dylib = true
std = true
run = true

Expand Down Expand Up @@ -387,12 +395,14 @@ build-std = true
[[target]]
target = "i686-unknown-freebsd"
os = "ubuntu-latest"
cpp = true
dylib = true
std = true

[[target]]
target = "x86_64-unknown-freebsd"
os = "ubuntu-latest"
cpp = true
dylib = true
std = true

Expand Down

0 comments on commit 0445d3d

Please sign in to comment.