11# TODO: check if qemu-user-static-binfmt is needed (perhaps to run some tests since it probably calls exec).
22
3- name : m68k CI
3+ name : Cross-compilation CI
44
55on :
66 push :
2222 strategy :
2323 fail-fast : false
2424 matrix :
25+ arch : [
26+ {
27+ gcc : " aarch64" ,
28+ qemu : " aarch64" ,
29+ triple : " aarch64-unknown-linux-gnu" ,
30+ vm : " arm64" ,
31+ },
32+ {
33+ gcc : " m68k" ,
34+ qemu : " m68k" ,
35+ triple : " m68k-unknown-linux-gnu" ,
36+ vm : " m68k" ,
37+ },
38+ ]
2539 commands : [
2640 " --std-tests" ,
2741 # TODO(antoyo): fix those on m68k.
@@ -50,14 +64,14 @@ jobs:
5064 sudo apt-get install qemu-system qemu-user-static
5165
5266 - name : Download artifact
53- run : curl -LO https://github.com/cross-cg-gcc-tools/cross-gcc/releases/latest/download/gcc-m68k -15.deb
67+ run : curl -LO https://github.com/cross-cg-gcc-tools/cross-gcc/releases/latest/download/gcc-${{ matrix.arch.gcc }} -15.deb
5468
5569 - name : Download VM artifact
56- run : curl -LO https://github.com/cross-cg-gcc-tools/vms/releases/latest/download/debian-m68k .img
70+ run : curl -LO https://github.com/cross-cg-gcc-tools/vms/releases/latest/download/debian-${{ matrix.arch.vm }} .img
5771
5872 - name : Setup path to libgccjit
5973 run : |
60- sudo dpkg --force-overwrite -i gcc-m68k -15.deb
74+ sudo dpkg --force-overwrite -i gcc-${{ matrix.arch.gcc }} -15.deb
6175 echo 'gcc-path = "/usr/lib/"' > config.toml
6276
6377 - name : Set env
@@ -76,22 +90,23 @@ jobs:
7690 - name : Prepare VM
7791 run : |
7892 mkdir vm
79- sudo mount debian-m68k .img vm
80- sudo cp $(which qemu-m68k -static) vm/usr/bin/
93+ sudo mount debian-${{ matrix.arch.vm }} .img vm
94+ sudo cp $(which qemu-${{ matrix.arch.qemu }} -static) vm/usr/bin/
8195
8296 - name : Build sample project with target defined as JSON spec
97+ if : matrix.arch.gcc == 'm68k'
8398 run : |
8499 ./y.sh prepare --only-libcore --cross
85- ./y.sh build --sysroot --target-triple m68k-unknown-linux-gnu --target ${{ github.workspace }}/target_specs/m68k-unknown-linux-gnu.json
100+ ./y.sh build --sysroot --target-triple ${{ matrix.arch.triple }} --target ${{ github.workspace }}/target_specs/m68k-unknown-linux-gnu.json
86101 CG_RUSTFLAGS="-Clinker=m68k-unknown-linux-gnu-gcc" ./y.sh cargo build --manifest-path=./tests/hello-world/Cargo.toml --target ${{ github.workspace }}/target_specs/m68k-unknown-linux-gnu.json
87102 ./y.sh clean all
88103
89104 - name : Build
90105 run : |
91106 ./y.sh prepare --only-libcore --cross
92- ./y.sh build --sysroot --target-triple m68k-unknown-linux-gnu
93- ./y.sh test --mini-tests --target-triple m68k-unknown-linux-gnu
94- CG_GCC_TEST_TARGET=m68k-unknown-linux-gnu . /y.sh test --cargo-tests --target-triple m68k-unknown-linux-gnu
107+ ./y.sh build --sysroot --target-triple ${{ matrix.arch.triple }}
108+ ./y.sh test --mini-tests --target-triple ${{ matrix.arch.triple }}
109+ CG_GCC_TEST_TARGET=${{ matrix.arch.triple }} . /y.sh test --cargo-tests --target-triple ${{ matrix.arch.triple }}
95110 ./y.sh clean all
96111
97112 - name : Prepare dependencies
@@ -102,23 +117,23 @@ jobs:
102117
103118 - name : Run tests
104119 run : |
105- ./y.sh test --target-triple m68k-unknown-linux-gnu --release --clean --build-sysroot ${{ matrix.commands }}
120+ ./y.sh test --target-triple ${{ matrix.arch.triple }} --release --clean --build-sysroot ${{ matrix.commands }}
106121
107122 - name : Run Hello World!
108123 run : |
109- ./y.sh build --target-triple m68k-unknown-linux-gnu
124+ ./y.sh build --target-triple ${{ matrix.arch.triple }}
110125
111126 vm_dir=$(pwd)/vm
112127 cd tests/hello-world
113- CG_RUSTFLAGS="-Clinker=m68k-unknown-linux-gnu- gcc" ../../y.sh cargo build --target m68k-unknown-linux-gnu
114- sudo cp target/m68k-unknown-linux-gnu /debug/hello_world $vm_dir/home/
115- sudo chroot $vm_dir qemu-m68k -static /home/hello_world > hello_world_stdout
128+ CG_RUSTFLAGS="-Clinker=${{ matrix.arch.triple }}- gcc" ../../y.sh cargo build --target ${{ matrix.arch.triple }}
129+ sudo cp target/${{ matrix.arch.triple }} /debug/hello_world $vm_dir/home/
130+ sudo chroot $vm_dir qemu-${{ matrix.arch.qemu }} -static /home/hello_world > hello_world_stdout
116131 expected_output="40"
117132 test $(cat hello_world_stdout) == $expected_output || (echo "Output differs. Actual output: $(cat hello_world_stdout)"; exit 1)
118133
119134 # Summary job for the merge queue.
120135 # ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB!
121- success_m68k :
136+ success_cross :
122137 needs : [build]
123138 # We need to ensure this job does *not* get skipped if its dependencies fail,
124139 # because a skipped job is considered a success by GitHub. So we have to
0 commit comments