Skip to content

Commit

Permalink
Support NetBSD 10.0 and {aarch64_be,i586,mipsel}-unknown-netbsd
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Apr 3, 2024
1 parent c965e8a commit 2258867
Show file tree
Hide file tree
Showing 14 changed files with 161 additions and 66 deletions.
4 changes: 4 additions & 0 deletions .github/.cspell/project-dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ elfv
emcc
EMSDK
evbarm
evbmips
evbppc
fexceptions
ffreestanding
fmin
fstrict
funwind
fvisibility
gnusrc
HWCAPS
Icelake
INLINES
Expand Down Expand Up @@ -115,12 +117,14 @@ rcrt
rtti
Scrt
secureplt
sharesrc
sjlj
softfp
solarish
stdarch
stdlib
strnlen
syssrc
SYSV
TOOLDIR
uclibcgnueabi
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@ jobs:

# NetBSD
- target: aarch64-unknown-netbsd # tier3
- target: aarch64_be-unknown-netbsd # tier3
- target: armv6-unknown-netbsd-eabihf # tier3
- target: armv7-unknown-netbsd-eabihf # tier3
- target: i586-unknown-netbsd # tier3
- target: i686-unknown-netbsd # tier3
- target: mipsel-unknown-netbsd # tier3
- target: powerpc-unknown-netbsd # tier3
- target: sparc64-unknown-netbsd # tier3
- target: x86_64-unknown-netbsd
Expand Down
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,16 @@ See also [setup-cross-toolchain-action](https://github.com/taiki-e/setup-cross-t

| target | version |
| ------ | ------- |
| `aarch64-unknown-netbsd` (tier3) | 9.3 |
| `armv6-unknown-netbsd-eabihf` (tier3) | 8.2 (default), 9.3 |
| `armv7-unknown-netbsd-eabihf` (tier3) | 8.2 (default), 9.3 |
| `i686-unknown-netbsd` (tier3) | 8.2 (default), 9.3 |
| `powerpc-unknown-netbsd` (tier3) | 8.2 (default), 9.3 |
| `sparc64-unknown-netbsd` (tier3) | 8.2 (default), 9.3 |
| `x86_64-unknown-netbsd` | 8.2 (default), 9.3 |
| `aarch64-unknown-netbsd` (tier3) | 9.3 (default), 10.0 |
| `aarch64_be-unknown-netbsd` (tier3) | 10.0 |
| `armv6-unknown-netbsd-eabihf` (tier3) | 8.2 (default), 9.3, 10.0 |
| `armv7-unknown-netbsd-eabihf` (tier3) | 8.2 (default), 9.3, 10.0 |
| `i586-unknown-netbsd` (tier3) | 8.2 (default), 9.3, 10.0 |
| `i686-unknown-netbsd` (tier3) | 8.2 (default), 9.3, 10.0 |
| `mipsel-unknown-netbsd` (tier3) | 8.2 (default), 9.3, 10.0 |
| `powerpc-unknown-netbsd` (tier3) | 8.2 (default), 9.3, 10.0 |
| `sparc64-unknown-netbsd` (tier3) | 8.2 (default), 9.3, 10.0 |
| `x86_64-unknown-netbsd` | 8.2 (default), 9.3, 10.0 |

### OpenBSD

Expand Down
13 changes: 9 additions & 4 deletions docker/base/build-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,19 @@ case "${target}" in
netbsd_versions=("${NETBSD_VERSION}")
else
# NB: When updating this, the reminder to update tools/build-docker.sh.
netbsd_versions=("8.2" "9.3")
netbsd_versions=("9.3" "10.0")
fi
for netbsd_version in "${netbsd_versions[@]}"; do
case "${target}" in
aarch64-*)
if [[ "${netbsd_version}" == "8"* ]]; then
continue
fi
case "${netbsd_version}" in
8.*) continue ;;
esac
;;
aarch64_be-*)
case "${netbsd_version}" in
[8-9].*) continue ;;
esac
;;
esac
build "netbsd" "${target}" "${netbsd_version%%.*}" \
Expand Down
46 changes: 34 additions & 12 deletions docker/base/netbsd.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,16 @@ SHELL ["/bin/bash", "-eEuxo", "pipefail", "-c"]
ARG NETBSD_VERSION
RUN mkdir -p /build-src
WORKDIR /build-src
RUN curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused "https://ftp.netbsd.org/pub/NetBSD/NetBSD-${NETBSD_VERSION}/source/sets/src.tgz" | tar xzf -
RUN curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused "https://ftp.netbsd.org/pub/NetBSD/NetBSD-${NETBSD_VERSION}/source/sets/gnusrc.tgz" | tar xzf -
RUN curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused "https://ftp.netbsd.org/pub/NetBSD/NetBSD-${NETBSD_VERSION}/source/sets/sharesrc.tgz" | tar xzf -
RUN curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused "https://ftp.netbsd.org/pub/NetBSD/NetBSD-${NETBSD_VERSION}/source/sets/syssrc.tgz" | tar xzf -
RUN <<EOF
case "${NETBSD_VERSION}" in
[1-8].*) base_url=https://archive.netbsd.org/pub/NetBSD-archive ;;
*) base_url=https://ftp.netbsd.org/pub/NetBSD ;;
esac
curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused "${base_url}/NetBSD-${NETBSD_VERSION}/source/sets/src.tgz" | tar xzf -
curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused "${base_url}/NetBSD-${NETBSD_VERSION}/source/sets/gnusrc.tgz" | tar xzf -
curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused "${base_url}/NetBSD-${NETBSD_VERSION}/source/sets/sharesrc.tgz" | tar xzf -
curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused "${base_url}/NetBSD-${NETBSD_VERSION}/source/sets/syssrc.tgz" | tar xzf -
EOF
WORKDIR /

