commit:     2a853cee8ed7b3eaa1088ba9cdd93969eae77f39
Author:     Michal Rostecki <vadorovsky <AT> protonmail <DOT> com>
AuthorDate: Sun Sep 14 06:39:34 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Oct  8 02:21:22 2025 +0000
URL:        https://gitweb.gentoo.org/proj/crossdev.git/commit/?id=2a853cee

ci: Test building sysroots with LLVM

Add --llvm argument to the container_test.sh script. Use it on CI in
combination with the llvm stage3 image.

Signed-off-by: Michal Rostecki <vadorovsky <AT> protonmail.com>
Part-of: https://github.com/gentoo/crossdev/pull/24
Closes: https://github.com/gentoo/crossdev/pull/24
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .github/workflows/crossdev.yml | 122 +++++++++++++++++++++++++++++++++++++++--
 scripts/container_test.sh      |  13 ++++-
 2 files changed, 129 insertions(+), 6 deletions(-)

diff --git a/.github/workflows/crossdev.yml b/.github/workflows/crossdev.yml
index f9f11ba..8f45031 100644
--- a/.github/workflows/crossdev.yml
+++ b/.github/workflows/crossdev.yml
@@ -22,63 +22,147 @@ jobs:
         # requests fixing them welcome!
         target:
           - target: aarch64-unknown-linux-gnu
+            gcc: true
+            llvm: false
           - target: aarch64-unknown-linux-musl
+            gcc: true
+            llvm: true
           - target: aarch64_be-unknown-linux-gnu
+            gcc: true
+            llvm: false
           - target: alpha-unknown-linux-gnu
+            gcc: true
+            llvm: false
           - target: arm-unknown-linux-gnueabi
+            gcc: true
+            llvm: false
           - target: arm-unknown-linux-gnueabihf
+            gcc: true
+            llvm: false
           - target: arm-unknown-linux-musleabi
+            gcc: true
+            llvm: false
           - target: arm-unknown-linux-musleabihf
+            gcc: true
+            llvm: false
           - target: armeb-unknown-linux-gnueabi
+            gcc: true
+            llvm: false
           - target: armeb-unknown-linux-gnueabihf
+            gcc: true
+            llvm: false
           - target: armeb-unknown-linux-musleabi
+            gcc: true
+            llvm: false
           - target: armeb-unknown-linux-musleabihf
+            gcc: true
+            llvm: false
           - target: armv7-unknown-linux-musleabi
+            gcc: true
+            llvm: false
           - target: armv7-unknown-linux-musleabihf
+            gcc: true
+            llvm: false
           - target: armv6j-softfp-linux-gnueabi
+            gcc: true
+            llvm: false
           - target: armv6j-unknown-linux-gnueabihf
+            gcc: true
+            llvm: false
           - target: armv7a-softfp-linux-gnueabi
+            gcc: true
+            llvm: false
           - target: armv7a-unknown-linux-gnueabihf
+            gcc: true
+            llvm: false
           - target: hppa1.1-unknown-linux-gnu
+            gcc: true
+            llvm: false
           - target: hppa2.0-unknown-linux-gnu
+            gcc: true
+            llvm: false
           - target: hppa64-unknown-linux-gnu
             args: --skip-system
+            gcc: true
+            llvm: false
           - target: loongarch64-unknown-linux-gnu
+            gcc: true
+            llvm: false
           # musl ebuilds don't support loong. The target is supported upstream,
           # we need to fix and test our ebuilds.
           #- target: loongarch64-unknown-linux-musl
           - target: m68k-unknown-linux-gnu
+            gcc: true
+            llvm: false
           - target: mips-unknown-linux-gnu
+            gcc: true
+            llvm: false
           - target: mips-unknown-linux-musl
+            gcc: true
+            llvm: false
           - target: mipsel-unknown-linux-gnu
+            gcc: true
+            llvm: false
           - target: mipsel-unknown-linux-musl
+            gcc: true
+            llvm: false
           - target: mips64-unknown-linux-gnu
+            gcc: true
+            llvm: false
           # libgcc_s.so fails to build: `cannot find crti.o: No such file or
           # directory`.
           # - target: mips64-unknown-linux-musl
           - target: mips64el-unknown-linux-gnu
+            gcc: true
+            llvm: false
           # libgcc_s.so fails to build: `cannot find crti.o: No such file or
           # directory`.
           # - target: mips64el-unknown-linux-musl
           - target: or1k-unknown-linux-gnu
             args: --skip-system
+            gcc: true
+            llvm: false
           - target: or1k-unknown-linux-musl
             args: --skip-system
+            gcc: true
+            llvm: false
           - target: powerpc-unknown-linux-gnu
+            gcc: true
+            llvm: false
           - target: powerpc-unknown-linux-musl
+            gcc: true
+            llvm: false
           - target: powerpc64-unknown-linux-gnu
+            gcc: true
+            llvm: false
           - target: powerpc64-unknown-linux-musl
+            gcc: true
+            llvm: false
           - target: powerpc64le-unknown-linux-gnu
+            gcc: true
+            llvm: false
           - target: riscv32-unknown-linux-gnu
+            gcc: true
+            llvm: false
           # busybox fails to build: `‘SYS_settimeofday’ undeclared`.
           # - target: riscv32-unknown-linux-musl
           - target: riscv64-unknown-linux-gnu
