forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#73171 - tblah:riscv-qemu-test, r=pietroalbini
RISC-V Emulated Testing Adds a disabled docker image on which to run RISC-V tests. Based on the armhf image. Test using ``` ./src/ci/docker/run.sh riscv64gc-linux ``` cc: @msizanoen1
- Loading branch information
Showing
7 changed files
with
322 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
src/ci/docker/disabled/riscv64gc-linux/0001-Remove-stime-function-calls.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
From c820da85c65c7f3aa9e9cb3ed71ada69bf9b783e Mon Sep 17 00:00:00 2001 | ||
From: Alistair Francis <alistair.francis@wdc.com> | ||
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 preperation. | ||
|
||
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 <alistair.francis@wdc.com> | ||
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com> | ||
|
||
[Tom Eccles: adjust patch context to apply on top of 1.31.1-stable] | ||
Signed-off-by: Tom Eccles <tom.eccles@codethink.co.uk> | ||
--- | ||
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
# based on armhf-gnu/Dockerfile | ||
FROM ubuntu:20.04 | ||
|
||
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections | ||
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 \ | ||
make \ | ||
patch \ | ||
python3 \ | ||
qemu-system-misc \ | ||
xz-utils | ||
|
||
ENV ARCH=riscv | ||
ENV CROSS_COMPILE=riscv64-linux-gnu- | ||
|
||
WORKDIR /build | ||
|
||
# From https://github.com/michaeljclark/busybear-linux/blob/master/conf/linux.config | ||
COPY riscv64gc-linux/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 | ||
# to be using when running tests. | ||
RUN curl https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.6.16.tar.xz | tar xJf - && \ | ||
cp linux.config linux-5.6.16/.config && \ | ||
cd /build/linux-5.6.16 && \ | ||
make olddefconfig && \ | ||
make -j$(nproc) vmlinux | ||
RUN cp linux-5.6.16/vmlinux /tmp | ||
RUN rm -rf linux-5.6.16 | ||
|
||
# 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 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 | ||
|
||
# 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/* | ||
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 | ||
|
||
# Copy over our init script, which starts up our test server and also a few other | ||
# misc tasks | ||
COPY scripts/qemu-bare-bones-rcS rootfs/etc/init.d/rcS | ||
RUN chmod +x rootfs/etc/init.d/rcS | ||
|
||
# Helper to quickly fill the entropy pool in the kernel | ||
COPY scripts/qemu-bare-bones-addentropy.c /tmp/addentropy.c | ||
RUN riscv64-linux-gnu-gcc addentropy.c -o rootfs/addentropy -static | ||
|
||
# download and build the riscv bootloader | ||
RUN git clone https://github.com/riscv/riscv-pk | ||
WORKDIR /tmp/riscv-pk | ||
# nothing special about this revision: it is just master at the time of writing | ||
# v1.0.0 doesn't build | ||
RUN git checkout 5d9ed238e1cabfbca3c47f50d32894ce94bfc304 | ||
RUN mkdir build && cd build && \ | ||
../configure --with-payload=/tmp/vmlinux --host=riscv64-linux-gnu && \ | ||
make -j$(nproc) && \ | ||
cp bbl /tmp | ||
WORKDIR /tmp | ||
RUN rm -rf /tmp/riscv-pk | ||
|
||
COPY scripts/sccache.sh /scripts/ | ||
RUN sh /scripts/sccache.sh | ||
|
||
ENV RUST_CONFIGURE_ARGS --qemu-riscv64-rootfs=/tmp/rootfs | ||
ENV SCRIPT python3 ../x.py test --target riscv64gc-unknown-linux-gnu | ||
|
||
ENV NO_CHANGE_USER=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
CONFIG_DEFAULT_HOSTNAME="busybear" | ||
CONFIG_SYSVIPC=y | ||
CONFIG_POSIX_MQUEUE=y | ||
CONFIG_IKCONFIG=y | ||
CONFIG_IKCONFIG_PROC=y | ||
CONFIG_CGROUPS=y | ||
CONFIG_CGROUP_SCHED=y | ||
CONFIG_CFS_BANDWIDTH=y | ||
CONFIG_CGROUP_BPF=y | ||
CONFIG_NAMESPACES=y | ||
CONFIG_USER_NS=y | ||
CONFIG_CHECKPOINT_RESTORE=y | ||
CONFIG_BLK_DEV_INITRD=y | ||
CONFIG_EXPERT=y | ||
CONFIG_BPF_SYSCALL=y | ||
CONFIG_SMP=y | ||
CONFIG_MODULES=y | ||
CONFIG_NET=y | ||
CONFIG_PACKET=y | ||
CONFIG_PACKET_DIAG=y | ||
CONFIG_UNIX=y | ||
CONFIG_INET=y | ||
CONFIG_NETLINK_DIAG=y | ||
# CONFIG_WIRELESS is not set | ||
CONFIG_PCI=y | ||
CONFIG_DEVTMPFS=y | ||
CONFIG_BLK_DEV_LOOP=y | ||
CONFIG_VIRTIO_BLK=y | ||
CONFIG_NETDEVICES=y | ||
CONFIG_VIRTIO_NET=y | ||
# CONFIG_ETHERNET is not set | ||
# CONFIG_WLAN is not set | ||
CONFIG_SERIAL_8250=y | ||
CONFIG_SERIAL_8250_CONSOLE=y | ||
CONFIG_SERIAL_OF_PLATFORM=y | ||
CONFIG_HVC_RISCV_SBI=y | ||
# CONFIG_HW_RANDOM is not set | ||
# CONFIG_USB_SUPPORT is not set | ||
CONFIG_VIRTIO_MMIO=y | ||
CONFIG_SIFIVE_PLIC=y | ||
CONFIG_RAS=y | ||
CONFIG_EXT2_FS=y | ||
CONFIG_EXT3_FS=y | ||
CONFIG_EXT4_FS_POSIX_ACL=y | ||
CONFIG_AUTOFS4_FS=y | ||
CONFIG_MSDOS_FS=y | ||
CONFIG_VFAT_FS=y | ||
CONFIG_TMPFS=y | ||
# CONFIG_CRYPTO_ECHAINIV is not set | ||
# CONFIG_CRYPTO_HW is not set | ||
CONFIG_PRINTK_TIME=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters