Skip to content

Commit b32c434

Browse files
[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 <[email protected]>
1 parent 320c18a commit b32c434

File tree

8 files changed

+132
-16
lines changed

8 files changed

+132
-16
lines changed

.github/workflows/libc-fullbuild-tests.yml

Lines changed: 67 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,42 @@ jobs:
4848
cpp_compiler: clang++-22
4949
target: x86_64-unknown-uefi-llvm
5050
include_scudo: OFF
51+
- os: ubuntu-24.04
52+
build__type: MinSizeRel
53+
c_compiler: clang-22
54+
cpp_compiler: clang++-22
55+
target: armv6m-none-eabi
56+
include_scudo: OFF
57+
- os: ubuntu-24.04
58+
build__type: MinSizeRel
59+
c_compiler: clang-22
60+
cpp_compiler: clang++-22
61+
target: armv7m-none-eabi
62+
include_scudo: OFF
63+
- os: ubuntu-24.04
64+
build__type: MinSizeRel
65+
c_compiler: clang-22
66+
cpp_compiler: clang++-22
67+
target: armv7em-none-eabi
68+
include_scudo: OFF
69+
- os: ubuntu-24.04
70+
build__type: MinSizeRel
71+
c_compiler: clang-22
72+
cpp_compiler: clang++-22
73+
target: armv8m.main-none-eabi
74+
include_scudo: OFF
75+
- os: ubuntu-24.04
76+
build__type: MinSizeRel
77+
c_compiler: clang-22
78+
cpp_compiler: clang++-22
79+
target: armv8.1m.main-none-eabi
80+
include_scudo: OFF
81+
- os: ubuntu-24.04
82+
build__type: MinSizeRel
83+
c_compiler: clang-22
84+
cpp_compiler: clang++-22
85+
target: riscv32-unknown-elf
86+
include_scudo: OFF
5187
# TODO: add back gcc build when it is fixed
5288
# - c_compiler: gcc
5389
# cpp_compiler: g++
@@ -93,28 +129,39 @@ jobs:
93129
run: |
94130
export RUNTIMES="libc"
95131
132+
export CMAKE_FLAGS="
133+
-G Ninja
134+
-S ${{ github.workspace }}/runtimes
135+
-B ${{ steps.strings.outputs.build-output-dir }}
136+
-DCMAKE_ASM_COMPILER=${{ matrix.c_compiler }}
137+
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
138+
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
139+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
140+
-DCMAKE_C_COMPILER_LAUNCHER=sccache
141+
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache
142+
-DCMAKE_INSTALL_PREFIX=${{ steps.strings.outputs.build-install-dir }}"
143+
96144
if [[ ${{ matrix.include_scudo}} == "ON" ]]; then
97145
export RUNTIMES="$RUNTIMES;compiler-rt"
98-
export CMAKE_FLAGS="
146+
export CMAKE_FLAGS="$CMAKE_FLAGS
99147
-DLLVM_LIBC_INCLUDE_SCUDO=ON
100148
-DCOMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC=ON
101149
-DCOMPILER_RT_BUILD_GWP_ASAN=OFF
102150
-DCOMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED=OFF"
103151
fi
104152
105-
cmake -B ${{ steps.strings.outputs.build-output-dir }} \
106-
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \
107-
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \
108-
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
109-
-DCMAKE_C_COMPILER_LAUNCHER=sccache \
110-
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache \
111-
-DCMAKE_INSTALL_PREFIX=${{ steps.strings.outputs.build-install-dir }} \
112-
-DLLVM_RUNTIME_TARGETS=${{ matrix.target }} \
113-
-DLLVM_ENABLE_RUNTIMES="$RUNTIMES" \
114-
-DLLVM_LIBC_FULL_BUILD=ON \
115-
-G Ninja \
116-
-S ${{ github.workspace }}/runtimes \
117-
$CMAKE_FLAGS
153+
case "${{ matrix.target }}" in
154+
*-none-eabi|riscv32-unknown-elf)
155+
cmake $CMAKE_FLAGS \
156+
-C ${{ github.workspace }}/libc/cmake/caches/${{ matrix.target }}.cmake
157+
;;
158+
*)
159+
cmake -DLLVM_RUNTIME_TARGETS=${{ matrix.target }} \
160+
-DLLVM_ENABLE_RUNTIMES="$RUNTIMES" \
161+
-DLLVM_LIBC_FULL_BUILD=ON \
162+
$CMAKE_FLAGS
163+
;;
164+
esac
118165
119166
- name: Build
120167
run: >
@@ -124,8 +171,12 @@ jobs:
124171
--target install
125172
126173
- name: Test
127-
# Skip UEFI tests until we have testing set up.
128-
if: ${{ ! endsWith(matrix.target, '-uefi-llvm') }}
174+
# Skip UEFI and baremetal tests until we have testing set up.
175+
if: ${{
176+
!endsWith(matrix.target, '-uefi-llvm') &&
177+
!endsWith(matrix.target, '-none-eabi') &&
178+
matrix.target != 'riscv32-unknown-elf'
179+
}}
129180
run: >
130181
cmake
131182
--build ${{ steps.strings.outputs.build-output-dir }}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
set(CMAKE_SYSTEM_PROCESSOR arm CACHE STRING "")
2+
set(RUNTIMES_TARGET_TRIPLE "armv6m-none-eabi" CACHE STRING "")
3+
4+
foreach(lang C;CXX;ASM)
5+
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 "")
6+
endforeach()
7+
8+
include(${CMAKE_CURRENT_LIST_DIR}/baremetal_common.cmake)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
set(CMAKE_SYSTEM_PROCESSOR arm CACHE STRING "")
2+
set(RUNTIMES_TARGET_TRIPLE "armv7em-none-eabi" CACHE STRING "")
3+
4+
foreach(lang C;CXX;ASM)
5+
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 "")
6+
endforeach()
7+
8+
include(${CMAKE_CURRENT_LIST_DIR}/baremetal_common.cmake)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
set(CMAKE_SYSTEM_PROCESSOR arm CACHE STRING "")
2+
set(RUNTIMES_TARGET_TRIPLE "armv7m-none-eabi" CACHE STRING "")
3+
4+
foreach(lang C;CXX;ASM)
5+
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 "")
6+
endforeach()
7+
8+
include(${CMAKE_CURRENT_LIST_DIR}/baremetal_common.cmake)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
set(CMAKE_SYSTEM_PROCESSOR arm CACHE STRING "")
2+
set(RUNTIMES_TARGET_TRIPLE "armv8.1m.main-none-eabi" CACHE STRING "")
3+
4+
foreach(lang C;CXX;ASM)
5+
set(CMAKE_${lang}_FLAGS "-mfloat-abi=hard -march=armv8.1-m.main+mve.fp+fp.dp -mcpu=cortex-m55" CACHE STRING "")
6+
endforeach()
7+
8+
include(${CMAKE_CURRENT_LIST_DIR}/baremetal_common.cmake)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
set(CMAKE_SYSTEM_PROCESSOR arm CACHE STRING "")
2+
set(RUNTIMES_TARGET_TRIPLE "armv8m.main-none-eabi" CACHE STRING "")
3+
4+
foreach(lang C;CXX;ASM)
5+
set(CMAKE_${lang}_FLAGS "-mfloat-abi=softfp -march=armv8m.main+fp+dsp -mcpu=cortex-m33" CACHE STRING "")
6+
endforeach()
7+
8+
include(${CMAKE_CURRENT_LIST_DIR}/baremetal_common.cmake)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Expects target triple to be passed as `RUNTIMES_TARGET_TRIPLE`
2+
3+
set(CMAKE_SYSTEM_NAME Generic CACHE STRING "")
4+
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY CACHE STRING "")
5+
set(LLVM_ENABLE_RUNTIMES "libc" CACHE STRING "")
6+
set(LLVM_INCLUDE_TESTS OFF CACHE BOOL "")
7+
set(CMAKE_C_COMPILER_WORKS ON CACHE BOOL "")
8+
set(CMAKE_CXX_COMPILER_WORKS ON CACHE BOOL "")
9+
set(CMAKE_SYSROOT "" CACHE STRING "")
10+
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
11+
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
12+
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
13+
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
14+
15+
set(CMAKE_C_COMPILER_TARGET ${RUNTIMES_TARGET_TRIPLE} CACHE STRING "")
16+
set(CMAKE_CXX_COMPILER_TARGET ${RUNTIMES_TARGET_TRIPLE} CACHE STRING "")
17+
set(CMAKE_ASM_COMPILER_TARGET ${RUNTIMES_TARGET_TRIPLE} CACHE STRING "")
18+
set(LLVM_DEFAULT_TARGET_TRIPLE ${RUNTIMES_TARGET_TRIPLE} CACHE STRING "")
19+
set(LIBC_TARGET_TRIPLE ${RUNTIMES_TARGET_TRIPLE} CACHE STRING "")
20+
21+
set(LLVM_LIBC_FULL_BUILD "ON" CACHE BOOL "")
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
set(CMAKE_SYSTEM_PROCESSOR RISCV CACHE STRING "")
2+
set(RUNTIMES_TARGET_TRIPLE "riscv32-unknown-elf" CACHE STRING "")
3+
4+
include(${CMAKE_CURRENT_LIST_DIR}/baremetal_common.cmake)

0 commit comments

Comments
 (0)