Skip to content

Commit 5024dff

Browse files
authored
[libc++][ci] Add a test configuration with an incomplete sysroot (#107089)
When bringing up a new cross compiler from scratch, we build libunwind/libcxx in a setup where the toolchain is incomplete and unable to perform the normal linker checks; this requires a few special cases in the CMake files. We simulate that scenario by removing the libc++ headers, libunwind and libc++ libraries from the installed toolchain. We need to set CMAKE_CXX_COMPILER_WORKS since CMake fails to probe the compiler. We need to set CMAKE_CXX_COMPILER_TARGET, since LLVM's heuristics fail when CMake hasn't been able to probe the environment properly. (This is normal; one has to set those options when setting up such a toolchain from scratch.) This adds CI coverage for these build scenarios, which otherwise seldom are tested by some build flow (but are essential when setting up a cross compiler from scratch).
1 parent 9e85efb commit 5024dff

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

.github/workflows/libcxx-build-and-test.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ jobs:
242242
- { config: mingw-dll, mingw: true }
243243
- { config: mingw-static, mingw: true }
244244
- { config: mingw-dll-i686, mingw: true }
245+
- { config: mingw-incomplete-sysroot, mingw: true }
245246
steps:
246247
- uses: actions/checkout@v4
247248
- name: Install dependencies
@@ -260,6 +261,12 @@ jobs:
260261
del llvm-mingw*.zip
261262
mv llvm-mingw* c:\llvm-mingw
262263
echo "c:\llvm-mingw\bin" | Out-File -FilePath $Env:GITHUB_PATH -Encoding utf8 -Append
264+
- name: Simulate a from-scratch build of llvm-mingw
265+
if: ${{ matrix.config == 'mingw-incomplete-sysroot' }}
266+
run: |
267+
rm -r c:\llvm-mingw\include\c++
268+
rm -r c:\llvm-mingw\*-w64-mingw32\lib\libc++*
269+
rm -r c:\llvm-mingw\*-w64-mingw32\lib\libunwind*
263270
- name: Add Git Bash to the path
264271
run: |
265272
echo "c:\Program Files\Git\usr\bin" | Out-File -FilePath $Env:GITHUB_PATH -Encoding utf8 -Append

libcxx/utils/ci/run-buildbot

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,29 @@ mingw-dll-i686)
715715
-C "${MONOREPO_ROOT}/libcxx/cmake/caches/MinGW.cmake"
716716
check-runtimes
717717
;;
718+
mingw-incomplete-sysroot)
719+
# When bringing up a new cross compiler from scratch, we build
720+
# libunwind/libcxx in a setup where the toolchain is incomplete and
721+
# unable to perform the normal linker checks; this requires a few
722+
# special cases in the CMake files.
723+
#
724+
# Building in an incomplete setup requires setting CMAKE_*_COMPILER_WORKS,
725+
# as CMake fails to probe the compiler. This case also requires
726+
# setting CMAKE_CXX_COMPILER_TARGET, as LLVM's heuristics for setting
727+
# the triple fails when CMake hasn't been able to probe the environment.
728+
# (This is what one has to do when building the initial libunwind/libcxx
729+
# for a new toolchain.)
730+
clean
731+
generate-cmake \
732+
-DCMAKE_C_COMPILER_WORKS=TRUE \
733+
-DCMAKE_CXX_COMPILER_WORKS=TRUE \
734+
-DCMAKE_C_COMPILER_TARGET=x86_64-w64-windows-gnu \
735+
-DCMAKE_CXX_COMPILER_TARGET=x86_64-w64-windows-gnu \
736+
-C "${MONOREPO_ROOT}/libcxx/cmake/caches/MinGW.cmake"
737+
# Only test that building succeeds; there's not much extra value in running
738+
# the tests here, as it would be equivalent to the mingw-dll config above.
739+
${NINJA} -vC "${BUILD_DIR}"
740+
;;
718741
aix)
719742
clean
720743
generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/AIX.cmake" \

0 commit comments

Comments
 (0)