Skip to content

feat(build): Support generating XiangShan in docker envrionment #4538

Merged
Tang-Haojin merged 10 commits intomasterfrom
docker_env
May 9, 2025
Merged

feat(build): Support generating XiangShan in docker envrionment #4538
Tang-Haojin merged 10 commits intomasterfrom
docker_env

Conversation

@forever043
Copy link
Copy Markdown
Contributor

@forever043 forever043 commented Apr 10, 2025

In this PR, we provide a docker-based XiangShan build environment, which can effectively reduce the dependency on the host environments and ensure that everyone can use the same environment to generate RTL and subsequent emulator(verilator) sources.

The base docker image will be named as ghcr.io/openxiangshan/xsdev, which was based on ghcr.io/openxiangshan/xs-env:latest image from OpenXiangShan/xs-env. It also contains the chisel/mill environment that XiangShan relies on to generate RTL.

When we use make verilog or make sim-verilog to generate RTL, it will automatically detect whether docker was installed on the system and the required image was exist. If so, the task will be executed in the docker environment, otherwise it will still be executed in the host as usual.

update: make emu-mk was supported, now the verilating job was done in docker.

The image does not contain any XiangShan source code inside. As an alternative, they will be injected into the container by bind-mount mechanism provided by docker run command at runtime as following:

  • (rd) /work -> $srctree
  • (rw) /work/out -> $srctree/.docker-mill-out
  • (rw) /work/build -> $srctree/build

By default, the source code will be bind-mounted to /work directory with readonly permission to prevent it from being modified by mistake. Two additional directories /work/build and /work/out will be mounted with write permission for the final build output and intermediate files of mill. We use separated .docker-mill-out for mill inside docker to prevent it from interfering with the host mill runs.

For subsequent image updates, we provide a make image target to update the image content according to Dockerfile and build.sc, which means that future changes to the environments should be synchronized to the Dockerfile as while.

This PR mainly consists of the following parts:

  1. cleanup current makefile to make sure all generated/temporary files was written to build instead of srctree (because of the read-only mount of srctree)
  2. provide firtool dependency resolve mechanism in build.sc
    • the firtool was download in the late stage of chisel build by default, we move this early to speedup image build
  3. add make image and related Dockerfile for docker image build
  4. add make pull-image to pull latest xsdev image from ghcr.io
  5. add make sh to start an interactive container of xsdev image
  6. adapt verilog, sim-verilog, emu-mk, and test-jar targets so that they can be executed in the docker envrionment
  7. pre-merge ci flow for docker image build, and assembly jar inside docker
  8. post-release ci flow for image build and publish

Future works:

  1. more ci flow for PR check (build in docker flow)
  2. refact makefile to fully separate in-docker/out-of-docker targets

@forever043 forever043 force-pushed the docker_env branch 2 times, most recently from a7768f9 to c329b0b Compare April 27, 2025 17:02
@XiangShanRobot
Copy link
Copy Markdown

[Generated by IPC robot]
commit: c329b0b

commit astar copy_and_run coremark gcc gromacs hmmer-Vector lbm linux mcf microbench milc namd povray wrf xalancbmk
c329b0b 1.821 0.442 2.643 1.234 2.152 1.679 2.139 2.362 0.938 1.400 2.012 3.110 2.540 2.271 3.314

master branch:

