Skip to content

Commit e820504

Browse files
committed
Support MIPS32R2 linux-gnu/linux-uclibc again
1 parent 93f2d63 commit e820504

10 files changed

+43
-47
lines changed

.github/.cspell/project-dictionary.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ MKUNPRIVED
108108
mlong
109109
mpcore
110110
mrproper
111+
msoft
111112
mstrict
112113
mthumb
113114
multilib

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@
4545
| `armv7-unknown-linux-gnueabihf` | 2.27 | 7.4.0 | x86_64/aarch64 linux (glibc 2.27+) |
4646
| `i586-unknown-linux-gnu` | 2.27 | 7.4.0 | x86_64/aarch64 linux (glibc 2.27+) |
4747
| `i686-unknown-linux-gnu` | 2.27 | 7.4.0 | x86_64/aarch64 linux (glibc 2.27+) |
48-
| `mips-unknown-linux-gnu` | 2.27 | 7.4.0 | x86_64 linux (glibc 2.27+) |
49-
| `mips64-unknown-linux-gnuabi64` | 2.27 | 7.4.0 | x86_64 linux (glibc 2.27+) |
50-
| `mips64el-unknown-linux-gnuabi64` | 2.27 | 7.4.0 | x86_64 linux (glibc 2.27+) |
51-
| `mipsel-unknown-linux-gnu` | 2.27 | 7.4.0 | x86_64 linux (glibc 2.27+) |
48+
| `mips-unknown-linux-gnu` (tier3) [1] | 2.27 | 7.4.0 | x86_64 linux (glibc 2.27+) |
49+
| `mips64-unknown-linux-gnuabi64` (tier3) | 2.27 | 7.4.0 | x86_64 linux (glibc 2.27+) |
50+
| `mips64el-unknown-linux-gnuabi64` (tier3) | 2.27 | 7.4.0 | x86_64 linux (glibc 2.27+) |
51+
| `mipsel-unknown-linux-gnu` (tier3) [1] | 2.27 | 7.4.0 | x86_64 linux (glibc 2.27+) |
5252
| `mipsisa32r6-unknown-linux-gnu` (tier3) | 2.31 | 9.3.0 | x86_64 linux (glibc 2.31+) |
5353
| `mipsisa32r6el-unknown-linux-gnu` (tier3) | 2.31 | 9.3.0 | x86_64 linux (glibc 2.31+) |
5454
| `mipsisa64r6-unknown-linux-gnuabi64` (tier3) | 2.31 | 9.3.0 | x86_64 linux (glibc 2.31+) |
@@ -65,6 +65,8 @@
6565
| `x86_64-unknown-linux-gnu` | host (x86_64 host) / 2.27 (aarch64 host) | host (x86_64 host) / 7.4.0 (aarch64 host) | x86_64/aarch64 linux (glibc 2.27+) |
6666
| `x86_64-unknown-linux-gnux32` | 2.27 | 7.4.0 | x86_64/aarch64 linux (glibc 2.27+) |
6767

68+
[1] Since nightly-2023-07-05, mips{,el}-unknown-linux-gnu requires release mode for building std<br>
69+
6870
### Linux (musl)
6971

7072
| libc | GCC | clang | C++ | test | host |
@@ -111,6 +113,10 @@
111113
- `armv5te-unknown-linux-uclibceabi` (tier3)
112114
- `armv7-unknown-linux-uclibceabi` (tier3)
113115
- `armv7-unknown-linux-uclibceabihf` (tier3)
116+
- `mips-unknown-linux-uclibc` (tier3)
117+
- `mipsel-unknown-linux-uclibc` (tier3)
118+
119+
[1] mips{,el}-unknown-linux-uclibc requires release mode for building std<br>
114120

115121
### Android
116122

docker/clang-cross.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,11 @@ case "${RUST_TARGET}" in
4343
common_flags+=" -march=mips32r2"
4444
# https://github.com/rust-lang/rust/blob/1.70.0/compiler/rustc_target/src/spec/mips_unknown_linux_musl.rs#L7
4545
# https://github.com/rust-lang/rust/blob/1.70.0/compiler/rustc_target/src/spec/mipsel_unknown_linux_musl.rs#L6
46+
# TODO(linux-uclibc): Rust targets are soft-float, but toolchain is hard-float.
4647
# https://github.com/rust-lang/rust/blob/1.70.0/compiler/rustc_target/src/spec/mips_unknown_linux_uclibc.rs#L13
4748
# https://github.com/rust-lang/rust/blob/1.70.0/compiler/rustc_target/src/spec/mipsel_unknown_linux_uclibc.rs#L12
4849
case "${RUST_TARGET}" in
49-
*-linux-musl* | *-linux-uclibc*) common_flags+=" -mfloat-abi=soft" ;;
50+
*-linux-musl*) common_flags+=" -mfloat-abi=soft" ;;
5051
esac
5152
;;
5253
thumbv7neon-*) common_flags+=" -march=armv7-a -mthumb -mfpu=neon-vfpv4 -mfloat-abi=hard" ;;

