Skip to content

Conversation

@Chris-godz
Copy link
Contributor

Added GitHub Action for CI:
Runs on ubuntu-22.04

Mlibc compilation:

  • Build libraries for ARM/AArch64/RISC-V32/RISC-V64 with toolchain setup
  • Add artifact downloads

Qemu environments:

  • Pre-built qemu-9.2.2
  • Support mps3-an536, vexpress-a9, virt-aarch64, virt-riscv32/64
  • Monitor qemu logs

Runs on ubuntu-22.04

Mlibc compilation:
- Build libraries for ARM/AArch64/RISC-V32/RISC-V64 with toolchain setup
- Add artifact downloads

Qemu environments:
- Pre-built qemu-9.2.2
- Support mps3-an536, vexpress-a9, virt-aarch64, virt-riscv32/64
- Monitor qemu logs

Signed-off-by: Jiajie Zhou <2293611667@qq.com>
Renamed TARGET to QEMU_TARGET in qemu-hello.mk to avoid conflicts with makefile.

Signed-off-by: Jiajie Zhou 2293611667@qq.com
@Chris-godz
Copy link
Contributor Author

运行的效果,可以参考下面

@unicornx unicornx requested a review from BernardXiong March 24, 2025 22:31
wget -q https://github.com/Chris-godz/mlibc/releases/download/CI/qemu-9.2.2.tar.zst
cat *.tar.zst | zstd -d -T0 | tar -xf - > /dev/null 2>&1
chmod +x ./qemu-9.2.2/qemu_install.sh
sudo ./qemu-9.2.2/qemu_install.sh
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个是不是应该放到 https://github.com/plctlab/mlibc/ 上去,而不是 https://github.com/Chris-godz/mlibc/

另外 qemu_install.sh 干了什么?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个是我编译后的qemu-9.2.2,删掉了不必要的部分, qemu_install.sh是我根据qemu安装的日志,把编译后的部分mov到系统对应的位置

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个是不是应该放到 https://github.com/plctlab/mlibc/ 上去,而不是 https://github.com/Chris-godz/mlibc/

另外 qemu_install.sh 干了什么?

是的,需不需要也把用到的 rtt release 的工具链部分也一起放到mlibc的仓库里面

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我觉得像 gcc 那样统一放 https://github.com/RT-Thread/toolchains-ci/releases 就挺好的,@BernardXiong 熊大给个建议?

@Chris-godz 另外我发现 rv32 的toolchain 你是从一个非官方的地方下载的,其实我记得 riscv64 的 gcc 也是可以编译 rv32 的,就是用 -march 和 -mabi 控制好就好了的。

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我觉得像 gcc 那样统一放 https://github.com/RT-Thread/toolchains-ci/releases 就挺好的,@BernardXiong 熊大给个建议?

问题是,放哪个仓库呢?

Copy link
Collaborator

@unicornx unicornx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

除了 embeded 的 comments 外,我还有几个问题如下:

Q1:从这个 PR 来看,有两个工作:

  • compile-mlibc.yaml: 编译 milbc 库
  • qemu-hello.yaml:编译 elf 并在 qemu 上跑测试

可是编译 elf 本身也会编译 mlibc 和 crt 啊,是否可以合并成一个 yaml? 为啥要设计成两个,有什么特别考虑吗?我的理解是是否可以合并成一个,这样在 ci 时把构建和运行测试一起都做了不好吗?

Q2:我看 ci 会下载 toolchain 和 qemu,特别时 qemu 要下载和安装,这个时间花费大吗?有没有测试过跑一个 ci test 要多长时间?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这是一个 bugfix,应该单独提一个 pr。不建议和这个 pr 一起提交。
我已经提了一个 issue:#57

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是否应该移除这个文件的修改?

@Chris-godz
Copy link
Contributor Author

除了 embeded 的 comments 外,我还有几个问题如下:

Q1:从这个 PR 来看,有两个工作:

  • compile-mlibc.yaml: 编译 milbc 库
  • qemu-hello.yaml:编译 elf 并在 qemu 上跑测试

可是编译 elf 本身也会编译 mlibc 和 crt 啊,是否可以合并成一个 yaml? 为啥要设计成两个,有什么特别考虑吗?我的理解是是否可以合并成一个,这样在 ci 时把构建和运行测试一起都做了不好吗?

Q2:我看 ci 会下载 toolchain 和 qemu,特别时 qemu 要下载和安装,这个时间花费大吗?有没有测试过跑一个 ci test 要多长时间?

Q1的话,两个编译过程还是有细微的区别,主要是两个过程中 mlibc 和 crt 编译时传的 flag 是有区别的,建议还是分成两个吧

Q2的话,可以参考https://github.com/Chris-godz/mlibc/actions/runs/14040200041 ,提前编译好qemu的话,时间大概一分钟左右

@unicornx
Copy link
Collaborator