commit astar copy_and_run coremark gcc gromacs hmmer-Vector lbm linux mcf microbench milc namd povray wrf xalancbmk
9e1d4bb 1.821 0.442 2.643 1.234 2.152 1.679 2.139 2.362 0.938 1.400 2.012 3.110 2.540 2.271 3.314
4c2188a 1.823 0.442 2.643 1.224 2.152 1.679 2.139 2.362 0.938 1.376 2.012 3.110 2.540 2.271 3.314
e6d8485 1.821 0.442 2.643 1.234 2.152 1.679 2.139 2.362 0.938 1.400 2.012 3.110 2.540 2.271 3.314
b5c2f4c 1.821 0.442 2.643 1.225 2.152 1.679 2.139 2.362 0.938 1.400 2.012 3.110 2.540 2.271 3.314
9680387 1.823 0.442 2.643 1.237 2.152 1.679 2.139 2.362 0.938 1.376 2.012 3.110 2.540 2.271 3.314
a833aaf 1.823 0.442 2.643 1.235 2.152 1.679 2.139 2.362 0.938 1.400 2.012 3.110 2.540 2.271 3.314
98b165a 1.823 0.442 2.643 1.228 2.152 1.679 2.139 2.362 0.938 1.376 2.012 3.110 2.540 2.271 3.314
ee92d6f 1.821 0.442 2.643 1.234 2.152 1.679 2.139 2.362 0.938 1.400 2.012 3.110 2.540 2.271 3.314
6683fc4 1.821 0.442 2.643 1.222 2.152 1.679 2.139 2.362 0.938 1.376 2.012 3.110 2.540 2.271 3.314
00c6a8a 1.821 0.442 2.643 1.231 2.152 1.679 2.139 2.362 0.938 1.376 2.012 3.110 2.540 2.271 3.314

@poemonsense
Copy link
Copy Markdown
Member

I think @cebarobot had a dockerfile for XiangShan (the demo used for last RISC-V Summit Europe?). Maybe we need coordination between groups to avoid duplicated work. Should we discuss how we are going to maintain the environment and let everyone know?

@cebarobot
Copy link
Copy Markdown
Member

I think @cebarobot had a dockerfile for XiangShan (the demo used for last RISC-V Summit Europe?). Maybe we need coordination between groups to avoid duplicated work. Should we discuss how we are going to maintain the environment and let everyone know?

No, I don't have such dockerfile. Recent work on xs-env is just setting up basic tools in an Ubuntu images, which is not the best practice of development container. Currently xs-env provides basic images for Ubuntu (20.04, 22.04, 24.04) and CentOS, mainly for building NEMU and SPIKE.

@poemonsense
Copy link
Copy Markdown
Member

I think @cebarobot had a dockerfile for XiangShan (the demo used for last RISC-V Summit Europe?). Maybe we need coordination between groups to avoid duplicated work. Should we discuss how we are going to maintain the environment and let everyone know?

No, I don't have such dockerfile. Recent work on xs-env is just setting up basic tools in an Ubuntu images, which is not the best practice of development container. Currently xs-env provides basic images for Ubuntu (20.04, 22.04, 24.04) and CentOS, mainly for building NEMU and SPIKE.

Where's the docker that BOSC published before? Who owns it?

@cebarobot
Copy link
Copy Markdown
Member

Where's the docker that BOSC published before? Who owns it?

I believe that docker image is owned by Director An and hosted on Baidu Pan. I remember those images were manually built rather than based on Dockerfile, so they don't offer much reference value. I've been wanting to replace them with a new workflow for a while.

@poemonsense
Copy link
Copy Markdown
Member

Where's the docker that BOSC published before? Who owns it?

I believe that docker image is owned by Director An and hosted on Baidu Pan. I remember those images were manually built rather than based on Dockerfile, so they don't offer much reference value. I've been wanting to replace them with a new workflow for a while.

Fine. Then we should work again for that docker. Let's use this PR.

Copy link
Copy Markdown
Member

@poemonsense poemonsense left a comment

Choose a reason for hiding this comment

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

Probably we should reuse the prebuilt containers from xs-env

@forever043 forever043 force-pushed the docker_env branch 2 times, most recently from 9626044 to 87d1bc0 Compare April 30, 2025 00:41
@XiangShanRobot
Copy link
Copy Markdown

[Generated by IPC robot]
commit: 87d1bc0

commit astar copy_and_run coremark gcc gromacs hmmer-Vector lbm linux mcf microbench milc namd povray wrf xalancbmk
87d1bc0 1.823 0.442 2.643 1.232 2.152 1.679 2.139 2.362 0.938 1.376 2.012 3.110 2.540 2.271 3.314

master branch:

commit astar copy_and_run coremark gcc gromacs hmmer-Vector lbm linux mcf microbench milc namd povray wrf xalancbmk
fdc4433 0.442 2.643 1.245 2.152 1.679 2.139 2.362 0.938 1.376 2.012 3.110 2.540 3.314
3f03196 1.823 0.442 2.643 1.228 2.152 1.679 2.139 2.362 0.938 1.376 2.012 3.110 2.540 2.271 3.314
6a3636f 1.823 0.442 2.643 1.223 2.152 1.679 2.139 2.362 0.938 1.400 2.012 3.110 2.540 2.271 3.314
acf3dcc 1.823 0.442 2.643 1.233 2.152 1.679 2.139 2.362 0.938 1.400 2.012 3.110 2.540 2.271 3.314
6172063 0.442 2.643 1.234 1.679 2.362 0.938 1.376 2.012 3.110 2.540 3.314
bd1e467 1.821 0.442 2.643 1.229 2.152 1.679 2.139 2.362 0.938 1.376 2.012 3.110 2.540 2.271 3.314
e4651c4 1.821 0.442 2.643 1.234 2.152 1.679 2.139 2.362 0.938 1.400 2.012 3.110 2.540 2.271 3.314
bf62c34 1.821 0.442 2.643 1.235 2.152 1.679 2.139 2.362 0.938 1.400 2.012 3.110 2.540 2.271 3.314
31087ce 1.823 0.442 2.643 1.233 2.152 1.679 2.139 2.362 0.938 1.400 2.012 3.110 2.540 2.271 3.314
02734d5 1.823 0.442 2.643 1.230 2.152 1.679 2.139 2.362 0.938 1.376 2.012 3.110 2.540 2.271 3.314

@XiangShanRobot
Copy link
Copy Markdown

[Generated by IPC robot]
commit: ec06438

commit astar copy_and_run coremark gcc gromacs hmmer-Vector lbm linux mcf microbench milc namd povray wrf xalancbmk
ec06438 1.821 0.442 2.643 1.232 2.152 1.679 2.139 2.362 0.938 1.376 2.012 3.110 2.540 2.271 3.314

master branch:

commit astar copy_and_run coremark gcc gromacs hmmer-Vector lbm linux mcf microbench milc namd povray wrf xalancbmk
4a33e05 1.821 0.442 2.643 1.228 2.152 1.679 2.139 2.362 0.938 1.376 2.012 3.110 2.540 2.271 3.314
fdc4433 1.823 0.442 2.643 1.245 2.152 1.679 2.139 2.362 0.938 1.376 2.012 3.110 2.540 2.271 3.314
3f03196 1.823 0.442 2.643 1.228 2.152 1.679 2.139 2.362 0.938 1.376 2.012 3.110 2.540 2.271 3.314
6a3636f 1.823 0.442 2.643 1.223 2.152 1.679 2.139 2.362 0.938 1.400 2.012 3.110 2.540 2.271 3.314
acf3dcc 1.823 0.442 2.643 1.233 2.152 1.679 2.139 2.362 0.938 1.400 2.012 3.110 2.540 2.271 3.314
6172063 0.442 2.643 1.234 1.679 2.362 0.938 1.376 2.012 3.110 2.540 3.314
bd1e467 1.821 0.442 2.643 1.229 2.152 1.679 2.139 2.362 0.938 1.376 2.012 3.110 2.540 2.271 3.314
e4651c4 1.821 0.442 2.643 1.234 2.152 1.679 2.139 2.362 0.938 1.400 2.012 3.110 2.540 2.271 3.314
bf62c34 1.821 0.442 2.643 1.235 2.152 1.679 2.139 2.362 0.938 1.400 2.012 3.110 2.540 2.271 3.314
31087ce 1.823 0.442 2.643 1.233 2.152 1.679 2.139 2.362 0.938 1.400 2.012 3.110 2.540 2.271 3.314

