Skip to content

Commit adabc2f

Browse files
committed
GHA: Integrate Alpine musl job in main workflow
Incl. prebuilt package etc.
1 parent 9de21fd commit adabc2f

File tree

6 files changed

+73
-98
lines changed

6 files changed

+73
-98
lines changed

.github/actions/3-build-native/action.yml

+4
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,7 @@ runs:
3131

3232
- run: ../build/bin/ldc2 --version
3333
shell: bash
34+
35+
- run: ldd ../build/bin/ldc2
36+
if: runner.os == 'Linux'
37+
shell: bash

.github/actions/4c-test-dmd/action.yml

+14-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,20 @@ runs:
99
- name: 'Posix: Run DMD testsuite'
1010
if: runner.os != 'Windows'
1111
shell: bash
12-
run: cd ../build && ctest -V -R "dmd-testsuite"
12+
run: |
13+
set -eux
14+
repoDir=$PWD
15+
cd ../build
16+
if type -P apk &>/dev/null; then
17+
# Alpine: run full dmd-testsuite-debug
18+
ctest -V -R 'dmd-testsuite' -E '^dmd-testsuite$'
19+
# these two tests require extra flags "-link-defaultlib-debug -frame-pointer=all": https://github.com/ldc-developers/ldc/issues/4694
20+
# => remove before running optimized dmd-testsuite separately
21+
rm $repoDir/tests/dmd/runnable/{test17559.d,test19086.d}
22+
ctest -V -R '^dmd-testsuite$'
23+
else
24+
ctest -V -R "dmd-testsuite"
25+
fi
1326
1427
- name: 'Windows: Run DMD testsuite'
1528
if: runner.os == 'Windows'

.github/actions/6-integration-test/action.yml

+8-2
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,16 @@ runs:
1515
run: |
1616
set -eux
1717
cd ..
18+
if type -P apk &>/dev/null; then
19+
exit 0 # Alpine: no shared libs
20+
fi
1821
if [[ '${{ runner.os }}' == Windows ]]; then
1922
# add druntime/Phobos DLL dir to PATH
2023
export PATH="$PWD/installed/bin:$PATH"
2124
fi
2225
installed/bin/ldc2 hello.d -link-defaultlib-shared
2326
./hello
24-
if [[ '${{ runner.os }}-${{ inputs.arch }}' == Linux-x86_64 ]]; then
27+
if [[ -d installed/lib32 ]]; then
2528
installed/bin/ldc2 hello.d -m32 -link-defaultlib-shared
2629
./hello
2730
fi
@@ -34,7 +37,7 @@ runs:
3437
for mode in thin full; do
3538
installed/bin/ldc2 hello.d -of=hello_$mode -flto=$mode -defaultlib=phobos2-ldc-lto,druntime-ldc-lto
3639
./hello_$mode
37-
if [[ '${{ runner.os }}-${{ inputs.arch }}' == Linux-x86_64 ]]; then
40+
if [[ -d installed/lib32 ]]; then
3841
installed/bin/ldc2 hello.d -m32 -of=hello_$mode-32 -flto=$mode -defaultlib=phobos2-ldc-lto,druntime-ldc-lto
3942
./hello_$mode-32
4043
fi
@@ -45,6 +48,9 @@ runs:
4548
run: |
4649
set -eux
4750
cd ..
51+
if type -P apk &>/dev/null; then
52+
exit 0 # FIXME: Alpine: LLVM too old for dynamic-compile support
53+
fi
4854
if [[ '${{ runner.os }}' == Windows ]]; then
4955
# add ldc-jit.dll dir to PATH
5056
export PATH="$PWD/installed/bin:$PATH"

.github/actions/7-package/action.yml