Q1的话,两个编译过程还是有细微的区别,主要是两个过程中 mlibc 和 crt 编译时传的 flag 是有区别的,建议还是分成两个吧

具体什么差别?还能说一下?

@Chris-godz
Copy link
Contributor Author

Q1的话,两个编译过程还是有细微的区别,主要是两个过程中 mlibc 和 crt 编译时传的 flag 是有区别的,建议还是分成两个吧

具体什么差别?还能说一下?

qemu编译的时候,传给编译器的是 mkconfigs/qemu 下面对应环境的 flag ,而直接编译mlibc不是的

@unicornx
Copy link
Collaborator

Q1的话,两个编译过程还是有细微的区别,主要是两个过程中 mlibc 和 crt 编译时传的 flag 是有区别的,建议还是分成两个吧

具体什么差别?还能说一下?

qemu编译的时候,传给编译器的是 mkconfigs/qemu 下面对应环境的 flag ,而直接编译mlibc不是的

这个问题我感觉还是需要再研究一下。另外我尝试分别执行了 make QEMU_BOARD=qemu-virt-riscv64 ARCH=riscv64make mlibc ARCH=riscv64 我发现前一条命令的执行结果也包含了第二条命令的执行内容。

make_mlibc_ARCH=riscv64.log
make_QEMU_BOARD=qemu-virt-riscv64_ARCH=riscv64.log

附件是 log,可以对比一下。

make QEMU_BOARD=qemu-virt-riscv64 ARCH=riscv64 里为啥会编译两次 mlibc,这是个 bug,还是怎么回事?

不过值得注意的是:make QEMU_BOARD=qemu-virt-riscv64 ARCH=riscv64 里只会编译两次 mlibc,但只编译了一次 crt0。

@Chris-godz
Copy link
Contributor Author

Q1的话,两个编译过程还是有细微的区别,主要是两个过程中 mlibc 和 crt 编译时传的 flag 是有区别的,建议还是分成两个吧

具体什么差别?还能说一下?

qemu编译的时候,传给编译器的是 mkconfigs/qemu 下面对应环境的 flag ,而直接编译mlibc不是的

这个问题我感觉还是需要再研究一下。另外我尝试分别执行了 make QEMU_BOARD=qemu-virt-riscv64 ARCH=riscv64make mlibc ARCH=riscv64 我发现前一条命令的执行结果也包含了第二条命令的执行内容。

make_mlibc_ARCH=riscv64.log make_QEMU_BOARD=qemu-virt-riscv64_ARCH=riscv64.log

附件是 log,可以对比一下。

make QEMU_BOARD=qemu-virt-riscv64 ARCH=riscv64 里为啥会编译两次 mlibc,这是个 bug,还是怎么回事?

不过值得注意的是:make QEMU_BOARD=qemu-virt-riscv64 ARCH=riscv64 里只会编译两次 mlibc,但只编译了一次 crt0。

这里我看了一下,应该是我当时在readme的时候没有说清楚,直接make QEMU_BOARD=qemu-virt-riscv64 ARCH=riscv64会默认触发目标all : mlibc crt0 qemu-hello,所以看起来编译了两次mlibc,这个可以加在 #60 上 , 改成 make qemu-hello QEMU_BOARD=qemu-virt-riscv64 ARCH=riscv64

实际上,两次编译mlibc的时候编译的参数会有差异

  • mlibc: /home/u/ws/bin/rtt-tools-std/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14/bin/riscv64-unknown-elf-gcc -mcmodel=medany -nostdlib -ffreestanding -nostdinc -Wl,-Map=cc.map -I ./include -c crt/riscv64/crt0.c -o build/riscv64/crtobj/crt0.o
  • qemu-hello: /home/u/ws/bin/rtt-tools-std/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14/bin/riscv64-unknown-elf-gcc -c -I ./include -I./helloworld/qemu/qemu-virt-riscv64 -O0 -mcmodel=medany -mstrict-align -D__UNDEF_FFS__ -gdwarf-2 -o build/riscv64/qemu/qemu-virt-riscv64/crtobj/crt0.o crt/riscv64/crt0.c

@unicornx
Copy link
Collaborator

这里我看了一下,应该是我当时在readme的时候没有说清楚,直接make QEMU_BOARD=qemu-virt-riscv64 ARCH=riscv64会默认触发目标all : mlibc crt0 qemu-hello,所以看起来编译了两次mlibc,这个可以加在 #60 上 , 改成 make qemu-hello QEMU_BOARD=qemu-virt-riscv64 ARCH=riscv64

ok, 这个我会在 #60 里一起改掉

实际上,两次编译mlibc的时候编译的参数会有差异

为啥区分开,能否研究一下?或者找人问问?

@BernardXiong
Copy link
Collaborator

这份PR有冲突了,还请修正下,谢谢。

@BernardXiong
Copy link
Collaborator

还帮忙推动下这个PR,随着multilib的加入,ci看护是很重要的一方面。谢谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants