| # This workflow is for pre-commit testing of the LLVM-libc project. |
| name: LLVM-libc Pre-commit Fullbuild Tests |
| permissions: |
| contents: read |
| on: |
| pull_request: |
| branches: [ "main" ] |
| paths: |
| - 'libc/**' |
| - '.github/workflows/libc-fullbuild-tests.yml' |
| |
| jobs: |
| build: |
| runs-on: ${{ matrix.os }} |
| container: |
| image: ${{ (startsWith(matrix.os, 'ubuntu-24.04-arm') && 'ghcr.io/llvm/arm64v8/libc-ubuntu-24.04') || 'ghcr.io/llvm/libc-ubuntu-24.04'}} |
| # We need to enable privileged containers so that certain libc tests |
| # have the necessary permissions (like SYS_TIME). There are no security |
| # implications as we are already running in an isolated VM. |
| options: >- |
| --privileged |
| strategy: |
| fail-fast: false |
| matrix: |
| # Build basic linux configuration with Debug/Release/MinSizeRel and all |
| # other configurations in Debug only. |
| include: |
| - os: ubuntu-24.04 |
| build_type: Debug |
| c_compiler: clang-23 |
| cpp_compiler: clang++-23 |
| target: x86_64-unknown-linux-llvm |
| include_scudo: ON |
| build_fuzzing_tests: OFF |
| - os: ubuntu-24.04 |
| build_type: Release |
| c_compiler: clang-23 |
| cpp_compiler: clang++-23 |
| target: x86_64-unknown-linux-llvm |
| include_scudo: ON |
| build_fuzzing_tests: ON |
| - os: ubuntu-24.04 |
| build_type: MinSizeRel |
| c_compiler: clang-23 |
| cpp_compiler: clang++-23 |
| target: x86_64-unknown-linux-llvm |
| include_scudo: ON |
| build_fuzzing_tests: OFF |
| - os: ubuntu-24.04-arm |
| build_type: Debug |
| c_compiler: clang-23 |
| cpp_compiler: clang++-23 |
| target: aarch64-unknown-linux-llvm |
| include_scudo: ON |
| build_fuzzing_tests: ON |
| - os: ubuntu-24.04 |
| build_type: Debug |
| c_compiler: clang-23 |
| cpp_compiler: clang++-23 |
| target: x86_64-unknown-uefi-llvm |
| include_scudo: OFF |
| build_fuzzing_tests: OFF |
| - os: ubuntu-24.04 |
| build_type: MinSizeRel |
| c_compiler: clang-23 |
| cpp_compiler: clang++-23 |
| target: armv6m-none-eabi |
| include_scudo: OFF |
| build_fuzzing_tests: OFF |
| - os: ubuntu-24.04 |
| build_type: MinSizeRel |
| c_compiler: clang-23 |
| cpp_compiler: clang++-23 |
| target: armv7m-none-eabi |
| include_scudo: OFF |
| build_fuzzing_tests: OFF |
| - os: ubuntu-24.04 |
| build_type: MinSizeRel |
| c_compiler: clang-23 |
| cpp_compiler: clang++-23 |
| target: armv7em-none-eabi |
| include_scudo: OFF |
| build_fuzzing_tests: OFF |
| - os: ubuntu-24.04 |
| build_type: MinSizeRel |
| c_compiler: clang-23 |
| cpp_compiler: clang++-23 |
| target: armv8m.main-none-eabi |
| include_scudo: OFF |
| build_fuzzing_tests: OFF |
| - os: ubuntu-24.04 |
| build_type: MinSizeRel |
| c_compiler: clang-23 |
| cpp_compiler: clang++-23 |
| target: armv8.1m.main-none-eabi |
| include_scudo: OFF |
| build_fuzzing_tests: OFF |
| - os: ubuntu-24.04 |
| build_type: MinSizeRel |
| c_compiler: clang-23 |
| cpp_compiler: clang++-23 |
| target: riscv32-unknown-elf |
| include_scudo: OFF |
| build_fuzzing_tests: OFF |
| # TODO: add back gcc build when it is fixed |
| # - c_compiler: gcc |
| # cpp_compiler: g++ |
| steps: |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| with: |
| persist-credentials: false |
| |
| # Libc's build is relatively small comparing with other components of LLVM. |
| # A fresh fullbuild takes about 190MiB of uncompressed disk space, which can |
| # be compressed into ~40MiB. Limiting the cache size to 1G should be enough. |
| # Prefer sccache as it is more modern. |
| # Do not use direct GHAC access even though it is supported by sccache. GHAC rejects |
| # frequent small object writes. |
| - name: Setup ccache |
| uses: hendrikmuhs/ccache-action@33522472633dbd32578e909b315f5ee43ba878ce # v1.2.22 |
| with: |
| max-size: 1G |
| key: libc_fullbuild_${{ matrix.c_compiler }} |
| variant: sccache |
| |
| - name: Set reusable strings |
| id: strings |
| shell: bash |
| run: | |
| echo "build-output-dir=/__w/llvm-project/llvm-project/build" >> "$GITHUB_OUTPUT" |
| echo "build-install-dir=/__w/llvm-project/llvm-project/install" >> "$GITHUB_OUTPUT" |
| |
| # Configure libc fullbuild with scudo. |
| - name: Configure CMake |
| run: | |
| export RUNTIMES="libc" |
| |
| export CMAKE_FLAGS=" |
| -G Ninja |
| -S /__w/llvm-project/llvm-project/runtimes |
| -B ${{ steps.strings.outputs.build-output-dir }} |
| -DCMAKE_ASM_COMPILER=${{ matrix.c_compiler }} |
| -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} |
| -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} |
| -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} |
| -DCMAKE_C_COMPILER_LAUNCHER=sccache |
| -DCMAKE_CXX_COMPILER_LAUNCHER=sccache |
| -DCMAKE_INSTALL_PREFIX=${{ steps.strings.outputs.build-install-dir }}" |
| |
| if [[ "${{ matrix.include_scudo }}" == "ON" || "${{ matrix.build_fuzzing_tests }}" == "ON" ]]; then |
| export RUNTIMES="$RUNTIMES;compiler-rt" |
| fi |
| |
| if [[ "${{ matrix.include_scudo }}" == "ON" ]]; then |
| export CMAKE_FLAGS="$CMAKE_FLAGS |
| -DLLVM_LIBC_INCLUDE_SCUDO=ON |
| -DCOMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC=ON |
| -DCOMPILER_RT_BUILD_GWP_ASAN=OFF |
| -DCOMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED=OFF" |
| fi |
| |
| case "${{ matrix.target }}" in |
| *-none-eabi|riscv32-unknown-elf) |
| cmake $CMAKE_FLAGS \ |
| -C /__w/llvm-project/llvm-project/libc/cmake/caches/${{ matrix.target }}.cmake |
| ;; |
| *) |
| cmake -DLLVM_RUNTIME_TARGETS=${{ matrix.target }} \ |
| -DLLVM_ENABLE_RUNTIMES="$RUNTIMES" \ |
| -DLLVM_LIBC_FULL_BUILD=ON \ |
| $CMAKE_FLAGS |
| ;; |
| esac |
| |
| - name: Build |
| shell: bash |
| run: | |
| TARGETS="install" |
| if [[ "${{ matrix.build_fuzzing_tests }}" == "ON" ]]; then |
| TARGETS="$TARGETS libc-fuzzer" |
| fi |
| |
| cmake \ |
| --build ${{ steps.strings.outputs.build-output-dir }} \ |
| --parallel \ |
| --target $TARGETS |
| |
| - name: Test |
| # Skip UEFI and baremetal tests until we have testing set up. |
| if: ${{ |
| !endsWith(matrix.target, '-uefi-llvm') && |
| !endsWith(matrix.target, '-none-eabi') && |
| matrix.target != 'riscv32-unknown-elf' |
| }} |
| run: > |
| cmake |
| --build ${{ steps.strings.outputs.build-output-dir }} |
| --parallel |
| --target check-libc |