Skip to content

Commit 4a2a6aa

Browse files
authored
build: update llvm checksum and refactor ci (#304)
1 parent 3c53d3b commit 4a2a6aa

File tree

9 files changed

+211
-436
lines changed

9 files changed

+211
-436
lines changed

.github/workflows/cmake.yml

Lines changed: 39 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ on:
99
- "src/**"
1010
- "tests/**"
1111
- "CMakeLists.txt"
12-
1312
pull_request:
1413
branches: [main]
1514
paths:
@@ -23,80 +22,84 @@ on:
2322
jobs:
2423
build:
2524
strategy:
25+
fail-fast: false
2626
matrix:
27-
os: [ubuntu-24.04, windows-2025, macos-15]
27+
include:
28+
- os: windows-2025
29+
build_type: RelWithDebInfo
30+
cc: clang
31+
cxx: clang++
32+
- os: ubuntu-24.04
33+
build_type: Debug
34+
cc: clang-20
35+
cxx: clang++-20
36+
- os: macos-15
37+
build_type: Debug
38+
cc: clang
39+
cxx: clang++
2840

2941
runs-on: ${{ matrix.os }}
3042

3143
steps:
32-
- name: Setup ninja
33-
if: matrix.os == 'windows-2025'
44+
- name: Setup dependencies (Windows)
45+
if: runner.os == 'Windows'
3446
uses: MinoruSekine/setup-scoop@v4.0.1
3547
with:
3648
buckets: main
3749
apps: ninja
3850

39-
- name: Setup llvm & libstdc++ & cmake & ninja
40-
if: matrix.os == 'ubuntu-24.04'
51+
- name: Setup dependencies (Linux)
52+
if: runner.os == 'Linux'
4153
run: |
4254
sudo apt update
4355
sudo apt install -y gcc-14 g++-14 libstdc++-14-dev
44-
4556
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 100
4657
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14 100
47-
4858
sudo update-alternatives --set gcc /usr/bin/gcc-14
4959
sudo update-alternatives --set g++ /usr/bin/g++-14
50-
5160
wget https://apt.llvm.org/llvm.sh
5261
chmod +x llvm.sh
5362
sudo ./llvm.sh 20 all
54-
5563
sudo apt install -y cmake ninja-build
5664
57-
- name: Setup llvm@20 and lld
58-
if: matrix.os == 'macos-15'
65+
- name: Setup dependencies (MacOS)
66+
if: runner.os == 'macOS'
5967
run: |
6068
brew install llvm@20 lld@20
6169
6270
- name: Checkout repository
6371
uses: actions/checkout@v4
6472

6573
- name: Setup msvc sysroot for cmake
66-
if: matrix.os == 'windows-2025'
74+
if: runner.os == 'Windows'
6775
uses: ilammy/msvc-dev-cmd@v1
6876

69-
- name: Build clice (release, windows)
70-
if: matrix.os == 'windows-2025'
77+
- name: Build clice
78+
shell: bash
7179
run: |
72-
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCLICE_ENABLE_TEST=ON -DCLICE_CI_ENVIRONMENT=ON
73-
cmake --build build
80+
if [[ "${{ runner.os }}" == "macOS" ]]; then
81+
export PATH="/opt/homebrew/opt/llvm@20/bin:/opt/homebrew/opt/lld@20/bin:$PATH"
82+
fi
7483
75-
- name: Build clice (debug, linux)
76-
if: matrix.os == 'ubuntu-24.04'
77-
run: |
78-
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang-20 -DCMAKE_CXX_COMPILER=clang++-20 -DCLICE_ENABLE_TEST=ON -DCLICE_CI_ENVIRONMENT=ON
79-
cmake --build build
84+
cmake -B build -G Ninja \
85+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
86+
-DCMAKE_C_COMPILER=${{ matrix.cc }} \
87+
-DCMAKE_CXX_COMPILER=${{ matrix.cxx }} \
88+
-DCLICE_ENABLE_TEST=ON \
89+
-DCLICE_CI_ENVIRONMENT=ON
8090
81-
- name: Build clice (debug, macos)
82-
if: matrix.os == 'macos-15'
83-
run: |
84-
export PATH="/opt/homebrew/opt/llvm@20/bin:/opt/homebrew/opt/lld@20/bin:$PATH"
85-
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCLICE_ENABLE_TEST=ON -DCLICE_CI_ENVIRONMENT=ON
8691
cmake --build build
8792
8893
- name: Install uv for integration tests
8994
uses: astral-sh/setup-uv@v6
9095

9196
- name: Run tests
92-
if: matrix.os == 'windows-2025'
93-
run: |
94-
./build/bin/unit_tests.exe --test-dir="./tests/data"
95-
uv run pytest -s --log-cli-level=INFO tests/integration --executable=./build/bin/clice.exe
9697
shell: bash
97-
98-
- name: Run tests
99-
if: matrix.os == 'ubuntu-24.04' || matrix.os == 'macos-15'
10098
run: |
101-
./build/bin/unit_tests --test-dir="./tests/data"
102-
uv run pytest -s --log-cli-level=INFO tests/integration --executable=./build/bin/clice
99+
EXE_EXT=""
100+
if [[ "${{ runner.os }}" == "Windows" ]]; then
101+
EXE_EXT=".exe"
102+
fi
103+
104+
./build/bin/unit_tests${EXE_EXT} --test-dir="./tests/data"
105+
uv run pytest -s --log-cli-level=INFO tests/integration --executable=./build/bin/clice${EXE_EXT}

.github/workflows/xmake.yml

Lines changed: 31 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ on:
99
- "src/**"
1010
- "tests/**"
1111
- "xmake.lua"
12-
1312
pull_request:
1413
branches: [main]
1514
paths:
@@ -21,114 +20,41 @@ on:
2120
- "xmake.lua"
2221

2322
jobs:
24-
windows:
23+
build:
2524
strategy:
25+
fail-fast: false
2626
matrix:
27-
os: [windows-2025]
27+
os: [windows-2025, ubuntu-24.04, macos-15]
28+
build_type: [debug, releasedbg]
29+
exclude:
30+
- os: windows-2025
31+
build_type: debug
2832

2933
runs-on: ${{ matrix.os }}
3034

3135
steps:
32-
- name: Checkout repository
33-
uses: actions/checkout@v4
34-
35-
- name: Setup xmake
36-
uses: xmake-io/github-action-setup-xmake@v1
37-
with:
38-
xmake-version: 3.0.4
39-
actions-cache-folder: ".xmake-cache"
40-
actions-cache-key: ${{ matrix.os }}
41-
package-cache: true
42-
package-cache-key: ${{ matrix.os }}
43-
build-cache: true
44-
build-cache-key: ${{ matrix.os }}-${{ matrix.build_type }}
45-
46-
- name: Xmake configure
47-
run: |
48-
xmake config --yes --ci=y --toolchain=clang
49-
50-
- name: Build clice
51-
run: |
52-
xmake build --verbose --diagnosis --all
53-
54-
- name: Install uv for integration tests
55-
uses: astral-sh/setup-uv@v6
56-
57-
- name: Run tests
58-
run: xmake test --verbose
59-
60-
linux:
61-
strategy:
62-
matrix:
63-
os: [ubuntu-24.04]
64-
build_type: [release, debug]
65-
66-
runs-on: ${{ matrix.os }}
67-
68-
steps:
69-
- name: Setup llvm & libstdc++ & cmake & ninja
36+
- name: Setup dependencies (Linux)
37+
if: runner.os == 'Linux'
7038
run: |
7139
sudo apt update
7240
sudo apt install -y gcc-14 g++-14 libstdc++-14-dev
7341
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 100
7442
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14 100
7543
sudo update-alternatives --set gcc /usr/bin/gcc-14
7644
sudo update-alternatives --set g++ /usr/bin/g++-14
77-
7845
wget https://apt.llvm.org/llvm.sh
7946
chmod +x llvm.sh
8047
sudo ./llvm.sh 20 all
81-
8248
sudo apt install -y cmake ninja-build
8349
84-
- name: Checkout repository
85-
uses: actions/checkout@v4
86-
87-
- name: Setup xmake
88-
uses: xmake-io/github-action-setup-xmake@v1
89-
with:
90-
xmake-version: 3.0.4
91-
actions-cache-folder: ".xmake-cache"
92-
actions-cache-key: ${{ matrix.os }}
93-
package-cache: true
94-
package-cache-key: ${{ matrix.os }}
95-
build-cache: true
96-
build-cache-key: ${{ matrix.os }}-${{ matrix.build_type }}
97-
98-
- name: Xmake configure
50+
- name: Setup dependencies (MacOS)
51+
if: runner.os == 'macOS'
9952
run: |
100-
xmake config --yes --ci=y --mode=${{ matrix.build_type }} --toolchain=clang-20
53+
brew install llvm@20 lld@20
10154
102-
- name: Build clice
103-
run: |
104-
xmake build --verbose --diagnosis --all
105-
106-
- name: Install uv for integration tests
107-
uses: astral-sh/setup-uv@v6
108-
109-
- name: Run tests
110-
run: xmake test --verbose
111-
112-
# Workaround `no space left on device`
113-
- name: Remove llvm package
114-
run: rm -rf /home/runner/.xmake/packages/c/clice-llvm
115-
116-
macos:
117-
strategy:
118-
matrix:
119-
os: [macos-15]
120-
build_type: [release, debug]
121-
122-
runs-on: ${{ matrix.os }}
123-
124-
steps:
12555
- name: Checkout repository
12656
uses: actions/checkout@v4
12757

128-
- name: Setup llvm
129-
run: |
130-
brew install llvm@20
131-
13258
- name: Setup xmake
13359
uses: xmake-io/github-action-setup-xmake@v1
13460
with:
@@ -140,9 +66,16 @@ jobs:
14066
build-cache: true
14167
build-cache-key: ${{ matrix.os }}-${{ matrix.build_type }}
14268

143-
- name: Xmake configure
69+
- name: XMake configure
70+
shell: bash
14471
run: |
145-
xmake config --yes --ci=y --mode=${{ matrix.build_type }} --toolchain=clang --sdk=/opt/homebrew/opt/llvm@20
72+
if [[ "${{ runner.os }}" == "Windows" ]]; then
73+
xmake config --yes --ci=y --mode=${{ matrix.build_type }} --toolchain=clang -p windows
74+
elif [[ "${{ runner.os }}" == "Linux" ]]; then
75+
xmake config --yes --ci=y --mode=${{ matrix.build_type }} --toolchain=clang-20
76+
elif [[ "${{ runner.os }}" == "macOS" ]]; then
77+
xmake config --yes --ci=y --mode=${{ matrix.build_type }} --toolchain=clang --sdk=/opt/homebrew/opt/llvm@20
78+
fi
14679
14780
- name: Build clice
14881
run: |
@@ -152,7 +85,15 @@ jobs:
15285
uses: astral-sh/setup-uv@v6
15386

15487
- name: Run tests
88+
shell: bash
15589
run: |
156-
# Workaround for MacOS
157-
export PATH="/opt/homebrew/opt/llvm@20/bin:/opt/homebrew/opt/lld@20/bin:$PATH"
90+
# Workaround for macOS
91+
if [[ "${{ runner.os }}" == "macOS" ]]; then
92+
export PATH="/opt/homebrew/opt/llvm@20/bin:/opt/homebrew/opt/lld@20/bin:$PATH"
93+
fi
94+
15895
xmake test --verbose
96+
97+
- name: Remove llvm package (Linux)
98+
if: runner.os == 'Linux'
99+
run: rm -rf /home/runner/.xmake/packages/c/clice-llvm

CMakeLists.txt

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
cmake_minimum_required(VERSION 3.20)
22
project(CLICE_PROJECT LANGUAGES C CXX)
33

4-
54
set(CMAKE_CXX_STANDARD 23)
65
set(CMAKE_CXX_STANDARD_REQUIRED ON)
76
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
@@ -34,9 +33,20 @@ endif()
3433

3534
if(WIN32)
3635
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
37-
target_link_options(clice_options INTERFACE -fuse-ld=lld-link)
38-
else()
39-
target_link_options(clice_options INTERFACE -fuse-ld=lld)
36+
target_link_options(clice_options INTERFACE
37+
-fuse-ld=lld-link
38+
-Wl,/OPT:REF
39+
)
40+
elseif(APPLE)
41+
target_link_options(clice_options INTERFACE
42+
-fuse-ld=lld
43+
-Wl,-dead_strip
44+
)
45+
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
46+
target_link_options(clice_options INTERFACE
47+
-fuse-ld=lld
48+
-Wl,--gc-sections
49+
)
4050
endif()
4151

4252
if (MSVC)
@@ -51,6 +61,8 @@ else()
5161
-fno-exceptions
5262
-Wno-deprecated-declarations
5363
-Wno-undefined-inline
64+
-ffunction-sections
65+
-fdata-sections
5466
)
5567
endif()
5668