+10-7
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,12 @@ runs:
7373
"$(dirname "$DMD")/ldc2" -run list_payload.d .
7474
fi
7575
76-
# use host compiler's dub, which is guaranteed to be native
77-
DFLAGS="-O -linkonce-templates ${DFLAGS:-}" dub build -v \
78-
--build-mode=allAtOnce --combined $archFlag \
79-
--compiler="$(dirname "$DMD")/ldc2"
76+
# prefer host compiler's dub, which is guaranteed to be native
77+
PATH="$PATH:$PWD/../installed/bin" \
78+
DFLAGS="-O -linkonce-templates ${DFLAGS:-}" \
79+
dub build -v \
80+
--build-mode=allAtOnce --combined $archFlag \
81+
--compiler="$(dirname "$DMD")/ldc2"
8082
cp bin/reggae ../installed/bin/
8183
8284
if [[ '${{ inputs.cross_target_triple }}' == '' ]]; then
@@ -120,10 +122,11 @@ runs:
120122
chmod -R go=rX $artifactName
121123
if [[ '${{ runner.os }}' == macOS ]]; then
122124
sudo chown -R root:wheel $artifactName
123-
tar -cf - $artifactName | 7za a artifacts/$artifactName.tar.xz -si -txz -mx9
124-
else
125-
tar -cf - --owner=0 --group=0 $artifactName | 7za a artifacts/$artifactName.tar.xz -si -txz -mx9
125+
# note: already running as root in Alpine container, *and* potential busybox complication
126+
elif [[ $os != alpine ]]; then
127+
sudo chown -R 0:0 $artifactName
126128
fi
129+
tar -cf - $artifactName | 7za a artifacts/$artifactName.tar.xz -si -txz -mx9
127130
fi
128131
129132
# export ARTIFACT_{ID,NAME}

.github/workflows/alpine_musl.yml

-84
This file was deleted.

.github/workflows/main.yml

+37-4
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,23 @@ jobs:
5353
-DEXTRA_CXXFLAGS=-flto=full
5454
with_pgo: true
5555

56+
- job_name: Alpine musl x86_64
57+
os: ubuntu-latest
58+
container_image: alpine:3.20
59+
arch: x86_64
60+
bootstrap_cmake_flags: -DBUILD_LTO_LIBS=ON
61+
# TODO: Add '-DLLVM_IS_SHARED=OFF' when static linking is fully supported
62+
# TSan and XRay do not work.
63+
extra_cmake_flags: >-
64+
-DBUILD_LTO_LIBS=ON
65+
-DBUILD_SHARED_LIBS=OFF
66+
-DTEST_COMPILER_RT_LIBRARIES="profile;lsan;asan;msan;fuzzer"
67+
-DCMAKE_EXE_LINKER_FLAGS=-static-libstdc++
68+
-DJITRT_EXTRA_LDFLAGS=-static-libstdc++
69+
-DD_COMPILER_FLAGS="-O -flto=full"
70+
# FIXME: -defaultlib=phobos2-ldc-lto,druntime-ldc-lto
71+
with_pgo: false
72+
5673
- job_name: macOS x86_64
5774
os: macos-13
5875
arch: x86_64
@@ -108,18 +125,33 @@ jobs:
108125
env:
109126
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.arch == 'arm64' && '11.0' || '10.12' }}
110127
steps:
111-
- name: 'Container: Install git and sudo'
128+
- name: 'Set up Linux container'
112129
if: matrix.container_image
113-
shell: bash
114130
run: |
115131
set -eux
116-
apt-get -q update
117-
DEBIAN_FRONTEND=noninteractive apt-get -yq install git-core sudo
132+
if type -P apt-get &>/dev/null; then
133+
# Ubuntu: pre-install git and sudo
134+
apt-get -q update
135+
DEBIAN_FRONTEND=noninteractive apt-get -yq install git-core sudo
136+
else
137+
# set up Alpine container
138+
apk add \
139+
git cmake ninja-is-really-ninja g++ ldc llvm-dev llvm-static compiler-rt \
140+
libxml2-static zstd-static zlib-static \
141+
bash grep diffutils make curl 7zip perl
142+
# create missing 7za symlink
143+
ln -s 7z /usr/bin/7za
144+
# create ../llvm symlink to distro LLVM (no prebuilt LDC-LLVM for musl)
145+
ln -s /usr/lib/llvm17 $(dirname $(pwd))/llvm
146+
../llvm/bin/llvm-config --version
147+
fi
118148
- uses: actions/checkout@v4
119149
with:
120150
submodules: true
121151
fetch-depth: 50
122152
- name: Install prerequisites
153+
if: |
154+
!startsWith(matrix.container_image, 'alpine')
123155
uses: ./.github/actions/1-setup
124156
with:
125157
llvm_version: ${{ matrix.llvm_version || env.LLVM_VERSION }}
@@ -194,6 +226,7 @@ jobs:
194226
uses: ./.github/actions/7-package
195227
with:
196228
arch: ${{ matrix.arch }}
229+
os: ${{ startsWith(matrix.container_image, 'alpine') && 'alpine' || '' }}
197230

198231

199232
# Cross-compilation jobs for non-native targets.

0 commit comments

Comments
 (0)