+            gcc: true
+            llvm: false
           - target: riscv64-unknown-linux-musl
+            gcc: true
+            llvm: true
           # glibc fails to build: `no support for pre-v8 sparc`.
           # - target: sparc-unknown-linux-gnu
           - target: sparc64-unknown-linux-gnu
+            gcc: true
+            llvm: false
           - target: s390-ibm-linux-gnu
+            gcc: true
+            llvm: false
           - target: s390x-ibm-linux-gnu
+            gcc: true
+            llvm: false
           # musl ebuilds don't support s390x. The target is supported upstream,
           # we need to fix and test our ebuilds.
           # - target: s390x-unknown-linux-musl
@@ -93,30 +177,58 @@ jobs:
           # - target: sh4eb-unknown-linux-gnu
           # - target: sh4eb-unknown-linux-musl
           - target: x86_64-unknown-linux-gnu
+            gcc: true
+            llvm: false
           - target: x86_64-unknown-linux-musl
+            gcc: true
+            llvm: true
           # Embedded or otherwise special targets
           - target: arm-none-eabi
             args: --skip-system
+            gcc: true
+            llvm: false
           - target: avr
             args: --skip-system
+            gcc: true
+            llvm: false
           - target: nvptx-none
             args: --skip-system
+            gcc: true
+            llvm: false
           - target: bpf-unknown-none
             args: --skip-system
+            gcc: true
+            llvm: false
         stage3:
-          - latest # `openrc` (glibc+GCC) is tagged as `latest`
-          - musl
+          - latest # glibc+GCC
+          - llvm # glibc+LLVM and GCC as a fallback
+          - musl # musl+GCC
       fail-fast: false
     name: crossdev target=${{ matrix.target.target }} stage3=${{ matrix.stage3 
}}
+    env:
+      CONTAINER_ENGINE: docker
     runs-on: ubuntu-latest
     steps:
       - uses: actions/checkout@v4
 
-      - name: Create cross environment
-        env:
-          CONTAINER_ENGINE: docker
+      - name: Create cross environment with GCC
+        # Building GCC-based sysroots on llvm stage3 should be possible, since
+        # it contains a fallback GCC toolchain. But in practice, it fails for
+        # certain architectures. Pull requests welcome!
+        if: ${{ matrix.target.gcc && !contains(matrix.stage3, 'llvm') }}
         run: |
           ./scripts/container_test.sh \
             --tag ${{ matrix.stage3 }} \
             --target ${{ matrix.target.target }} \
             ${{ matrix.target.args }}
+
+      - name: Create cross environment with LLVM
+        # * We need LLVM toolchain to be present in the stage3.
+        # * Building sysroots with glibc and LLVM is not yet supported.
+        if: ${{ matrix.target.llvm && contains(matrix.stage3, 'llvm') }}
+        run: |
+          ./scripts/container_test.sh \
+            --llvm \
+            --tag ${{ matrix.stage3 }} \
+            --target ${{ matrix.target.target }} \
+            ${{ matrix.target.args }}

diff --git a/scripts/container_test.sh b/scripts/container_test.sh
index d30be3b..85311bf 100755
--- a/scripts/container_test.sh
+++ b/scripts/container_test.sh
@@ -6,6 +6,7 @@ print_help() {
        echo "Usage: $0 [OPTIONS]
 
 Options:
+  --llvm                Use LLVM/Clang as a cross compiler
   --skip-system         Skip emerging the @system set after setting up 
crossdev.
   --tag <tag>           Specify the container tag to use. Default is 'latest'.
   --target <target>     Specify the target architecture for crossdev. Required.
@@ -54,6 +55,7 @@ CONTAINER_NAME=${CONTAINER_NAME:-"crossdev"}
 CONTAINER_URI=${CONTAINER_URI:-"docker.io/gentoo/stage3"}
 CONTAINER_TAG="latest"
 EMERGE_SYSTEM=1
+USE_LLVM=0
 TOPDIR=$(git rev-parse --show-toplevel)
 
 remove_container || true
@@ -65,6 +67,10 @@ while [[ $# -gt 0 ]]; do
                        print_help
                        exit 0
                        ;;
+               --llvm)
+                       USE_LLVM=1
+                       shift 1
+                       ;;
                --skip-system)
                        EMERGE_SYSTEM=0
                        shift 1
@@ -85,6 +91,11 @@ while [[ $# -gt 0 ]]; do
        esac
 done
 
+EXTRA_ARGS=()
+if [[ "${USE_LLVM}" -eq 1 ]]; then
+       EXTRA_ARGS+="--llvm"
+fi
+
 "${CONTAINER_ENGINE}" run -d \
        --pull always \
        --name "${CONTAINER_NAME}" \
@@ -98,7 +109,7 @@ run_in_container getuto
 run_in_container emerge --getbinpkg app-eselect/eselect-repository 
sys-apps/config-site
 run_in_container make install
 run_in_container eselect repository create crossdev
-run_in_container crossdev --show-fail-log --target "${TARGET}"
+run_in_container crossdev --show-fail-log "${EXTRA_ARGS[@]}" --target 
"${TARGET}"
 if [[ "${EMERGE_SYSTEM}" -eq 1 ]]; then
        run_in_container "${TARGET}-emerge" @system
 fi

Reply via email to