cmake/llvm_setup.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ function(install_prebuilt_llvm LLVM_VERSION)
146146
# Download if file does not exist
147147
if(NOT EXISTS "${DOWNLOAD_PATH}")
148148
message(STATUS "Downloading prebuilt LLVM package: ${LLVM_PACKAGE}")
149-
set(DOWNLOAD_URL "https://github.com/clice-io/llvm-binary/releases/download/${LLVM_VERSION}/${LLVM_PACKAGE}")
149+
set(DOWNLOAD_URL "https://github.com/clice-io/clice-llvm/releases/download/${LLVM_VERSION}/${LLVM_PACKAGE}")
150150
file(DOWNLOAD "${DOWNLOAD_URL}"
151151
"${DOWNLOAD_PATH}"
152152
STATUS DOWNLOAD_STATUS

cmake/package.cmake

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ endif()
1313
# set llvm include and lib path
1414
add_library(llvm-libs INTERFACE IMPORTED)
1515

16-
message(STATUS "LLVM include path: ${LLVM_INSTALL_PATH}/include")
1716
# add to include directories
1817
target_include_directories(llvm-libs INTERFACE "${LLVM_INSTALL_PATH}/include")
1918

@@ -27,11 +26,9 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
2726
clangAST
2827
clangASTMatchers
2928
clangBasic
30-
clangDependencyScanning
3129
clangDriver
3230
clangFormat
3331
clangFrontend
34-
clangIndex
3532
clangLex
3633
clangSema
3734
clangSerialization
@@ -70,11 +67,10 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
7067
else()
7168
file(GLOB LLVM_LIBRARIES CONFIGURE_DEPENDS "${LLVM_INSTALL_PATH}/lib/*${CMAKE_STATIC_LIBRARY_SUFFIX}")
7269
target_link_libraries(llvm-libs INTERFACE ${LLVM_LIBRARIES})
70+
target_compile_definitions(llvm-libs INTERFACE CLANG_BUILD_STATIC=1)
7371
endif()
7472

75-
7673
if(WIN32)
77-
target_compile_definitions(llvm-libs INTERFACE "CLANG_BUILD_STATIC")
7874
target_link_libraries(llvm-libs INTERFACE version ntdll)
7975
endif()
8076

0 commit comments

Comments
 (0)