From 3ba0262c2d254c5510b97e01de198bdc05b27eab Mon Sep 17 00:00:00 2001 From: Ana Hobden Date: Mon, 27 May 2024 13:12:26 -0700 Subject: [PATCH 1/5] CI: Update riscv64gc-linux job to 22.04, rename to riscv64gc-gnu --- .../Dockerfile | 91 ++++++++---------- .../linux.config | 0 .../0001-Remove-stime-function-calls.patch | 96 ------------------- 3 files changed, 39 insertions(+), 148 deletions(-) rename src/ci/docker/host-x86_64/disabled/{riscv64gc-linux => riscv64gc-gnu}/Dockerfile (54%) rename src/ci/docker/host-x86_64/disabled/{riscv64gc-linux => riscv64gc-gnu}/linux.config (100%) delete mode 100644 src/ci/docker/host-x86_64/disabled/riscv64gc-linux/0001-Remove-stime-function-calls.patch diff --git a/src/ci/docker/host-x86_64/disabled/riscv64gc-linux/Dockerfile b/src/ci/docker/host-x86_64/disabled/riscv64gc-gnu/Dockerfile similarity index 54% rename from src/ci/docker/host-x86_64/disabled/riscv64gc-linux/Dockerfile rename to src/ci/docker/host-x86_64/disabled/riscv64gc-gnu/Dockerfile index 07260be35877a..bc7f8c3067312 100644 --- a/src/ci/docker/host-x86_64/disabled/riscv64gc-linux/Dockerfile +++ b/src/ci/docker/host-x86_64/disabled/riscv64gc-gnu/Dockerfile @@ -1,39 +1,36 @@ # based on armhf-gnu/Dockerfile -FROM ubuntu:20.04 +FROM ubuntu:22.04 -RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections +ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update -y && apt-get install -y --no-install-recommends \ - bc \ - bison \ - ca-certificates \ - cmake \ - cpio \ - curl \ - debian-ports-archive-keyring \ - debootstrap \ - flex \ - gcc \ - gcc-riscv64-linux-gnu \ - git \ - g++-riscv64-linux-gnu \ - g++ \ - libc6-dev \ - libc6-dev-riscv64-cross \ - libssl-dev \ - make \ - ninja-build \ - patch \ - python3 \ - qemu-system-misc \ - xz-utils + bc \ + bzip2 \ + ca-certificates \ + cmake \ + cpio \ + curl \ + file \ + flex \ + bison \ + g++ \ + g++-riscv64-linux-gnu \ + git \ + libc6-dev \ + libc6-dev-riscv64-cross \ + libssl-dev \ + make \ + ninja-build \ + python3 \ + qemu-system-riscv64 \ + xz-utils -ENV ARCH=riscv -ENV CROSS_COMPILE=riscv64-linux-gnu- +ENV ARCH=riscv \ + CROSS_COMPILE=riscv64-linux-gnu- WORKDIR /build # From https://github.com/michaeljclark/busybear-linux/blob/master/conf/linux.config -COPY host-x86_64/riscv64gc-linux/linux.config /build +COPY host-x86_64/riscv64gc-gnu/linux.config /build # Compile the kernel that we're going to be emulating with. This is # basically just done to be compatible with the QEMU target that we're going @@ -49,29 +46,22 @@ RUN curl https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.6.16.tar.xz | tar # Compile an instance of busybox as this provides a lightweight system and init # binary which we will boot into. Only trick here is configuring busybox to # build static binaries. -RUN curl https://busybox.net/downloads/busybox-1.31.1.tar.bz2 | tar xjf - -COPY host-x86_64/riscv64gc-linux/0001-Remove-stime-function-calls.patch /build/busybox-1.31.1/ -RUN cd /build/busybox-1.31.1 && \ - patch -p1 -i 0001-Remove-stime-function-calls.patch && \ - make defconfig && \ - sed -i 's/.*CONFIG_STATIC.*/CONFIG_STATIC=y/' .config && \ - make -j$(nproc) && \ - make install && \ - mv _install /tmp/rootfs && \ - cd /build && \ - rm -rf busybox-1.31.1 +RUN curl https://www.busybox.net/downloads/busybox-1.32.1.tar.bz2 | tar xjf - && \ + cd busybox-1.32.1 && \ + make defconfig && \ + sed -i 's/.*CONFIG_STATIC.*/CONFIG_STATIC=y/' .config && \ + make -j$(nproc) && \ + make install && \ + mv _install /tmp/rootfs && \ + cd /build && \ + rm -rf busybox-1.32.1 -# Download the ubuntu rootfs, which we'll use as a chroot for all our tests -# This is only needed to provide /lib/* and /usr/lib/* +# Download the ubuntu rootfs, which we'll use as a chroot for all our tests. WORKDIR /tmp -RUN debootstrap --variant=minbase --arch=riscv64 --foreign focal /tmp/rootfs/ubuntu -RUN cd rootfs && mkdir proc sys dev etc etc/init.d -# rootfs/ubuntu/proc is in a weird state (access fails with ELOOP) until -# rootfs/ubuntu/debootstrap/debootstrap --second-stage is run (under emulation), -# but this takes ages. Instead hack it into a good enough state. -# /proc is used by std::env::current_exe() (which is roughly -# `readlink /proc/self/exe`) -RUN cd rootfs/ubuntu && rm -rf proc && mkdir proc +RUN mkdir rootfs/ubuntu +RUN curl https://cdimage.ubuntu.com/ubuntu-base/releases/22.04/release/ubuntu-base-22.04.2-base-riscv64.tar.gz | \ + tar xzf - -C rootfs/ubuntu && \ + cd rootfs && mkdir proc sys dev etc etc/init.d # Copy over our init script, which starts up our test server and also a few other # misc tasks @@ -95,9 +85,6 @@ RUN mkdir build && cd build && \ WORKDIR /tmp RUN rm -rf /tmp/riscv-pk -COPY scripts/cmake.sh /scripts/ -RUN /scripts/cmake.sh - COPY scripts/sccache.sh /scripts/ RUN sh /scripts/sccache.sh diff --git a/src/ci/docker/host-x86_64/disabled/riscv64gc-linux/linux.config b/src/ci/docker/host-x86_64/disabled/riscv64gc-gnu/linux.config similarity index 100% rename from src/ci/docker/host-x86_64/disabled/riscv64gc-linux/linux.config rename to src/ci/docker/host-x86_64/disabled/riscv64gc-gnu/linux.config diff --git a/src/ci/docker/host-x86_64/disabled/riscv64gc-linux/0001-Remove-stime-function-calls.patch b/src/ci/docker/host-x86_64/disabled/riscv64gc-linux/0001-Remove-stime-function-calls.patch deleted file mode 100644 index 4437a870b207e..0000000000000 --- a/src/ci/docker/host-x86_64/disabled/riscv64gc-linux/0001-Remove-stime-function-calls.patch +++ /dev/null @@ -1,96 +0,0 @@ -From c820da85c65c7f3aa9e9cb3ed71ada69bf9b783e Mon Sep 17 00:00:00 2001 -From: Alistair Francis -Date: Tue, 19 Nov 2019 13:06:40 +0100 -Subject: [PATCH] Remove stime() function calls - -stime() has been deprecated in glibc 2.31 and replaced with -clock_settime(). Let's replace the stime() function calls with -clock_settime() in preparation. - -function old new delta -rdate_main 197 224 +27 -clock_settime - 27 +27 -date_main 926 941 +15 -stime 37 - -37 ------------------------------------------------------------------------------- -(add/remove: 2/2 grow/shrink: 2/0 up/down: 69/-37) Total: 32 bytes - -Signed-off-by: Alistair Francis -Signed-off-by: Denys Vlasenko - -[Tom Eccles: adjust patch context to apply on top of 1.31.1-stable] -Signed-off-by: Tom Eccles ---- - coreutils/date.c | 6 +++++- - libbb/missing_syscalls.c | 8 -------- - util-linux/rdate.c | 8 ++++++-- - 3 files changed, 11 insertions(+), 11 deletions(-) - -diff --git a/coreutils/date.c b/coreutils/date.c -index 3414d38ae..4ade6abb4 100644 ---- a/coreutils/date.c -+++ b/coreutils/date.c -@@ -279,6 +279,9 @@ int date_main(int argc UNUSED_PARAM, char **argv) - time(&ts.tv_sec); - #endif - } -+#if !ENABLE_FEATURE_DATE_NANO -+ ts.tv_nsec = 0; -+#endif - localtime_r(&ts.tv_sec, &tm_time); - - /* If date string is given, update tm_time, and maybe set date */ -@@ -301,9 +304,10 @@ int date_main(int argc UNUSED_PARAM, char **argv) - if (date_str[0] != '@') - tm_time.tm_isdst = -1; - ts.tv_sec = validate_tm_time(date_str, &tm_time); -+ ts.tv_nsec = 0; - - /* if setting time, set it */ -- if ((opt & OPT_SET) && stime(&ts.tv_sec) < 0) { -+ if ((opt & OPT_SET) && clock_settime(CLOCK_REALTIME, &ts) < 0) { - bb_perror_msg("can't set date"); - } - } -diff --git a/libbb/missing_syscalls.c b/libbb/missing_syscalls.c -index 87cf59b3d..dc40d9155 100644 ---- a/libbb/missing_syscalls.c -+++ b/libbb/missing_syscalls.c -@@ -15,14 +15,6 @@ pid_t getsid(pid_t pid) - return syscall(__NR_getsid, pid); - } - --int stime(const time_t *t) --{ -- struct timeval tv; -- tv.tv_sec = *t; -- tv.tv_usec = 0; -- return settimeofday(&tv, NULL); --} -- - int sethostname(const char *name, size_t len) - { - return syscall(__NR_sethostname, name, len); -diff --git a/util-linux/rdate.c b/util-linux/rdate.c -index 70f829e7f..878375d78 100644 ---- a/util-linux/rdate.c -+++ b/util-linux/rdate.c -@@ -95,9 +95,13 @@ int rdate_main(int argc UNUSED_PARAM, char **argv) - if (!(flags & 2)) { /* no -p (-s may be present) */ - if (time(NULL) == remote_time) - bb_error_msg("current time matches remote time"); -- else -- if (stime(&remote_time) < 0) -+ else { -+ struct timespec ts; -+ ts.tv_sec = remote_time; -+ ts.tv_nsec = 0; -+ if (clock_settime(CLOCK_REALTIME, &ts) < 0) - bb_perror_msg_and_die("can't set time of day"); -+ } - } - - if (flags != 1) /* not lone -s */ --- -2.25.1 - From aafa93feeeff5a2c24cf375923b5ce116bf96425 Mon Sep 17 00:00:00 2001 From: Ana Hobden Date: Wed, 29 May 2024 07:34:21 -0700 Subject: [PATCH 2/5] Move riscv64-gnu test out of disabled --- .../docker/host-x86_64/{disabled => }/riscv64gc-gnu/Dockerfile | 0 .../host-x86_64/{disabled => }/riscv64gc-gnu/linux.config | 0 src/ci/github-actions/jobs.yml | 3 +++ 3 files changed, 3 insertions(+) rename src/ci/docker/host-x86_64/{disabled => }/riscv64gc-gnu/Dockerfile (100%) rename src/ci/docker/host-x86_64/{disabled => }/riscv64gc-gnu/linux.config (100%) diff --git a/src/ci/docker/host-x86_64/disabled/riscv64gc-gnu/Dockerfile b/src/ci/docker/host-x86_64/riscv64gc-gnu/Dockerfile similarity index 100% rename from src/ci/docker/host-x86_64/disabled/riscv64gc-gnu/Dockerfile rename to src/ci/docker/host-x86_64/riscv64gc-gnu/Dockerfile diff --git a/src/ci/docker/host-x86_64/disabled/riscv64gc-gnu/linux.config b/src/ci/docker/host-x86_64/riscv64gc-gnu/linux.config similarity index 100% rename from src/ci/docker/host-x86_64/disabled/riscv64gc-gnu/linux.config rename to src/ci/docker/host-x86_64/riscv64gc-gnu/linux.config diff --git a/src/ci/github-actions/jobs.yml b/src/ci/github-actions/jobs.yml index 48c39d2c33e56..8c1ca64f0c415 100644 --- a/src/ci/github-actions/jobs.yml +++ b/src/ci/github-actions/jobs.yml @@ -118,6 +118,9 @@ auto: - image: armhf-gnu <<: *job-linux-4c + - image: riscv64gc-gnu + <<: *job-linux-4c + - image: dist-aarch64-linux env: CODEGEN_BACKENDS: llvm,cranelift From f2e7d79e0c7f3f20032b4c8755e949787abe695f Mon Sep 17 00:00:00 2001 From: Ana Hobden Date: Wed, 29 May 2024 07:35:22 -0700 Subject: [PATCH 3/5] Add riscv64-gnu to PR tests --- src/ci/github-actions/jobs.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ci/github-actions/jobs.yml b/src/ci/github-actions/jobs.yml index 8c1ca64f0c415..72d0ace0a1344 100644 --- a/src/ci/github-actions/jobs.yml +++ b/src/ci/github-actions/jobs.yml @@ -91,6 +91,9 @@ pr: <<: *job-linux-16c - image: x86_64-gnu-tools <<: *job-linux-16c + # TODO: This is temporary and for testing https://github.com/rust-lang/rust/pull/125669 + - image: riscv64gc-gnu + <<: *job-linux-4c # Jobs that run when you perform a try build (@bors try) # These jobs automatically inherit envs.try, to avoid repeating From 4c4eb39bc50230f5d50f451f323cfef2e70962d6 Mon Sep 17 00:00:00 2001 From: Ana Hobden Date: Fri, 31 May 2024 07:46:24 -0700 Subject: [PATCH 4/5] Add workaround for git dubious ownership issue --- src/ci/docker/host-x86_64/riscv64gc-gnu/Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ci/docker/host-x86_64/riscv64gc-gnu/Dockerfile b/src/ci/docker/host-x86_64/riscv64gc-gnu/Dockerfile index bc7f8c3067312..a9ffa5918b5bc 100644 --- a/src/ci/docker/host-x86_64/riscv64gc-gnu/Dockerfile +++ b/src/ci/docker/host-x86_64/riscv64gc-gnu/Dockerfile @@ -88,6 +88,9 @@ RUN rm -rf /tmp/riscv-pk COPY scripts/sccache.sh /scripts/ RUN sh /scripts/sccache.sh +# Avoid "fatal: detected dubious ownership in repository at '/checkout'" error +RUN git config --global --add safe.directory /checkout + ENV RUST_CONFIGURE_ARGS --qemu-riscv64-rootfs=/tmp/rootfs ENV SCRIPT python3 ../x.py --stage 2 test --host='' --target riscv64gc-unknown-linux-gnu From e1b489db8803a233d2d6633cc6aae513e0867224 Mon Sep 17 00:00:00 2001 From: Ana Hobden Date: Mon, 10 Jun 2024 13:25:56 -0700 Subject: [PATCH 5/5] Re-disable riscv64-gnu test --- .../host-x86_64/{ => disabled}/riscv64gc-gnu/Dockerfile | 0 .../host-x86_64/{ => disabled}/riscv64gc-gnu/linux.config | 0 src/ci/github-actions/jobs.yml | 6 ------ 3 files changed, 6 deletions(-) rename src/ci/docker/host-x86_64/{ => disabled}/riscv64gc-gnu/Dockerfile (100%) rename src/ci/docker/host-x86_64/{ => disabled}/riscv64gc-gnu/linux.config (100%) diff --git a/src/ci/docker/host-x86_64/riscv64gc-gnu/Dockerfile b/src/ci/docker/host-x86_64/disabled/riscv64gc-gnu/Dockerfile similarity index 100% rename from src/ci/docker/host-x86_64/riscv64gc-gnu/Dockerfile rename to src/ci/docker/host-x86_64/disabled/riscv64gc-gnu/Dockerfile diff --git a/src/ci/docker/host-x86_64/riscv64gc-gnu/linux.config b/src/ci/docker/host-x86_64/disabled/riscv64gc-gnu/linux.config similarity index 100% rename from src/ci/docker/host-x86_64/riscv64gc-gnu/linux.config rename to src/ci/docker/host-x86_64/disabled/riscv64gc-gnu/linux.config diff --git a/src/ci/github-actions/jobs.yml b/src/ci/github-actions/jobs.yml index 72d0ace0a1344..48c39d2c33e56 100644 --- a/src/ci/github-actions/jobs.yml +++ b/src/ci/github-actions/jobs.yml @@ -91,9 +91,6 @@ pr: <<: *job-linux-16c - image: x86_64-gnu-tools <<: *job-linux-16c - # TODO: This is temporary and for testing https://github.com/rust-lang/rust/pull/125669 - - image: riscv64gc-gnu - <<: *job-linux-4c # Jobs that run when you perform a try build (@bors try) # These jobs automatically inherit envs.try, to avoid repeating @@ -121,9 +118,6 @@ auto: - image: armhf-gnu <<: *job-linux-4c - - image: riscv64gc-gnu - <<: *job-linux-4c - - image: dist-aarch64-linux env: CODEGEN_BACKENDS: llvm,cranelift