Skip to content

Commit 7b79041

Browse files
authored
Fix riscv64gc-unknown-linux-gnu target (#1525)
Fix #1423
2 parents 33c4d26 + b780664 commit 7b79041

File tree

8 files changed

+38
-10
lines changed

8 files changed

+38
-10
lines changed

.changes/1525.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"description": "Fix riscv64gc-unknown-linux-gnu target",
3+
"issues": [1423],
4+
"type": "fixed"
5+
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ terminate.
236236
| `powerpc-unknown-linux-gnu` | 2.31 | 9.4.0 || 6.1.0 ||
237237
| `powerpc64-unknown-linux-gnu` | 2.31 | 9.4.0 || 6.1.0 ||
238238
| `powerpc64le-unknown-linux-gnu` | 2.31 | 9.4.0 || 6.1.0 ||
239-
| `riscv64gc-unknown-linux-gnu` | 2.31 | 9.4.0 || 6.1.0 ||
239+
| `riscv64gc-unknown-linux-gnu` | 2.35 | 11.4.0 || 8.2.2 ||
240240
| `s390x-unknown-linux-gnu` | 2.31 | 9.4.0 || 6.1.0 ||
241241
| `sparc64-unknown-linux-gnu` | 2.31 | 9.4.0 || 6.1.0 ||
242242
| `sparcv9-sun-solaris` | 1.22.7 | 8.4.0 || N/A | |

ci/test.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@ main() {
4848
# don't use xargo: should have native support just from rustc
4949
rustup toolchain add nightly
5050
CROSS+=("+nightly")
51-
elif [[ "${TARGET}" == "riscv64gc-unknown-linux-gnu" ]]; then
52-
# FIXME: riscv64gc-unknown-linux-gnu is broken on rustc 1.75, see https://github.com/cross-rs/cross/issues/1423
53-
rustup toolchain add 1.70
54-
CROSS+=("+1.70")
5551
fi
5652

5753
if (( ${STD:-0} )); then

docker/Dockerfile.riscv64gc-unknown-linux-gnu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:20.04 as cross-base
1+
FROM ubuntu:22.04 as cross-base
22
ENV DEBIAN_FRONTEND=noninteractive
33

44
COPY common.sh lib.sh /

docker/lib.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,18 @@ if_ubuntu() {
5454
fi
5555
}
5656

57+
if_ubuntu_ge() {
58+
if grep -q -i ubuntu /etc/os-release; then
59+
local ver
60+
ver="$(source /etc/os-release; echo $VERSION_ID)"
61+
if dpkg --compare-versions "$ver" "ge" "$1"; then
62+
shift
63+
eval "${@}"
64+
fi
65+
fi
66+
}
67+
68+
5769
GNU_MIRRORS=(
5870
"https://ftp.gnu.org/gnu/"
5971
"https://ftpmirror.gnu.org/"

docker/linux-image.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,7 @@ main() {
137137
;;
138138
riscv64)
139139
kernel='6.*-riscv64'
140-
debsource="deb http://ftp.ports.debian.org/debian-ports unstable main"
141-
debsource="${debsource}\ndeb http://ftp.ports.debian.org/debian-ports unreleased main"
142-
debsource="${debsource}\ndeb http://deb.debian.org/debian unstable main"
140+
debsource="deb http://deb.debian.org/debian unstable main"
143141
deps=(libcrypt1:"${arch}")
144142
;;
145143
s390x)
@@ -365,6 +363,7 @@ mkdir /dev/pts
365363
mount -t devpts none /dev/pts/
366364
367365
# some archs does not have virtio modules
366+
# fscache is builtin on riscv64
368367
insmod /modules/failover.ko || insmod /modules/failover.ko.xz || true
369368
insmod /modules/net_failover.ko || insmod /modules/net_failover.ko.xz || true
370369
insmod /modules/virtio.ko || insmod /modules/virtio.ko.xz || true
@@ -375,7 +374,7 @@ insmod /modules/virtio_pci_modern_dev.ko || insmod /modules/virtio_pci_modern_de
375374
insmod /modules/virtio_pci.ko || insmod /modules/virtio_pci.ko.xz || true
376375
insmod /modules/virtio_net.ko || insmod /modules/virtio_net.ko.xz || true
377376
insmod /modules/netfs.ko || insmod /modules/netfs.ko.xz || true
378-
insmod /modules/fscache.ko || insmod /modules/fscache.ko.xz
377+
insmod /modules/fscache.ko || insmod /modules/fscache.ko.xz || true
379378
insmod /modules/9pnet.ko || insmod /modules/9pnet.ko.xz
380379
insmod /modules/9pnet_virtio.ko || insmod /modules/9pnet_virtio.ko.xz || true
381380
insmod /modules/9p.ko || insmod /modules/9p.ko.xz
@@ -390,6 +389,12 @@ mount -t 9p -o trans=virtio target /target -oversion=9p2000.u || true
390389
exec dropbear -F -E -B
391390
EOF
392391

392+
if [[ "${arch}" == "riscv64" ]]; then
393+
# Symlink dynamic loader to /lib/ld-linux-riscv64-lp64d.so.1
394+
mkdir -p "${root}/lib"
395+
ln -s /usr/lib/riscv64-linux-gnu/ld-linux-riscv64-lp64d.so.1 "${root}/lib/ld-linux-riscv64-lp64d.so.1"
396+
fi
397+
393398
chmod +x "${root}/init"
394399
cd "${root}"
395400
find . | cpio --create --format='newc' --quiet | gzip >../initrd.gz

docker/qemu.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ build_static_libffi () {
2929
build_static_libmount () {
3030
local version_spec=2.23.2
3131
local version=2.23
32+
33+
if_ubuntu_ge 22.04 version_spec=2.37.2
34+
if_ubuntu_ge 22.04 version=2.37
35+
3236
local td
3337
td="$(mktemp -d)"
3438

@@ -191,6 +195,9 @@ main() {
191195
libselinux1-dev \
192196
zlib1g-dev
193197

198+
# ubuntu no longer provides statically linked libmount
199+
if_ubuntu_ge 22.04 build_static_libmount
200+
194201
# if we have python3.6+, we can install qemu 7.0.0, which needs ninja-build
195202
# ubuntu 16.04 only provides python3.5, so remove when we have a newer qemu.
196203
is_ge_python36=$(python3 -c "import sys; print(int(sys.version_info >= (3, 6)))")

xtask/src/target_info.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,9 @@ case "${target}" in
288288
libc=$(max_glibc_version "${libdir}")
289289
fi
290290
;;
291+
riscv64gc-unknown-linux-gnu)
292+
libc="$(dpkg-query --showformat='${Version}' --show libc6-riscv64-cross | cut -d- -f1)"
293+
;;
291294
*-*-linux-gnu*)
292295
toolchain_prefix="${!cc_var//-gcc/}"
293296
libdir="/usr/${toolchain_prefix}/lib"

0 commit comments

Comments
 (0)