Skip to content

Commit f15cc6f

Browse files
[libc] add multi-platform pre-commit github actions (#119104)
We do not have CI coverage for Windows/MacOS and we regularly run into problem where changes break post-commit fullbuild which is not tested in pre-commit builds. This PR utilizes the github action to address such issues.
1 parent f5f9650 commit f15cc6f

File tree

2 files changed

+168
-0
lines changed

2 files changed

+168
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# This workflow is for pre-commit testing of the LLVM-libc project.
2+
name: LLVM-libc Pre-commit Fullbuild Tests
3+
4+
on:
5+
pull_request:
6+
branches: [ "main" ]
7+
paths:
8+
- 'libc/**'
9+
- '.github/workflows/libc-fullbuild-tests.yml'
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-24.04
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
include:
18+
- c_compiler: clang
19+
cpp_compiler: clang++
20+
# TODO: add back gcc build when it is fixed
21+
# - c_compiler: gcc
22+
# cpp_compiler: g++
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- name: Setup ccache
27+
uses: hendrikmuhs/[email protected]
28+
with:
29+
max-size: 1G
30+
key: libc_fullbuild_${{ matrix.c_compiler }}
31+
variant: sccache
32+
33+
- name: Prepare dependencies (Ubuntu)
34+
run: |
35+
sudo apt-get update
36+
sudo apt-get install -y libmpfr-dev libgmp-dev libmpc-dev ninja-build linux-headers-generic linux-libc-dev
37+
sudo ln -sf /usr/include/$(uname -p)-linux-gnu/asm /usr/include/asm
38+
39+
- name: Set reusable strings
40+
id: strings
41+
shell: bash
42+
run: |
43+
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
44+
echo "build-install-dir=${{ github.workspace }}/install" >> "$GITHUB_OUTPUT"
45+
46+
- name: Configure CMake
47+
run: >
48+
cmake -B ${{ steps.strings.outputs.build-output-dir }}
49+
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
50+
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
51+
-DCMAKE_BUILD_TYPE=MinSizeRel
52+
-DCMAKE_C_COMPILER_LAUNCHER=sccache
53+
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache
54+
-DCMAKE_INSTALL_PREFIX=${{ steps.strings.outputs.build-install-dir }}
55+
-DLLVM_ENABLE_RUNTIMES="libc;compiler-rt"
56+
-DLLVM_LIBC_FULL_BUILD=ON
57+
-DLLVM_LIBC_INCLUDE_SCUDO=ON
58+
-DCOMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC=ON
59+
-DCOMPILER_RT_BUILD_GWP_ASAN=OFF
60+
-DCOMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED=OFF
61+
-G Ninja
62+
-S ${{ github.workspace }}/runtimes
63+
64+
- name: Build
65+
run: >
66+
cmake
67+
--build ${{ steps.strings.outputs.build-output-dir }}
68+
--parallel
69+
--target install
70+
71+
- name: Test
72+
run: >
73+
cmake
74+
--build ${{ steps.strings.outputs.build-output-dir }}
75+
--parallel
76+
--target check-libc
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# This workflow is for pre-commit testing of the LLVM-libc project.
2+
name: LLVM-libc Pre-commit Overlay Tests
3+
4+
on:
5+
pull_request:
6+
branches: [ "main" ]
7+
paths:
8+
- 'libc/**'
9+
- '.github/workflows/libc-overlay-tests.yml'
10+
11+
jobs:
12+
build:
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations.
16+
fail-fast: false
17+
matrix:
18+
include:
19+
# TODO: add linux gcc when it is fixed
20+
- os: ubuntu-24.04
21+
compiler:
22+
c_compiler: clang
23+
cpp_compiler: clang++
24+
- os: windows-2022
25+
compiler:
26+
c_compiler: clang-cl
27+
cpp_compiler: clang-cl
28+
- os: macos-14
29+
compiler:
30+
c_compiler: clang
31+
cpp_compiler: clang++
32+
33+
steps:
34+
- uses: actions/checkout@v4
35+
36+
- name: Setup ccache
37+
uses: hendrikmuhs/ccache-action@v1
38+
with:
39+
max-size: 1G
40+
key: libc_overlay_build_${{ matrix.os }}_${{ matrix.compiler.c_compiler }}
41+
variant: sccache
42+
43+
- name: Prepare dependencies (Ubuntu)
44+
if: runner.os == 'Linux'
45+
run: |
46+
sudo apt-get update
47+
sudo apt-get install -y libmpfr-dev libgmp-dev libmpc-dev ninja-build
48+
49+
- name: Prepare dependencies (Windows)
50+
if: runner.os == 'Windows'
51+
run: |
52+
choco install ninja
53+
54+
- name: Prepare dependencies (macOS)
55+
if: runner.os == 'macOS'
56+
run: |
57+
brew install ninja
58+
59+
- name: Set reusable strings
60+
id: strings
61+
shell: bash
62+
run: |
63+
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
64+
65+
- name: Configure CMake
66+
run: >
67+
cmake -B ${{ steps.strings.outputs.build-output-dir }}
68+
-DCMAKE_CXX_COMPILER=${{ matrix.compiler.cpp_compiler }}
69+
-DCMAKE_C_COMPILER=${{ matrix.compiler.c_compiler }}
70+
-DCMAKE_BUILD_TYPE=MinSizeRel
71+
-DCMAKE_C_COMPILER_LAUNCHER=sccache
72+
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache
73+
-DCMAKE_POLICY_DEFAULT_CMP0141=NEW
74+
-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded
75+
-DLLVM_ENABLE_RUNTIMES=libc
76+
-G Ninja
77+
-S ${{ github.workspace }}/runtimes
78+
79+
- name: Build
80+
run: >
81+
cmake
82+
--build ${{ steps.strings.outputs.build-output-dir }}
83+
--parallel
84+
--config MinSizeRel
85+
--target libc
86+
87+
- name: Test
88+
run: >
89+
cmake
90+
--build ${{ steps.strings.outputs.build-output-dir }}
91+
--parallel
92+
--target check-libc

0 commit comments

Comments
 (0)