Skip to content

Commit 9de21fd

Browse files
authored
Merge pull request #4825 from kinke/gha_simplify_clang_install
GHA main: Simplify clang installation via apt.llvm.org repo
2 parents 3e2155a + 0bf70fd commit 9de21fd

File tree

2 files changed

+25
-43
lines changed

2 files changed

+25
-43
lines changed

.github/actions/1-setup/action.yml

+21-33
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
name: Install prerequisites
22
inputs:
3-
clang_version:
4-
required: true
53
llvm_version:
64
required: true
75
arch:
@@ -22,6 +20,7 @@ runs:
2220
sudo dpkg --add-architecture i386
2321
fi
2422
sudo apt-get -q update
23+
2524
packages=( \
2625
git-core cmake g++ \
2726
libcurl4 libxml2-dev libzstd-dev \
@@ -30,43 +29,44 @@ runs:
3029
if [[ $arch == x86_64 ]]; then
3130
packages+=(g++-multilib libcurl4:i386)
3231
fi
32+
# extra prerequisites of apt.llvm.org install script
33+
packages+=(lsb-release wget software-properties-common gnupg)
34+
3335
sudo -E apt-get -yq install ${packages[@]}
36+
3437
# Make sure to link libzstd statically
3538
sudo rm /usr/lib/$arch-linux-gnu/libzstd.so
39+
3640
# Install a more recent CMake version in the AArch64 container (for mimalloc...)
3741
if [[ $arch == aarch64 ]]; then
38-
curl -fL --retry 3 --max-time 300 -o cmake.tar.gz https://github.com/Kitware/CMake/releases/download/v3.31.4/cmake-3.31.4-linux-$arch.tar.gz
42+
curl -fL --retry 3 --max-time 300 -o cmake.tar.gz \
43+
https://github.com/Kitware/CMake/releases/download/v3.31.4/cmake-3.31.4-linux-$arch.tar.gz
3944
mkdir cmake
4045
tar -xf cmake.tar.gz --strip 1 -C cmake
4146
rm cmake.tar.gz
4247
sudo ln -sf $PWD/cmake/bin/cmake /usr/bin/cmake
4348
fi
4449
45-
- name: 'Linux: Download & extract clang' # into ../clang
50+
- name: 'Linux: Install clang 19 from apt.llvm.org'
4651
if: runner.os == 'Linux'
4752
shell: bash
4853
run: |
4954
set -eux
5055
cd ..
51-
arch='${{ inputs.arch }}'
52-
extraSuffix=''
53-
if [[ $arch == x86_64 ]]; then
54-
extraSuffix='-ubuntu-18.04'
55-
fi
56-
curl -fL --retry 3 --max-time 300 -o clang.tar.xz \
57-
https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ inputs.clang_version }}/clang+llvm-${{ inputs.clang_version }}-$arch-linux-gnu$extraSuffix.tar.xz
58-
mkdir clang
59-
tar -xf clang.tar.xz --strip 1 -C clang
60-
rm clang.tar.xz
61-
clang/bin/clang --version
62-
- name: 'Windows: Install clang'
56+
curl -fL --retry 3 --max-time 30 -O https://apt.llvm.org/llvm.sh
57+
sudo bash llvm.sh 19
58+
for tool in clang clang++ ld.lld; do
59+
sudo ln -sf $tool-19 /usr/bin/$tool
60+
$tool --version
61+
done
62+
- name: 'Windows: Install clang v19.1.3 from GitHub'
6363
if: runner.os == 'Windows'
6464
shell: bash
6565
run: |
6666
set -eux
6767
cd ..
6868
curl -fL --retry 3 --max-time 300 -o clang.exe \
69-
https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ inputs.clang_version }}/LLVM-${{ inputs.clang_version }}-win64.exe
69+
https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.3/LLVM-19.1.3-win64.exe
7070
./clang.exe //S # double-slash for bash
7171
rm clang.exe
7272
# C:\Program Files\LLVM\bin should already be in PATH
@@ -117,28 +117,16 @@ runs:
117117
118118
llvm/bin/llvm-config --version
119119
120-
- name: 'Linux: Make lld the default linker'
120+
- name: 'Linux: Make lld (from apt.llvm.org) the default linker'
121121
if: runner.os == 'Linux'
122122
shell: bash
123123
run: |
124124
set -eux
125-
sudo ln -sf "$(dirname "$PWD")/llvm/bin/ld.lld" /usr/bin/ld
125+
sudo ln -sf ld.lld /usr/bin/ld
126126
ld --version
127127
128-
- name: Install ninja
129-
if: inputs.arch != 'aarch64'
130-
uses: symmetryinvestments/gha-setup-ninja@v2
131-
- name: Install ninja (Linux AArch64)
132-
if: inputs.arch == 'aarch64'
133-
shell: bash
134-
run: |
135-
set -eux
136-
cd ..
137-
curl -fL --retry 3 --max-time 60 -O https://github.com/ninja-build/ninja/releases/download/v1.12.1/ninja-linux-aarch64.zip
138-
mkdir ninja
139-
unzip ninja-linux-aarch64.zip -d ninja
140-
rm ninja-linux-aarch64.zip
141-
sudo ln -sf $PWD/ninja/ninja /usr/bin/ninja
128+
- name: Install ninja v1.12.1
129+
uses: Ahajha/gha-setup-ninja@69595b0cf872acdad8ce599142fbdc88724b9a2b
142130