docker/linux-uclibc.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
ARG UBUNTU_VERSION=18.04
99

1010
# TODO: update to 2021.11-1 or 2022.08-1
11-
# https://toolchains.bootlin.com/releases_armv7-eabihf.html
11+
# https://toolchains.bootlin.com/toolchains.html
1212
# GCC 10.2.0, GDB 9.2, Linux headers 5.4.61, uClibc 1.0.34, binutils 2.34
1313
ARG TOOLCHAIN_VERSION=2020.08-1
1414
ARG GCC_VERSION=10.2.0

docker/test-base/patches/libc+mips-unknown-linux-uclibc.diff

Lines changed: 0 additions & 11 deletions
This file was deleted.

docker/test-base/patches/libc+mipsel-unknown-linux-uclibc.diff

Lines changed: 0 additions & 11 deletions
This file was deleted.

docker/test/entrypoint.sh

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ EOF
100100
clang)
101101
case "${RUST_TARGET}" in
102102
hexagon-unknown-linux-musl)
103-
cat >>"${env_path}" <<EOF
103+
cat >>"${env_path}" <<EOF
104104
export AR_${rust_target_lower}=${RUST_TARGET}-ar
105105
export RANLIB_${rust_target_lower}=${RUST_TARGET}-ranlib
106106
export NM=llvm-nm
@@ -109,7 +109,7 @@ export OBJCOPY=${RUST_TARGET}-objcopy
109109
export OBJDUMP=${RUST_TARGET}-objdump
110110
export READELF=${RUST_TARGET}-readelf
111111
EOF
112-
;;
112+
;;
113113
*)
114114
# https://www.kernel.org/doc/html/latest/kbuild/llvm.html#llvm-utilities
115115
cat >>"${env_path}" <<EOF
@@ -185,15 +185,19 @@ export RUSTFLAGS="-C debuginfo=0 \${RUSTFLAGS:-}"
185185
EOF
186186
;;
187187
mips-unknown-linux-uclibc | mipsel-unknown-linux-uclibc)
188-
# mips(el)-buildroot-linux-uclibc-gcc/g++'s default is -march=mips32
189-
# Allow override by user-set `CC_*`.
190-
# Also set to soft-float.
191-
# https://github.com/rust-lang/rust/blob/1.70.0/compiler/rustc_target/src/spec/mips_unknown_linux_uclibc.rs#L13
192-
# https://github.com/rust-lang/rust/blob/1.70.0/compiler/rustc_target/src/spec/mipsel_unknown_linux_uclibc.rs#L12
193-
cat >>"${env_path}" <<EOF
194-
export CFLAGS_${rust_target_lower}="-march=mips32r2 -mfloat-abi=soft \${CFLAGS_${rust_target_lower}:-}"
195-
export CXXFLAGS_${rust_target_lower}="-march=mips32r2 -mfloat-abi=soft \${CXXFLAGS_${rust_target_lower}:-}"
188+
case "${cc}" in
189+
gcc)
190+
# mips(el)-buildroot-linux-uclibc-gcc/g++'s default is -march=mips32
191+
# Allow override by user-set `CC_*`.
192+
# TODO(linux-uclibc): Rust targets are soft-float (-msoft-float), but toolchain is hard-float.
193+
# https://github.com/rust-lang/rust/blob/1.70.0/compiler/rustc_target/src/spec/mips_unknown_linux_uclibc.rs#L13
194+
# https://github.com/rust-lang/rust/blob/1.70.0/compiler/rustc_target/src/spec/mipsel_unknown_linux_uclibc.rs#L12
195+
cat >>"${env_path}" <<EOF
196+
export CFLAGS_${rust_target_lower}="-march=mips32r2 \${CFLAGS_${rust_target_lower}:-}"
197+
export CXXFLAGS_${rust_target_lower}="-march=mips32r2 \${CXXFLAGS_${rust_target_lower}:-}"
196198
EOF
199+
;;
200+
esac
197201
;;
198202
armv5te-none-eabi | thumbv5te-none-eabi)
199203
cat >>"${env_path}" <<EOF

docker/test/test.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ run_cargo() {
2525
if [[ -n "${no_rust_cpp}" ]] && [[ "$*" != *"--no-default-features"* ]]; then
2626
cargo_flags+=(--no-default-features)
2727
fi
28+
if [[ "${build_mode}" == "release" ]] && [[ "$*" != *"--release"* ]]; then
29+
cargo_flags+=(--release)
30+
fi
2831
subcmd="$1"
2932
shift
3033
x cargo "${subcmd}" ${build_std[@]+"${build_std[@]}"} --target "${RUST_TARGET}" ${cargo_flags[@]+"${cargo_flags[@]}"} "$@"
@@ -280,6 +283,8 @@ if [[ -f /BUILD_STD ]]; then
280283
fi
281284
case "${RUST_TARGET}" in
282285
hexagon-unknown-linux-musl) build_std+=(-Z build-std-features=llvm-libunwind) ;;
286+
# TODO(mips): LLVM bug: Undefined temporary symbol error when building std.
287+
mips-unknown-linux-gnu | mipsel-unknown-linux-gnu | mips-unknown-linux-uclibc | mipsel-unknown-linux-uclibc) build_mode=release ;;
283288
esac
284289
fi
285290

@@ -824,7 +829,8 @@ case "${RUST_TARGET}" in
824829
file_header_pat+=('Machine:\s+MIPS R3000' 'Flags:.*mips32r2')
825830
arch_specific_pat+=('ISA: MIPS32r2')
826831
case "${RUST_TARGET}" in
827-
*-linux-musl* | *-linux-uclibc*) arch_specific_pat+=('FP ABI: Soft float') ;;
832+
# TODO(linux-uclibc): should be soft-float
833+
*-linux-musl*) arch_specific_pat+=('FP ABI: Soft float') ;;
828834
*) arch_specific_pat+=('FP ABI: Hard float \(32-bit CPU, Any FPU\)') ;;
829835
esac
830836
;;

platform-support-status-tier3.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ See [platform-support-status.md](platform-support-status.md) for Tier 1 & Tier 2
6565
- [ ] loongarch64-unknown-none
6666
- [ ] loongarch64-unknown-none-softfloat
6767
- [ ] m68k-unknown-linux-gnu
68-
- [ ] mips-unknown-linux-gnu
69-
- [ ] mips-unknown-linux-uclibc
68+
- [x] mips-unknown-linux-gnu
69+
- [x] mips-unknown-linux-uclibc
7070
- [ ] mips64-openwrt-linux-musl
7171
- [x] mips64-unknown-linux-gnuabi64
7272
- [x] mips64el-unknown-linux-gnuabi64
7373
- [ ] mipsel-sony-psp
7474
- [ ] mipsel-sony-psx
75-
- [ ] mipsel-unknown-linux-gnu
76-
- [ ] mipsel-unknown-linux-uclibc
75+
- [x] mipsel-unknown-linux-gnu
76+
- [x] mipsel-unknown-linux-uclibc
7777
- [ ] mipsel-unknown-none
7878
- [x] mipsisa32r6-unknown-linux-gnu
7979
- [x] mipsisa32r6el-unknown-linux-gnu

tools/target-list-shared.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ linux_gnu_targets=(
2020
i686-unknown-linux-gnu
2121
# loongarch64-unknown-linux-gnu
2222
# m68k-unknown-linux-gnu # tier3, build fail: https://github.com/rust-lang/rust/issues/89498
23-
# mips-unknown-linux-gnu # tier3, TODO: LLVM bug: Undefined temporary symbol error when building std.
23+
mips-unknown-linux-gnu # tier3
2424
mips64-unknown-linux-gnuabi64 # tier3
2525
mips64el-unknown-linux-gnuabi64 # tier3
26-
# mipsel-unknown-linux-gnu # tier3, TODO: LLVM bug: Undefined temporary symbol error when building std.
26+
mipsel-unknown-linux-gnu # tier3
2727
mipsisa32r6-unknown-linux-gnu # tier3
2828
mipsisa32r6el-unknown-linux-gnu # tier3
2929
mipsisa64r6-unknown-linux-gnuabi64 # tier3
@@ -71,8 +71,8 @@ linux_uclibc_targets=(
7171
armv5te-unknown-linux-uclibceabi # tier3
7272
armv7-unknown-linux-uclibceabi # tier3
7373
armv7-unknown-linux-uclibceabihf # tier3
74-
# mips-unknown-linux-uclibc # tier3, TODO: error: Undefined temporary symbol $BB6_15
75-
# mipsel-unknown-linux-uclibc # tier3, TODO: error: Undefined temporary symbol $BB6_15
74+
mips-unknown-linux-uclibc # tier3
75+
mipsel-unknown-linux-uclibc # tier3
7676
)
7777
# Linux (OpenHarmony)
7878
linux_ohos_targets=(

0 commit comments

Comments
 (0)