FROM ghcr.io/taiki-e/downloader as sysroot
Expand All @@ -39,6 +45,7 @@ case "${RUST_TARGET}" in
armv6-*) netbsd_arch=evbarm-earmv6hf ;;
armv7-*) netbsd_arch=evbarm-earmv7hf ;;
i?86-*) netbsd_arch=i386 ;;
mipsel-*) netbsd_arch=evbmips-mipsel ;;
powerpc-*) netbsd_arch=evbppc ;;
riscv32*) netbsd_arch=riscv-riscv32 ;;
riscv64*) netbsd_arch=riscv-riscv64 ;;
Expand All @@ -47,19 +54,31 @@ case "${RUST_TARGET}" in
x86_64*) netbsd_arch=amd64 ;;
*) echo >&2 "unrecognized target '${RUST_TARGET}'" && exit 1 ;;
esac
ext=.tgz
cmd=xzf
ext=tar.xz
case "${RUST_TARGET}" in
sparc64-* | x86_64*)
if [[ "${NETBSD_VERSION}" != "8"* ]]; then
ext=.tar.xz
cmd=xJf
fi
case "${NETBSD_VERSION}" in
[1-8].*) ext=tgz ;;
esac
;;
aarch64-* | aarch64_be-*)
case "${NETBSD_VERSION}" in
[1-9].*) ext=tgz ;;
esac
;;
*) ext=tgz ;;
esac
case "${ext}" in
tar.xz) cmd=xJf ;;
*) cmd=xzf ;;
esac
case "${NETBSD_VERSION}" in
[1-8].*) base_url=https://archive.netbsd.org/pub/NetBSD-archive ;;
*) base_url=https://ftp.netbsd.org/pub/NetBSD ;;
esac
curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused "https://ftp.netbsd.org/pub/NetBSD/NetBSD-${NETBSD_VERSION}/${netbsd_arch}/binary/sets/base${ext}" \
curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused "${base_url}/NetBSD-${NETBSD_VERSION}/${netbsd_arch}/binary/sets/base.${ext}" \
| tar "${cmd}" - -C /sysroot ./lib ./usr/include ./usr/lib
curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused "https://ftp.netbsd.org/pub/NetBSD/NetBSD-${NETBSD_VERSION}/${netbsd_arch}/binary/sets/comp${ext}" \
curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused "${base_url}/NetBSD-${NETBSD_VERSION}/${netbsd_arch}/binary/sets/comp.${ext}" \
| tar "${cmd}" - -C /sysroot ./usr/include ./usr/lib
EOF

