Skip to content

Commit d3aad2c

Browse files
committed
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@protonmail.com>
1 parent 9462f67 commit d3aad2c

2 files changed

Lines changed: 34 additions & 6 deletions

File tree

.github/workflows/crossdev.yml

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,19 +100,36 @@ jobs:
100100
- target: bpf-unknown-none
101101
args: --skip-system
102102
stage3:
103-
- latest # `openrc` (glibc+GCC) is tagged as `latest`
104-
- musl
103+
- latest # glibc+GCC
104+
- llvm # glibc+LLVM and GCC as a fallback
105+
- musl # musl+GCC
105106
fail-fast: false
106107
name: crossdev target=${{ matrix.target.target }} stage3=${{ matrix.stage3 }}
108+
env:
109+
CONTAINER_ENGINE: docker
107110
runs-on: ubuntu-latest
108111
steps:
109112
- uses: actions/checkout@v4
110113

111-
- name: Create cross environment
112-
env:
113-
CONTAINER_ENGINE: docker
114+
- name: Create cross environment with GCC
115+
# Building GCC-based sysroots on llvm stage3 should be possible, since
116+
# it contains a fallback GCC toolchain. But in practice, it fails for
117+
# certain architectures. Pull requests welcome!
118+
if: ${{ !contains(matrix.stage3, 'llvm') }}
114119
run: |
115120
./scripts/container_test.sh \
116121
--tag ${{ matrix.stage3 }} \
117122
--target ${{ matrix.target.target }} \
118123
${{ matrix.target.args }}
124+
125+
- name: Create cross environment with LLVM
126+
# * We need LLVM toolchain to be present in the stage3.
127+
# * Building sysroots with glibc and LLVM is not yet supported.
128+
# * musleabi targets don't work - pull requests welcome!
129+
if: ${{ contains(matrix.stage3, 'llvm') && endsWith(matrix.target.target, 'musl') }}
130+
run: |
131+
./scripts/container_test.sh \
132+
--llvm \
133+
--tag ${{ matrix.stage3 }} \
134+
--target ${{ matrix.target.target }} \
135+
${{ matrix.target.args }}

scripts/container_test.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ print_help() {
66
echo "Usage: $0 [OPTIONS]
77
88
Options:
9+
--llvm Use LLVM/Clang as a cross compiler
910
--skip-system Skip emerging the @system set after setting up crossdev.
1011
--tag <tag> Specify the container tag to use. Default is 'latest'.
1112
--target <target> Specify the target architecture for crossdev. Required.
@@ -54,6 +55,7 @@ CONTAINER_NAME=${CONTAINER_NAME:-"crossdev"}
5455
CONTAINER_URI=${CONTAINER_URI:-"docker.io/gentoo/stage3"}
5556
CONTAINER_TAG="latest"
5657
EMERGE_SYSTEM=1
58+
USE_LLVM=0
5759
TOPDIR=$(git rev-parse --show-toplevel)
5860

5961
remove_container || true
@@ -65,6 +67,10 @@ while [[ $# -gt 0 ]]; do
6567
print_help
6668
exit 0
6769
;;
70+
--llvm)
71+
USE_LLVM=1
72+
shift 1
73+
;;
6874
--skip-system)
6975
EMERGE_SYSTEM=0
7076
shift 1
@@ -85,6 +91,11 @@ while [[ $# -gt 0 ]]; do
8591
esac
8692
done
8793

94+
EXTRA_ARGS=()
95+
if [[ "${USE_LLVM}" -eq 1 ]]; then
96+
EXTRA_ARGS+="--llvm"
97+
fi
98+
8899
"${CONTAINER_ENGINE}" run -d \
89100
--name "${CONTAINER_NAME}" \
90101
-v "${TOPDIR}:/workspace" \
@@ -97,7 +108,7 @@ run_in_container getuto
97108
run_in_container emerge --getbinpkg app-eselect/eselect-repository sys-apps/config-site
98109
run_in_container make install
99110
run_in_container eselect repository create crossdev
100-
run_in_container crossdev --show-fail-log --target "${TARGET}"
111+
run_in_container crossdev --show-fail-log "${EXTRA_ARGS[@]}" --target "${TARGET}"
101112
if [[ "${EMERGE_SYSTEM}" -eq 1 ]]; then
102113
run_in_container "${TARGET}-emerge" @system
103114
fi

0 commit comments

Comments
 (0)