Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
56db607
[libc][Github] Perform baremetal libc builds
Prabhuk Nov 11, 2025
981b670
Carve out a separate build step.
Prabhuk Nov 11, 2025
91c956f
Conditionally enable baremetal build.
Prabhuk Nov 11, 2025
16dac53
Add build step.
Prabhuk Nov 11, 2025
a4b12f6
Reuse build and install directories.
Prabhuk Nov 11, 2025
2a3c203
Guard baremetal config inside cmake step.
Prabhuk Nov 11, 2025
6d660cd
Remove baremetal check.
Prabhuk Nov 11, 2025
484396b
Add missing braces.
Prabhuk Nov 11, 2025
a4f6878
Guard test step. Skip compiler works cmake checks.
Prabhuk Nov 11, 2025
65d5107
Remove problematic test guard for now.
Prabhuk Nov 11, 2025
adf1e4f
Remove unnecessary spaces.
Prabhuk Nov 11, 2025
14b3572
Introduce a second target.
Prabhuk Nov 11, 2025
f5797ba
Use cache file for libc standalone build.
Prabhuk Nov 12, 2025
efc999f
Try to fix target if condition. Update cache file.
Prabhuk Nov 12, 2025
37bc709
Bring back enable_baremetal_build for experimentation.
Prabhuk Nov 12, 2025
97a969d
Add default target triple.
Prabhuk Nov 13, 2025
0601f69
Add LIBC_TARGET_TRIPLE
Prabhuk Nov 13, 2025
e616557
Cleanup cache file. Make it generic for all relevant baremetal target…
Prabhuk Nov 13, 2025
2810c45
Fix missing backslash.
Prabhuk Nov 13, 2025
9c203f5
Disable tests on baremetal builders.
Prabhuk Nov 13, 2025
2f4781f
Fix ending braces.
Prabhuk Nov 13, 2025
c00ac42
Use single quotes.
Prabhuk Nov 13, 2025
7f00c88
Drop enable_baremetal_build
Prabhuk Nov 13, 2025
500ddf2
Cleanup cache file.
Prabhuk Nov 13, 2025
dbe9e26
Address reviw comments.
Prabhuk Nov 13, 2025
9a6a569
Cache file location and name fix.
Prabhuk Nov 13, 2025
54bf553
Break out architecture specific flags into dedicated cache files.
Prabhuk Nov 15, 2025
4a3a8ca
Set ARCH_TRIPLE from cache files and not yml file.
Prabhuk Nov 15, 2025
bccaf16
Kinda important to set the command name.
Prabhuk Nov 15, 2025
384331f
Rename ARCH_TRIPLE and address other review comments.
Prabhuk Nov 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 67 additions & 16 deletions .github/workflows/libc-fullbuild-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,42 @@ jobs:
cpp_compiler: clang++-22
target: x86_64-unknown-uefi-llvm
include_scudo: OFF
- os: ubuntu-24.04
build__type: MinSizeRel
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is double underscore intended here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely not. Thanks for catching this. I'll send a patch.

c_compiler: clang-22
cpp_compiler: clang++-22
target: armv6m-none-eabi
include_scudo: OFF
- os: ubuntu-24.04
build__type: MinSizeRel
c_compiler: clang-22
cpp_compiler: clang++-22
target: armv7m-none-eabi
include_scudo: OFF
- os: ubuntu-24.04
build__type: MinSizeRel
c_compiler: clang-22
cpp_compiler: clang++-22
target: armv7em-none-eabi
include_scudo: OFF
- os: ubuntu-24.04
build__type: MinSizeRel
c_compiler: clang-22
cpp_compiler: clang++-22
target: armv8m.main-none-eabi
include_scudo: OFF
- os: ubuntu-24.04
build__type: MinSizeRel
c_compiler: clang-22
cpp_compiler: clang++-22
target: armv8.1m.main-none-eabi
include_scudo: OFF
- os: ubuntu-24.04
build__type: MinSizeRel
c_compiler: clang-22
cpp_compiler: clang++-22
target: riscv32-unknown-elf
include_scudo: OFF
# TODO: add back gcc build when it is fixed
# - c_compiler: gcc
# cpp_compiler: g++
Expand Down Expand Up @@ -93,28 +129,39 @@ jobs:
run: |
export RUNTIMES="libc"

export CMAKE_FLAGS="
-G Ninja
-S ${{ github.workspace }}/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" ]]; then
export RUNTIMES="$RUNTIMES;compiler-rt"
export CMAKE_FLAGS="
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

cmake -B ${{ steps.strings.outputs.build-output-dir }} \
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \
-DCMAKE_C_COMPILER=${{ matrix.c_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 }} \
-DLLVM_RUNTIME_TARGETS=${{ matrix.target }} \
-DLLVM_ENABLE_RUNTIMES="$RUNTIMES" \
-DLLVM_LIBC_FULL_BUILD=ON \
-G Ninja \
-S ${{ github.workspace }}/runtimes \
$CMAKE_FLAGS
case "${{ matrix.target }}" in
*-none-eabi|riscv32-unknown-elf)
cmake $CMAKE_FLAGS \
-C ${{ github.workspace }}/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
run: >
Expand All @@ -124,8 +171,12 @@ jobs:
--target install

- name: Test
# Skip UEFI tests until we have testing set up.
if: ${{ ! endsWith(matrix.target, '-uefi-llvm') }}
# 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 }}
Expand Down
8 changes: 8 additions & 0 deletions libc/cmake/caches/armv6m-none-eabi.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
set(CMAKE_SYSTEM_PROCESSOR arm CACHE STRING "")
set(RUNTIMES_TARGET_TRIPLE "armv6m-none-eabi" CACHE STRING "")

