diff --git a/.github/workflows/m68k.yml b/.github/workflows/cross.yml similarity index 70% rename from .github/workflows/m68k.yml rename to .github/workflows/cross.yml index 4b67360df9d..07986cb101c 100644 --- a/.github/workflows/m68k.yml +++ b/.github/workflows/cross.yml @@ -1,6 +1,6 @@ # TODO: check if qemu-user-static-binfmt is needed (perhaps to run some tests since it probably calls exec). -name: m68k CI +name: Cross-compilation CI on: push: @@ -22,6 +22,20 @@ jobs: strategy: fail-fast: false matrix: + arch: [ + { + gcc: "aarch64", + qemu: "aarch64", + triple: "aarch64-unknown-linux-gnu", + vm: "arm64", + }, + { + gcc: "m68k", + qemu: "m68k", + triple: "m68k-unknown-linux-gnu", + vm: "m68k", + }, + ] commands: [ "--std-tests", # TODO(antoyo): fix those on m68k. @@ -50,14 +64,14 @@ jobs: sudo apt-get install qemu-system qemu-user-static - name: Download artifact - run: curl -LO https://github.com/cross-cg-gcc-tools/cross-gcc/releases/latest/download/gcc-m68k-15.deb + run: curl -LO https://github.com/cross-cg-gcc-tools/cross-gcc/releases/latest/download/gcc-${{ matrix.arch.gcc }}-15.deb - name: Download VM artifact - run: curl -LO https://github.com/cross-cg-gcc-tools/vms/releases/latest/download/debian-m68k.img + run: curl -LO https://github.com/cross-cg-gcc-tools/vms/releases/latest/download/debian-${{ matrix.arch.vm }}.img - name: Setup path to libgccjit run: | - sudo dpkg --force-overwrite -i gcc-m68k-15.deb + sudo dpkg --force-overwrite -i gcc-${{ matrix.arch.gcc }}-15.deb echo 'gcc-path = "/usr/lib/"' > config.toml - name: Set env @@ -76,22 +90,23 @@ jobs: - name: Prepare VM run: | mkdir vm - sudo mount debian-m68k.img vm - sudo cp $(which qemu-m68k-static) vm/usr/bin/ + sudo mount debian-${{ matrix.arch.vm }}.img vm + sudo cp $(which qemu-${{ matrix.arch.qemu }}-static) vm/usr/bin/ - name: Build sample project with target defined as JSON spec + if: matrix.arch.gcc == 'm68k' run: | ./y.sh prepare --only-libcore --cross - ./y.sh build --sysroot --features compiler_builtins/no-f16-f128 --target-triple m68k-unknown-linux-gnu --target ${{ github.workspace }}/target_specs/m68k-unknown-linux-gnu.json + ./y.sh build --sysroot --features compiler_builtins/no-f16-f128 --target-triple ${{ matrix.arch.triple }} --target ${{ github.workspace }}/target_specs/m68k-unknown-linux-gnu.json 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 ./y.sh clean all - name: Build run: | ./y.sh prepare --only-libcore --cross - ./y.sh build --sysroot --features compiler_builtins/no-f16-f128 --target-triple m68k-unknown-linux-gnu - ./y.sh test --mini-tests --target-triple m68k-unknown-linux-gnu - CG_GCC_TEST_TARGET=m68k-unknown-linux-gnu ./y.sh test --cargo-tests --target-triple m68k-unknown-linux-gnu + ./y.sh build --sysroot --features compiler_builtins/no-f16-f128 --target-triple ${{ matrix.arch.triple }} + ./y.sh test --mini-tests --target-triple ${{ matrix.arch.triple }} + CG_GCC_TEST_TARGET=${{ matrix.arch.triple }} ./y.sh test --cargo-tests --target-triple ${{ matrix.arch.triple }} ./y.sh clean all - name: Prepare dependencies @@ -102,17 +117,17 @@ jobs: - name: Run tests run: | - ./y.sh test --target-triple m68k-unknown-linux-gnu --release --clean --build-sysroot --sysroot-features compiler_builtins/no-f16-f128 ${{ matrix.commands }} + ./y.sh test --target-triple ${{ matrix.arch.triple }} --release --clean --build-sysroot --sysroot-features compiler_builtins/no-f16-f128 ${{ matrix.commands }} - name: Run Hello World! run: | - ./y.sh build --target-triple m68k-unknown-linux-gnu + ./y.sh build --target-triple ${{ matrix.arch.triple }} vm_dir=$(pwd)/vm cd tests/hello-world - CG_RUSTFLAGS="-Clinker=m68k-unknown-linux-gnu-gcc" ../../y.sh cargo build --target m68k-unknown-linux-gnu - sudo cp target/m68k-unknown-linux-gnu/debug/hello_world $vm_dir/home/ - sudo chroot $vm_dir qemu-m68k-static /home/hello_world > hello_world_stdout + CG_RUSTFLAGS="-Clinker=${{ matrix.arch.triple }}-gcc" ../../y.sh cargo build --target ${{ matrix.arch.triple }} + sudo cp target/${{ matrix.arch.triple }}/debug/hello_world $vm_dir/home/ + sudo chroot $vm_dir qemu-${{ matrix.arch.qemu }}-static /home/hello_world > hello_world_stdout expected_output="40" test $(cat hello_world_stdout) == $expected_output || (echo "Output differs. Actual output: $(cat hello_world_stdout)"; exit 1)