Expand All @@ -83,6 +102,7 @@ case "${RUST_TARGET}" in
armv6-*) cc_target=armv6--netbsdelf-eabihf ;;
armv7-*) cc_target=armv7--netbsdelf-eabihf ;;
i?86-*) cc_target=i486--netbsdelf ;;
mipsel-*) cc_target=mipsel--netbsd ;;
powerpc-*) cc_target=powerpc--netbsd ;;
riscv32*) cc_target=riscv32--netbsd ;;
riscv64*) cc_target=riscv64--netbsd ;;
Expand All @@ -109,6 +129,7 @@ case "${RUST_TARGET}" in
armv6-*) args=(-m evbarm -a earmv6hf) ;;
armv7-*) args=(-m evbarm -a earmv7hf) ;;
i?86-*) args=(-m i386) ;;
mipsel-*) args=(-m evbmips -a mipsel) ;;
powerpc-*) args=(-m evbppc) ;;
riscv32*) args=(-m riscv -a riscv32) ;;
riscv64*) args=(-m riscv -a riscv64) ;;
Expand All @@ -127,6 +148,7 @@ WORKDIR /
RUN <<EOF
case "${RUST_TARGET}" in
armv7-*) common_flags=" -march=armv7-a -mthumb -mfpu=vfpv3-d16 -mfloat-abi=hard" ;;
mips-* | mipsel-*) common_flags=" -march=mips32r2" ;;
esac
cc_target=$(</CC_TARGET)
cat >"${TOOLCHAIN_DIR}/bin/${RUST_TARGET}-gcc" <<EOF2
Expand Down
2 changes: 2 additions & 0 deletions docker/netbsd.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# SPDX-License-Identifier: Apache-2.0 OR MIT

# Refs:
# - https://doc.rust-lang.org/nightly/rustc/platform-support/netbsd.html
# - https://github.com/rust-lang/rust/blob/1.66.0/src/ci/docker/host-x86_64/dist-x86_64-netbsd/build-netbsd-toolchain.sh

# When using clang:
Expand Down Expand Up @@ -35,6 +36,7 @@ case "${RUST_TARGET}" in
armv6-*) cc_target=armv6--netbsdelf-eabihf ;;
armv7-*) cc_target=armv7--netbsdelf-eabihf ;;
i?86-*) cc_target=i486--netbsdelf ;;
mipsel-*) cc_target=mipsel--netbsd ;;
powerpc-*) cc_target=powerpc--netbsd ;;
riscv32*) cc_target=riscv32--netbsd ;;
riscv64*) cc_target=riscv64--netbsd ;;
Expand Down
1 change: 1 addition & 0 deletions docker/openbsd.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# SPDX-License-Identifier: Apache-2.0 OR MIT

# Refs:
# - https://doc.rust-lang.org/nightly/rustc/platform-support/openbsd.html
# - https://github.com/rust-lang/rust/blob/1.70.0/src/doc/rustc/src/platform-support/openbsd.md

ARG UBUNTU_VERSION=20.04
Expand Down
17 changes: 17 additions & 0 deletions docker/test-base/patches/std+i586-unknown-netbsd.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
diff --git a/src/sys/pal/unix/thread_parking/netbsd.rs b/src/sys/pal/unix/thread_parking/netbsd.rs
index 3be0812..90f809a 100644
--- a/src/sys/pal/unix/thread_parking/netbsd.rs
+++ b/src/sys/pal/unix/thread_parking/netbsd.rs
@@ -34,7 +34,11 @@ pub fn park_timeout(dur: Duration, hint: usize) {
// Saturate so that the operation will definitely time out
// (even if it is after the heat death of the universe).
tv_sec: dur.as_secs().try_into().ok().unwrap_or(time_t::MAX),
- tv_nsec: dur.subsec_nanos().into(),
+ tv_nsec: dur
+ .subsec_nanos()
+ .try_into()
+ .ok()
+ .unwrap_or(libc::c_long::MAX),
};

