[libc-commits] [libc] b32c434 - [libc][Github] Perform baremetal libc builds (#167583)
via libc-commits
libc-commits at lists.llvm.org
Mon Nov 17 12:08:43 PST 2025
Author: Prabhu Rajasekaran
Date: 2025-11-17T12:08:39-08:00
New Revision: b32c434426a181590234f65f2e32f43735bf5b5a
URL: https://github.com/llvm/llvm-project/commit/b32c434426a181590234f65f2e32f43735bf5b5a
DIFF: https://github.com/llvm/llvm-project/commit/b32c434426a181590234f65f2e32f43735bf5b5a.diff
LOG: [libc][Github] Perform baremetal libc builds (#167583)
Currently there are no 32 bit presubmit builds for libc. This PR
performs 32 bit build only (no test) to check any changes that land in
libc break 32 bit builds.
Co-authored-by: Aiden Grossman <aidengrossman at google.com>
Added:
libc/cmake/caches/armv6m-none-eabi.cmake
libc/cmake/caches/armv7em-none-eabi.cmake
libc/cmake/caches/armv7m-none-eabi.cmake
libc/cmake/caches/armv8.1m.main-none-eabi.cmake
libc/cmake/caches/armv8m.main-none-eabi.cmake
libc/cmake/caches/baremetal_common.cmake
libc/cmake/caches/riscv32-unknown-elf.cmake
Modified:
.github/workflows/libc-fullbuild-tests.yml
Removed:
################################################################################
diff --git a/.github/workflows/libc-fullbuild-tests.yml b/.github/workflows/libc-fullbuild-tests.yml
index 3a048aeb9405b..c5b7f606a115a 100644
--- a/.github/workflows/libc-fullbuild-tests.yml
+++ b/.github/workflows/libc-fullbuild-tests.yml
@@ -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
+ 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++
@@ -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: >
@@ -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 }}
diff --git a/libc/cmake/caches/armv6m-none-eabi.cmake b/libc/cmake/caches/armv6m-none-eabi.cmake
new file mode 100644
index 0000000000000..1f463ae5c0ead
--- /dev/null
+++ b/libc/cmake/caches/armv6m-none-eabi.cmake
@@ -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)
diff --git a/libc/cmake/caches/armv7em-none-eabi.cmake b/libc/cmake/caches/armv7em-none-eabi.cmake
new file mode 100644
index 0000000000000..afbe9c87dffe1
--- /dev/null
+++ b/libc/cmake/caches/armv7em-none-eabi.cmake
@@ -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)
diff --git a/libc/cmake/caches/armv7m-none-eabi.cmake b/libc/cmake/caches/armv7m-none-eabi.cmake
new file mode 100644
index 0000000000000..796adb2f31148
--- /dev/null
+++ b/libc/cmake/caches/armv7m-none-eabi.cmake
@@ -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)
diff --git a/libc/cmake/caches/armv8.1m.main-none-eabi.cmake b/libc/cmake/caches/armv8.1m.main-none-eabi.cmake
new file mode 100644
index 0000000000000..4095facce46ac
--- /dev/null
+++ b/libc/cmake/caches/armv8.1m.main-none-eabi.cmake
@@ -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)
diff --git a/libc/cmake/caches/armv8m.main-none-eabi.cmake b/libc/cmake/caches/armv8m.main-none-eabi.cmake
new file mode 100644
index 0000000000000..4b69f6a822e71
--- /dev/null
+++ b/libc/cmake/caches/armv8m.main-none-eabi.cmake
@@ -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)
diff --git a/libc/cmake/caches/baremetal_common.cmake b/libc/cmake/caches/baremetal_common.cmake
new file mode 100644
index 0000000000000..c0d665d790393
--- /dev/null
+++ b/libc/cmake/caches/baremetal_common.cmake
@@ -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 "")
diff --git a/libc/cmake/caches/riscv32-unknown-elf.cmake b/libc/cmake/caches/riscv32-unknown-elf.cmake
new file mode 100644
index 0000000000000..960fb2bb51a4f
--- /dev/null
+++ b/libc/cmake/caches/riscv32-unknown-elf.cmake
@@ -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)
More information about the libc-commits
mailing list