diff --git a/.changes/1525.json b/.changes/1525.json new file mode 100644 index 000000000..c912f3852 --- /dev/null +++ b/.changes/1525.json @@ -0,0 +1,5 @@ +{ + "description": "Fix riscv64gc-unknown-linux-gnu target", + "issues": [1423], + "type": "fixed" +} diff --git a/README.md b/README.md index edda51a0a..6d0bb7298 100644 --- a/README.md +++ b/README.md @@ -236,7 +236,7 @@ terminate. | `powerpc-unknown-linux-gnu` | 2.31 | 9.4.0 | ✓ | 6.1.0 | ✓ | | `powerpc64-unknown-linux-gnu` | 2.31 | 9.4.0 | ✓ | 6.1.0 | ✓ | | `powerpc64le-unknown-linux-gnu` | 2.31 | 9.4.0 | ✓ | 6.1.0 | ✓ | -| `riscv64gc-unknown-linux-gnu` | 2.31 | 9.4.0 | ✓ | 6.1.0 | ✓ | +| `riscv64gc-unknown-linux-gnu` | 2.35 | 11.4.0 | ✓ | 8.2.2 | ✓ | | `s390x-unknown-linux-gnu` | 2.31 | 9.4.0 | ✓ | 6.1.0 | ✓ | | `sparc64-unknown-linux-gnu` | 2.31 | 9.4.0 | ✓ | 6.1.0 | ✓ | | `sparcv9-sun-solaris` | 1.22.7 | 8.4.0 | ✓ | N/A | | diff --git a/ci/test.sh b/ci/test.sh index 6a164ae54..147c6b06f 100755 --- a/ci/test.sh +++ b/ci/test.sh @@ -48,10 +48,6 @@ main() { # don't use xargo: should have native support just from rustc rustup toolchain add nightly CROSS+=("+nightly") - elif [[ "${TARGET}" == "riscv64gc-unknown-linux-gnu" ]]; then - # FIXME: riscv64gc-unknown-linux-gnu is broken on rustc 1.75, see https://github.com/cross-rs/cross/issues/1423 - rustup toolchain add 1.70 - CROSS+=("+1.70") fi if (( ${STD:-0} )); then diff --git a/docker/Dockerfile.riscv64gc-unknown-linux-gnu b/docker/Dockerfile.riscv64gc-unknown-linux-gnu index 8695d9134..d5ea70a17 100644 --- a/docker/Dockerfile.riscv64gc-unknown-linux-gnu +++ b/docker/Dockerfile.riscv64gc-unknown-linux-gnu @@ -1,4 +1,4 @@ -FROM ubuntu:20.04 as cross-base +FROM ubuntu:22.04 as cross-base ENV DEBIAN_FRONTEND=noninteractive COPY common.sh lib.sh / diff --git a/docker/lib.sh b/docker/lib.sh index dbd225bf4..248374fb1 100644 --- a/docker/lib.sh +++ b/docker/lib.sh @@ -54,6 +54,18 @@ if_ubuntu() { fi } +if_ubuntu_ge() { + if grep -q -i ubuntu /etc/os-release; then + local ver + ver="$(source /etc/os-release; echo $VERSION_ID)" + if dpkg --compare-versions "$ver" "ge" "$1"; then + shift + eval "${@}" + fi + fi +} + + GNU_MIRRORS=( "https://ftp.gnu.org/gnu/" "https://ftpmirror.gnu.org/" diff --git a/docker/linux-image.sh b/docker/linux-image.sh index 58094f9fa..745ac2fa9 100755 --- a/docker/linux-image.sh +++ b/docker/linux-image.sh @@ -137,9 +137,7 @@ main() { ;; riscv64) kernel='6.*-riscv64' - debsource="deb http://ftp.ports.debian.org/debian-ports unstable main" - debsource="${debsource}\ndeb http://ftp.ports.debian.org/debian-ports unreleased main" - debsource="${debsource}\ndeb http://deb.debian.org/debian unstable main" + debsource="deb http://deb.debian.org/debian unstable main" deps=(libcrypt1:"${arch}") ;; s390x) @@ -365,6 +363,7 @@ mkdir /dev/pts mount -t devpts none /dev/pts/ # some archs does not have virtio modules +# fscache is builtin on riscv64 insmod /modules/failover.ko || insmod /modules/failover.ko.xz || true insmod /modules/net_failover.ko || insmod /modules/net_failover.ko.xz || true 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 insmod /modules/virtio_pci.ko || insmod /modules/virtio_pci.ko.xz || true insmod /modules/virtio_net.ko || insmod /modules/virtio_net.ko.xz || true insmod /modules/netfs.ko || insmod /modules/netfs.ko.xz || true -insmod /modules/fscache.ko || insmod /modules/fscache.ko.xz +insmod /modules/fscache.ko || insmod /modules/fscache.ko.xz || true insmod /modules/9pnet.ko || insmod /modules/9pnet.ko.xz insmod /modules/9pnet_virtio.ko || insmod /modules/9pnet_virtio.ko.xz || true 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 exec dropbear -F -E -B EOF + if [[ "${arch}" == "riscv64" ]]; then + # Symlink dynamic loader to /lib/ld-linux-riscv64-lp64d.so.1 + mkdir -p "${root}/lib" + ln -s /usr/lib/riscv64-linux-gnu/ld-linux-riscv64-lp64d.so.1 "${root}/lib/ld-linux-riscv64-lp64d.so.1" + fi + chmod +x "${root}/init" cd "${root}" find . | cpio --create --format='newc' --quiet | gzip >../initrd.gz diff --git a/docker/qemu.sh b/docker/qemu.sh index bef061369..f56dfc83d 100755 --- a/docker/qemu.sh +++ b/docker/qemu.sh @@ -29,6 +29,10 @@ build_static_libffi () { build_static_libmount () { local version_spec=2.23.2 local version=2.23 + + if_ubuntu_ge 22.04 version_spec=2.37.2 + if_ubuntu_ge 22.04 version=2.37 + local td td="$(mktemp -d)" @@ -191,6 +195,9 @@ main() { libselinux1-dev \ zlib1g-dev + # ubuntu no longer provides statically linked libmount + if_ubuntu_ge 22.04 build_static_libmount + # if we have python3.6+, we can install qemu 7.0.0, which needs ninja-build # ubuntu 16.04 only provides python3.5, so remove when we have a newer qemu. is_ge_python36=$(python3 -c "import sys; print(int(sys.version_info >= (3, 6)))") diff --git a/xtask/src/target_info.sh b/xtask/src/target_info.sh index 4be4497ff..1056d6743 100755 --- a/xtask/src/target_info.sh +++ b/xtask/src/target_info.sh @@ -288,6 +288,9 @@ case "${target}" in libc=$(max_glibc_version "${libdir}") fi ;; + riscv64gc-unknown-linux-gnu) + libc="$(dpkg-query --showformat='${Version}' --show libc6-riscv64-cross | cut -d- -f1)" + ;; *-*-linux-gnu*) toolchain_prefix="${!cc_var//-gcc/}" libdir="/usr/${toolchain_prefix}/lib"