Skip to content

Commit

Permalink
support musl and glibc
Browse files Browse the repository at this point in the history
  • Loading branch information
w-mj committed Jun 2, 2024
1 parent 6ad08df commit ffa4c08
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 9 deletions.
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ MUSL_GCC = $(MUSL_PREFIX)-gcc
MUSL_STRIP = $(MUSL_PREFIX)-strip

build_all: busybox lua lmbench libctest iozone libc-bench netperf iperf unix-bench cyclictest time-test test_all true copy-file-range-test interrupts-test ltp
mkdir -p sdcard/lib/glibc
cp -d /usr/riscv64-linux-gnu/lib/*.so* sdcard/lib/glibc
chmod +x sdcard/*_testcode.sh

busybox: .PHONY
cp busybox-config busybox/.config
Expand All @@ -28,7 +31,7 @@ lmbench: .PHONY

libctest: .PHONY
make -C libc-test disk -j $(NPROC)
cp libc-test/disk/* sdcard/
cp -r libc-test/disk/* sdcard/
mv sdcard/run-all.sh sdcard/libctest_testcode.sh

iozone: .PHONY
Expand Down Expand Up @@ -89,6 +92,7 @@ interrupts-test: .PHONY

ltp: .PHONY
cd ltp-full-20240524 && ./configure --host=riscv64-linux-gnu --prefix /code/sdcard/ltp && make -j$(NPROC) && make install
cp scripts/ltp/ltp_testcode.sh sdcard/ltp_testcode.sh

sdcard: build_all .PHONY
dd if=/dev/zero of=sdcard.img count=2048 bs=1M
Expand Down Expand Up @@ -116,6 +120,7 @@ clean: .PHONY
- make -C copy-file-range-test clean
- make -C interrupts-test clean
- make -C ltp-full-20240524 clean
- make -C true clean
- rm -rf sdcard/*
- rm -rf sdcard.img
- rm -rf sdcard.img.gz
Expand Down
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ time-test 为测试Kernel的time函数是否准确,其结果只作为专家评
- `lua`脚本和其他测试脚本要依赖`busybox``sh`功能。所以OS kernel首先需要支持`busybox``sh`功能。
- 部分脚本会需要特定的OS功能(syscall, device file等),OS kernel需要一步一步地添加功能,以支持不同程序的不同执行方式。

在libc-test样例中,包含动态链接的样例程序entry-dynamic.exe。此执行文件的动态链接解释器为/lib/ld-musl-riscv64-sf.so.1,此文件为libc.so的动态链接。
由于Fat32文件系统不支持动态链接功能,因此比赛时各队伍请将/lib/ld-musl-riscv64-sf.so.1当作/libc.so处理。


## 程序的运行环境
示例程序的运行环境是Debian on Qemu RV64,搭建过程如下:
Expand All @@ -35,7 +32,7 @@ time-test 为测试Kernel的time函数是否准确,其结果只作为专家评
> 也可选择使用搭建好的镜像,下载地址:https://pan.baidu.com/s/1VetzxHOv1M4N0DdCpZCCMg 提取码:0uca
> 执行`./run.sh`进入系统,登陆用户名:root,密码:root
下载好镜像之后,将oscomp-debian放在本目录下,修改oscomp-debina/run.sh,在其中加入`-drive file=../sdcard.img,if=none,format=raw,id=x0 -device virtio-blk-device,drive=x0,bus=virtio-mmio-bus.0`参数。执行make qemu进入系统。
下载好镜像之后,将oscomp-debian放在本目录下,修改oscomp-debian/run.sh,在其中加入`-drive file=../sdcard.img,if=none,format=raw,id=x0 -device virtio-blk-device,drive=x0,bus=virtio-mmio-bus.0`参数。执行make qemu进入系统。

进入系统后将/dev/vdb挂载至/mnt,随后可以进入/mnt目录运行测试程序。

Expand Down
7 changes: 5 additions & 2 deletions libc-test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,11 @@ disk: run-all.sh
cp entry-dynamic.exe disk
cp entry-static.exe disk
cp runtest.exe disk
cp src/functional/*.so src/regression/*.so disk
cp $(MUSL_LIB)/libc.so disk
mkdir -p disk/lib/musl
cp src/functional/*.so src/regression/*.so disk/lib
cp $(MUSL_LIB)/libc.so disk/lib/musl
rm -f disk/lib/ld-musl-riscv64-sf.so.1
ln -s musl/libc.so disk/lib/ld-musl-riscv64-sf.so.1
cp run-*.sh disk
# ls -lh disk/
# dd if=/dev/zero of=sdcard.img bs=1024K count=4
Expand Down
2 changes: 2 additions & 0 deletions scripts/ltp/ltp_testcode.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export LD_LIBRARY_PATH=/lib:/lib/glibc
cd /ltp && ./kirk -f ltp -r syscalls
4 changes: 3 additions & 1 deletion scripts/test_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ busybox echo "run netperf_testcode.sh"
busybox echo "run iperf_testcode.sh"
./iperf_testcode.sh
busybox echo "run cyclic_testcode.sh"
./cyclic_testcode.sh
./cyclic_testcode.sh
busybox echo "run ltp_testcode.sh"
./ltp_testcode.sh
5 changes: 4 additions & 1 deletion true/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@

all:
$(CC) main.c -static -Os -o true
$(CC) main.c -static -Os -o true

clean:
rm -f true

0 comments on commit ffa4c08

Please sign in to comment.