foreach(lang C;CXX;ASM)
set(CMAKE_${lang}_FLAGS "-march=armv6m -mcpu=cortex-m0plus -mfloat-abi=soft -Wno-atomic-alignment \"-Dvfprintf(stream, format, vlist)=vprintf(format, vlist)\" \"-Dfprintf(stream, format, ...)=printf(format)\" \"-Dfputs(string, stream)=puts(string)\" -D_LIBCPP_PRINT=1" CACHE STRING "")
endforeach()

include(${CMAKE_CURRENT_LIST_DIR}/baremetal_common.cmake)
8 changes: 8 additions & 0 deletions libc/cmake/caches/armv7em-none-eabi.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
set(CMAKE_SYSTEM_PROCESSOR arm CACHE STRING "")
set(RUNTIMES_TARGET_TRIPLE "armv7em-none-eabi" CACHE STRING "")

foreach(lang C;CXX;ASM)
set(CMAKE_${lang}_FLAGS "-march=armv7em -mcpu=cortex-m4 -mfloat-abi=soft -Wno-atomic-alignment \"-Dvfprintf(stream, format, vlist)=vprintf(format, vlist)\" \"-Dfprintf(stream, format, ...)=printf(format)\" \"-Dfputs(string, stream)=puts(string)\" -D_LIBCPP_PRINT=1" CACHE STRING "")
endforeach()

include(${CMAKE_CURRENT_LIST_DIR}/baremetal_common.cmake)
8 changes: 8 additions & 0 deletions libc/cmake/caches/armv7m-none-eabi.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
set(CMAKE_SYSTEM_PROCESSOR arm CACHE STRING "")
set(RUNTIMES_TARGET_TRIPLE "armv7m-none-eabi" CACHE STRING "")

foreach(lang C;CXX;ASM)
set(CMAKE_${lang}_FLAGS "-march=armv7m -mcpu=cortex-m4 -mfloat-abi=soft -Wno-atomic-alignment \"-Dvfprintf(stream, format, vlist)=vprintf(format, vlist)\" \"-Dfprintf(stream, format, ...)=printf(format)\" \"-Dfputs(string, stream)=puts(string)\" -D_LIBCPP_PRINT=1" CACHE STRING "")
endforeach()

include(${CMAKE_CURRENT_LIST_DIR}/baremetal_common.cmake)
8 changes: 8 additions & 0 deletions libc/cmake/caches/armv8.1m.main-none-eabi.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
set(CMAKE_SYSTEM_PROCESSOR arm CACHE STRING "")
set(RUNTIMES_TARGET_TRIPLE "armv8.1m.main-none-eabi" CACHE STRING "")

foreach(lang C;CXX;ASM)
set(CMAKE_${lang}_FLAGS "-mfloat-abi=hard -march=armv8.1-m.main+mve.fp+fp.dp -mcpu=cortex-m55" CACHE STRING "")
endforeach()

include(${CMAKE_CURRENT_LIST_DIR}/baremetal_common.cmake)
8 changes: 8 additions & 0 deletions libc/cmake/caches/armv8m.main-none-eabi.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
set(CMAKE_SYSTEM_PROCESSOR arm CACHE STRING "")
set(RUNTIMES_TARGET_TRIPLE "armv8m.main-none-eabi" CACHE STRING "")

foreach(lang C;CXX;ASM)
set(CMAKE_${lang}_FLAGS "-mfloat-abi=softfp -march=armv8m.main+fp+dsp -mcpu=cortex-m33" CACHE STRING "")
endforeach()

include(${CMAKE_CURRENT_LIST_DIR}/baremetal_common.cmake)
21 changes: 21 additions & 0 deletions libc/cmake/caches/baremetal_common.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Expects target triple to be passed as `RUNTIMES_TARGET_TRIPLE`

set(CMAKE_SYSTEM_NAME Generic CACHE STRING "")
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY CACHE STRING "")
set(LLVM_ENABLE_RUNTIMES "libc" CACHE STRING "")
set(LLVM_INCLUDE_TESTS OFF CACHE BOOL "")
set(CMAKE_C_COMPILER_WORKS ON CACHE BOOL "")
set(CMAKE_CXX_COMPILER_WORKS ON CACHE BOOL "")
set(CMAKE_SYSROOT "" CACHE STRING "")
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

set(CMAKE_C_COMPILER_TARGET ${RUNTIMES_TARGET_TRIPLE} CACHE STRING "")
set(CMAKE_CXX_COMPILER_TARGET ${RUNTIMES_TARGET_TRIPLE} CACHE STRING "")
set(CMAKE_ASM_COMPILER_TARGET ${RUNTIMES_TARGET_TRIPLE} CACHE STRING "")
set(LLVM_DEFAULT_TARGET_TRIPLE ${RUNTIMES_TARGET_TRIPLE} CACHE STRING "")
set(LIBC_TARGET_TRIPLE ${RUNTIMES_TARGET_TRIPLE} CACHE STRING "")

set(LLVM_LIBC_FULL_BUILD "ON" CACHE BOOL "")
4 changes: 4 additions & 0 deletions libc/cmake/caches/riscv32-unknown-elf.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set(CMAKE_SYSTEM_PROCESSOR RISCV CACHE STRING "")
set(RUNTIMES_TARGET_TRIPLE "riscv32-unknown-elf" CACHE STRING "")

include(${CMAKE_CURRENT_LIST_DIR}/baremetal_common.cmake)
Loading