143131
- name: Install D host compiler
144132
uses: dlang-community/setup-dlang@v1

.github/workflows/main.yml

+4-10
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ concurrency:
1010
cancel-in-progress: true
1111

1212
env:
13-
CLANG_VERSION: 15.0.6
1413
LLVM_VERSION: 19.1.7
1514

1615
jobs:
@@ -28,8 +27,8 @@ jobs:
2827
extra_cmake_flags: >-
2928
-DMULTILIB=ON
3029
-DBUILD_LTO_LIBS=ON
31-
-DCMAKE_C_COMPILER=/home/runner/work/ldc/clang/bin/clang
32-
-DCMAKE_CXX_COMPILER=/home/runner/work/ldc/clang/bin/clang++
30+
-DCMAKE_C_COMPILER=clang
31+
-DCMAKE_CXX_COMPILER=clang++
3332
-DCMAKE_EXE_LINKER_FLAGS=-static-libstdc++
3433
-DJITRT_EXTRA_LDFLAGS=-static-libstdc++
3534
-DD_COMPILER_FLAGS="-O -flto=full -defaultlib=phobos2-ldc-lto,druntime-ldc-lto"
@@ -40,15 +39,14 @@ jobs:
4039
os: ubuntu-22.04-arm # Ubuntu 20 not natively supported
4140
container_image: ubuntu:20.04
4241
arch: aarch64
43-
clang_version: 15.0.3 # 15.0.6 requires a more recent libstdc++.so.6 than shipped with Ubuntu 20
4442
bootstrap_cmake_flags: >-
4543
-DBUILD_LTO_LIBS=ON
4644
-DCOMPILER_RT_LIBDIR_OS=aarch64-unknown-linux-gnu
4745
extra_cmake_flags: >-
4846
-DBUILD_LTO_LIBS=ON
4947
-DCOMPILER_RT_LIBDIR_OS=aarch64-unknown-linux-gnu
50-
-DCMAKE_C_COMPILER=/__w/ldc/clang/bin/clang
51-
-DCMAKE_CXX_COMPILER=/__w/ldc/clang/bin/clang++
48+
-DCMAKE_C_COMPILER=clang
49+
-DCMAKE_CXX_COMPILER=clang++
5250
-DCMAKE_EXE_LINKER_FLAGS=-static-libstdc++
5351
-DJITRT_EXTRA_LDFLAGS=-static-libstdc++
5452
-DD_COMPILER_FLAGS="-O -flto=full -defaultlib=phobos2-ldc-lto,druntime-ldc-lto"
@@ -83,7 +81,6 @@ jobs:
8381
- job_name: Windows x64
8482
os: windows-2022
8583
arch: x64
86-
clang_version: 19.1.3
8784
bootstrap_cmake_flags: -DBUILD_LTO_LIBS=ON
8885
extra_cmake_flags: >-
8986
-DBUILD_LTO_LIBS=ON
@@ -94,7 +91,6 @@ jobs:
9491
- job_name: Windows x86
9592
os: windows-2022
9693
arch: x86
97-
clang_version: 19.1.3
9894
bootstrap_cmake_flags: -DBUILD_LTO_LIBS=ON
9995
# `RT_CFLAGS=-m32` needed to make 64-bit clang-cl output 32-bit code for druntime integration tests
10096
extra_cmake_flags: >-
@@ -126,7 +122,6 @@ jobs:
126122
- name: Install prerequisites
127123
uses: ./.github/actions/1-setup
128124
with:
129-
clang_version: ${{ matrix.clang_version || env.CLANG_VERSION }}
130125
llvm_version: ${{ matrix.llvm_version || env.LLVM_VERSION }}
131126
arch: ${{ matrix.arch }}
132127
- name: Build bootstrap LDC
@@ -235,7 +230,6 @@ jobs:
235230
- name: Install prerequisites
236231
uses: ./.github/actions/1-setup
237232
with:
238-
clang_version: ${{ env.CLANG_VERSION }}
239233
llvm_version: ${{ env.LLVM_VERSION }}
240234
arch: x86_64
241235
- name: Build bootstrap LDC

0 commit comments

Comments
 (0)