@forever043 forever043 changed the title WIP: feat(build): Support generating XiangShan in docker envrionment feat(build): Support generating XiangShan in docker envrionment May 7, 2025
Signed-off-by: Jiuyue Ma <majiuyue@bosc.ac.cn>
@Tang-Haojin Tang-Haojin requested a review from cebarobot May 8, 2025 05:23
@forever043 forever043 force-pushed the docker_env branch 2 times, most recently from 3b3c897 to 100b30a Compare May 8, 2025 05:31
forever043 added 2 commits May 8, 2025 14:03
…ncies

Signed-off-by: Jiuyue Ma <majiuyue@bosc.ac.cn>
Signed-off-by: Jiuyue Ma <majiuyue@bosc.ac.cn>
@forever043 forever043 force-pushed the docker_env branch 5 times, most recently from 75f38c3 to c8d4390 Compare May 8, 2025 09:05
forever043 added 5 commits May 8, 2025 17:09
Signed-off-by: Jiuyue Ma <majiuyue@bosc.ac.cn>
Signed-off-by: Jiuyue Ma <majiuyue@bosc.ac.cn>
Signed-off-by: Jiuyue Ma <majiuyue@bosc.ac.cn>
Signed-off-by: Jiuyue Ma <majiuyue@bosc.ac.cn>
Signed-off-by: Jiuyue Ma <majiuyue@bosc.ac.cn>
forever043 added 2 commits May 8, 2025 17:17
Signed-off-by: Jiuyue Ma <majiuyue@bosc.ac.cn>
Signed-off-by: Jiuyue Ma <majiuyue@bosc.ac.cn>
@XiangShanRobot
Copy link
Copy Markdown

[Generated by IPC robot]
commit: ac1862c

commit astar copy_and_run coremark gcc gromacs hmmer-Vector lbm linux mcf microbench milc namd povray wrf xalancbmk
ac1862c 1.821 0.442 2.643 1.241 2.152 1.679 2.139 2.362 0.938 1.400 2.012 3.110 2.540 2.271 3.314

master branch:

commit astar copy_and_run coremark gcc gromacs hmmer-Vector lbm linux mcf microbench milc namd povray wrf xalancbmk
f9d8efe 1.823 0.442 2.643 1.235 2.152 1.679 2.139 2.362 0.938 1.400 2.012 3.110 2.540 2.271 3.314
87aef66 1.821 0.442 2.643 1.234 2.152 1.679 2.139 2.362 0.938 1.400 2.012 3.110 2.540 2.271 3.314
7e564db 1.823 0.442 2.643 1.242 2.152 1.679 2.139 2.362 0.938 1.400 2.012 3.110 2.540 2.271 3.314
4a33e05 1.821 0.442 2.643 1.228 2.152 1.679 2.139 2.362 0.938 1.376 2.012 3.110 2.540 2.271 3.314
fdc4433 1.823 0.442 2.643 1.245 2.152 1.679 2.139 2.362 0.938 1.376 2.012 3.110 2.540 2.271 3.314
3f03196 1.823 0.442 2.643 1.228 2.152 1.679 2.139 2.362 0.938 1.376 2.012 3.110 2.540 2.271 3.314
6a3636f 1.823 0.442 2.643 1.223 2.152 1.679 2.139 2.362 0.938 1.400 2.012 3.110 2.540 2.271 3.314
acf3dcc 1.823 0.442 2.643 1.233 2.152 1.679 2.139 2.362 0.938 1.400 2.012 3.110 2.540 2.271 3.314
6172063 0.442 2.643 1.234 1.679 2.362 0.938 1.376 2.012 3.110 2.540 3.314
bd1e467 1.821 0.442 2.643 1.229 2.152 1.679 2.139 2.362 0.938 1.376 2.012 3.110 2.540 2.271 3.314

Copy link
Copy Markdown
Member

@cebarobot cebarobot left a comment

Choose a reason for hiding this comment

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

LGTM

@Tang-Haojin Tang-Haojin merged commit 06ff532 into master May 9, 2025
11 checks passed
@Tang-Haojin Tang-Haojin deleted the docker_env branch May 9, 2025 13:02
@ngc7331 ngc7331 added this to the kmh-v2r2 milestone Aug 25, 2025
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.

7 participants