// Timeout needs to be mutable since it is modified on NetBSD 9.0 and
17 changes: 17 additions & 0 deletions docker/test-base/patches/std+mipsel-unknown-netbsd.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
diff --git a/src/sys/pal/unix/thread_parking/netbsd.rs b/src/sys/pal/unix/thread_parking/netbsd.rs
index 3be0812..90f809a 100644
--- a/src/sys/pal/unix/thread_parking/netbsd.rs
+++ b/src/sys/pal/unix/thread_parking/netbsd.rs
@@ -34,7 +34,11 @@ pub fn park_timeout(dur: Duration, hint: usize) {
// Saturate so that the operation will definitely time out
// (even if it is after the heat death of the universe).
tv_sec: dur.as_secs().try_into().ok().unwrap_or(time_t::MAX),
- tv_nsec: dur.subsec_nanos().into(),
+ tv_nsec: dur
+ .subsec_nanos()
+ .try_into()
+ .ok()
+ .unwrap_or(libc::c_long::MAX),
};

// Timeout needs to be mutable since it is modified on NetBSD 9.0 and
6 changes: 4 additions & 2 deletions docker/test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ if [[ -f /BUILD_STD ]]; then
build_std+=(-Z build-std-features=llvm-libunwind)
;;
# TODO(mips): LLVM bug: Undefined temporary symbol error when building std.
mips-*-linux-* | mipsel-*-linux-*) build_mode=release ;;
mips-* | mipsel-*) build_mode=release ;;
esac
fi

Expand Down Expand Up @@ -768,7 +768,7 @@ case "${RUST_TARGET}" in
# https://github.com/rust-lang/rust/blob/1.70.0/compiler/rustc_target/src/spec/armv7_linux_androideabi.rs#L21
# https://github.com/rust-lang/rust/pull/33414
# https://github.com/rust-lang/rust/blob/1.70.0/compiler/rustc_target/src/spec/armv7_unknown_netbsd_eabihf.rs#L13
*-android*) fp_arch='(VFPv3|VFPv3-D16)' ;;
*-android* | *-netbsd*) fp_arch='(VFPv3|VFPv3-D16)' ;;
# https://github.com/rust-lang/rust/blob/1.70.0/compiler/rustc_target/src/spec/thumbv7em_none_eabihf.rs#L22-L31
thumbv7em-*) fp_arch=VFPv4-D16 ;;
*) fp_arch=VFPv3-D16 ;;
Expand Down Expand Up @@ -827,6 +827,8 @@ case "${RUST_TARGET}" in
case "${RUST_TARGET}" in
# TODO(linux-uclibc): should be soft-float
*-linux-musl*) arch_specific_pat+=('FP ABI: Soft float') ;;
# TODO(netbsd):
*-netbsd*) arch_specific_pat+=('FP ABI: Hard float (\(double precision\)|\(32-bit CPU, Any FPU\))') ;;
*) arch_specific_pat+=('FP ABI: Hard float \(32-bit CPU, Any FPU\)') ;;
esac
;;
Expand Down
6 changes: 3 additions & 3 deletions platform-support-status-tier3.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ See [platform-support-status.md](platform-support-status.md) for Tier 1 & Tier 2
- [ ] aarch64-wrs-vxworks
- [x] aarch64_be-unknown-linux-gnu
- [ ] aarch64_be-unknown-linux-gnu_ilp32
- [ ] aarch64_be-unknown-netbsd
- [x] aarch64_be-unknown-netbsd
- [ ] arm64_32-apple-watchos
- [ ] arm64e-apple-darwin
- [ ] arm64e-apple-ios
Expand Down Expand Up @@ -63,7 +63,7 @@ See [platform-support-status.md](platform-support-status.md) for Tier 1 & Tier 2
- [ ] hexagon-unknown-none-elf
- [ ] i386-apple-ios
- [ ] i586-pc-nto-qnx700
- [ ] i586-unknown-netbsd
- [x] i586-unknown-netbsd
- [ ] i686-apple-darwin
- [x] i686-pc-windows-gnullvm
- [ ] i686-unknown-haiku
Expand All @@ -89,7 +89,7 @@ See [platform-support-status.md](platform-support-status.md) for Tier 1 & Tier 2
- [x] mipsel-unknown-linux-gnu
- [x] mipsel-unknown-linux-musl
- [x] mipsel-unknown-linux-uclibc
- [ ] mipsel-unknown-netbsd
- [x] mipsel-unknown-netbsd
- [ ] mipsel-unknown-none
- [ ] mipsisa32r6-unknown-linux-gnu
- [ ] mipsisa32r6el-unknown-linux-gnu
Expand Down
47 changes: 27 additions & 20 deletions tools/build-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,10 @@ for target in "${targets[@]}"; do
freebsd_versions=("${FREEBSD_VERSION}")
else
# FreeBSD have binary compatibility with previous releases.
# Therefore, the default is FreeBSD 12 that is the minimum supported version.
# However, we don't support FreeBSD 12 for the following targets, because:
# Therefore, the default is the minimum supported version.
# However, we don't support old FreeBSD for the following targets:
# - powerpc,powerpc64: FreeBSD 12 uses gcc instead of clang.
# - powerpc64le,riscv64: not available in FreeBSD 12.
# - powerpc64le,riscv64: available on FreeBSD 13+.
# See also https://www.freebsd.org/releases/13.0R/announce.
#
# Supported releases: https://www.freebsd.org/security/#sup
Expand All @@ -259,16 +259,17 @@ for target in "${targets[@]}"; do
# https://endoflife.date/freebsd
# NB: When updating this, the reminder to update tools/docker-manifest.sh and README.md.
# TODO: 12.4 was EoL on 2023-12-31.
# TODO: 13.2 will be EoL on 2024-06-30.
freebsd_versions=("12.4" "13.2" "14.0")
fi
default_freebsd_version="12"
default_freebsd_version=12
for freebsd_version in "${freebsd_versions[@]}"; do
case "${target}" in
powerpc-* | powerpc64-* | powerpc64le-* | riscv64*)
default_freebsd_version="13"
if [[ "${freebsd_version}" == "12"* ]]; then
continue
fi
powerpc* | riscv64*)
default_freebsd_version=13
case "${freebsd_version}" in
12.*) continue ;;
esac
;;
esac
build "freebsd" "${target}" "${freebsd_version%%.*}" "${default_freebsd_version}" \
Expand All @@ -280,27 +281,33 @@ for target in "${targets[@]}"; do
netbsd_versions=("${NETBSD_VERSION}")
else
# NetBSD have binary compatibility with previous releases.
# Therefore, the default is NetBSD 8 that is the minimum supported version.
# However, we cannot support old NetBSD for the following targets, because:
# - aarch64: not available in NetBSD 8.
# - aarch64_be: not available in NetBSD 8/9.
# See also https://www.netbsd.org/releases/formal-9/NetBSD-9.0.html.
# Therefore, the default is the minimum supported version.
# However, we cannot support old NetBSD for the following targets:
# - aarch64: available on NetBSD 9+ https://www.netbsd.org/releases/formal-9/NetBSD-9.0.html
# - aarch64_be: available on NetBSD 10+ https://www.netbsd.org/releases/formal-10/NetBSD-10.0.html
#
# Supported releases: https://www.netbsd.org/releases
# NetBSD 7 was EoL on 2020-06-30.
# https://www.netbsd.org/releases/formal.html
# https://endoflife.date/netbsd
# NB: When updating this, the reminder to update docker/base/build-docker.sh, tools/docker-manifest.sh, and README.md.
netbsd_versions=("8" "9")
# TODO: 8 will be EoL on 2024-04-28.
netbsd_versions=("8" "9" "10")
fi
default_netbsd_version="8"
default_netbsd_version=8
for netbsd_version in "${netbsd_versions[@]}"; do
case "${target}" in
aarch64-*)
default_netbsd_version="9"
if [[ "${netbsd_version}" == "8"* ]]; then
continue
fi
default_netbsd_version=9
case "${netbsd_version}" in
8) continue ;;
esac
;;
aarch64_be-*)
default_netbsd_version=10
case "${netbsd_version}" in
[8-9]) continue ;;
esac
;;
esac
build "netbsd" "${target}" "${netbsd_version%%.*}" "${default_netbsd_version}" \
Expand Down
Loading

0 comments on commit 2258867

Please sign in to comment.