[libc-commits] [libc] [llvm] [libc][cmake][linux] require new LLVM_LIBC_USE_HOST_KERNEL_HEADERS or LIBC_KERNEL_HEADERS (PR #123820)

Nick Desaulniers via libc-commits libc-commits at lists.llvm.org
Wed Jan 29 11:31:47 PST 2025


https://github.com/nickdesaulniers updated https://github.com/llvm/llvm-project/pull/123820

>From 456a4f575649975b68bdb9d3c61dee3630ee4bbf Mon Sep 17 00:00:00 2001
From: Nick Desaulniers <ndesaulniers at google.com>
Date: Tue, 21 Jan 2025 13:07:02 -0800
Subject: [PATCH 1/6] [libc][cmake][linux] require new
 LLVM_LIBC_USE_HOST_KERNEL_HEADERS or LIBC_KERNEL_HEADERS

When cross compiling, we DO NOT want to use the host's kernel headers. Adding
all of /usr/include via `-dirafter` also isn't very hermetic since it can pull
in more than just kernel headers. But peeking at /usr/include simplifies
setting up the libc, since then the kernel headers don't have to be built from
source. (Building kernel headers from source is quite trivial though).

We already support setting -DLIBC_KERNEL_HEADERS=/path/to/kernel/headers. Add a
new boolean cmake flag, LLVM_LIBC_USE_HOST_KERNEL_HEADERS, which indicates that
the user is opting into just using the hosts kernel headers. Existing host
builds may break and need to set this.

Setting LIBC_KERNEL_HEADERS currently produces a few unit test failures that I
still need to debug, but ideally users targeting linux will always pass
LIBC_KERNEL_HEADERS in the future.

Add some checks to ensure that at least one of these flags are set, that
they're mutually exclusive, that the headers are required when cross compiling,
and that the headers path is a directory.
---
 libc/CMakeLists.txt                           |  6 +++++-
 .../cmake/modules/LLVMLibCArchitectures.cmake | 21 +++++++++++++++++++
 libc/docs/getting_started.rst                 |  1 +
 3 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt
index c061e2a05ebd8f..f78e16a50abd71 100644
--- a/libc/CMakeLists.txt
+++ b/libc/CMakeLists.txt
@@ -46,7 +46,11 @@ set(LIBC_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})
 
 set(LIBC_ENABLE_USE_BY_CLANG OFF CACHE BOOL "Whether or not to place libc in a build directory findable by a just built clang")
 
-set(LIBC_KERNEL_HEADERS "/usr/include" CACHE STRING "Path to Linux kernel headers")
+# LLVM_LIBC_USE_HOST_KERNEL_HEADERS is brittle, and frowned upon (prefer
+# setting LIBC_KERNEL_HEADERS), but is simpler from a hello world linux host
+# build.
+set(LLVM_LIBC_USE_HOST_KERNEL_HEADERS OFF CACHE BOOL "Add /usr/include to the header seach path")
+set(LIBC_KERNEL_HEADERS "" CACHE STRING "Path to Linux kernel headers")
 
 # Defining a global namespace to enclose all libc functions.
 set(default_namespace "__llvm_libc")
diff --git a/libc/cmake/modules/LLVMLibCArchitectures.cmake b/libc/cmake/modules/LLVMLibCArchitectures.cmake
index fbb1091ddabab4..8cf4dfac70e498 100644
--- a/libc/cmake/modules/LLVMLibCArchitectures.cmake
+++ b/libc/cmake/modules/LLVMLibCArchitectures.cmake
@@ -216,6 +216,27 @@ if (LIBC_TARGET_OS_IS_WINDOWS AND LLVM_LIBC_FULL_BUILD)
   message(FATAL_ERROR "Windows does not support full mode build.")
 endif ()
 
+if (LIBC_TARGET_OS_IS_LINUX)
+  if (NOT LLVM_LIBC_USE_HOST_KERNEL_HEADERS AND NOT LIBC_KERNEL_HEADERS STREQUAL "")
+    message(FATAL_ERROR "MUST specify either LIBC_KERNEL_HEADERS or LLVM_LIBC_USE_HOST_KERNEL_HEADERS")
+  endif()
+  if (LLVM_LIBC_USE_HOST_KERNEL_HEADERS AND NOT LIBC_KERNEL_HEADERS STREQUAL "")
+    message(FATAL_ERROR "LLVM_LIBC_USE_HOST_KERNEL_HEADERS and LIBC_USE_HOST_KERNEL_HEADERS are mutually exclusive")
+  endif()
+  if(LIBC_TARGET_TRIPLE AND LLVM_LIBC_USE_HOST_KERNEL_HEADERS)
+    # This is because the syscall numbers are frequently different between
+    # different target architectures. Code may compile, but you'll get spooky
+    # runtime failures.
+    message(FATAL_ERROR "LLVM_LIBC_USE_HOST_KERNEL_HEADERS should not be set when using LIBC_TARGET_TRIPLE, set LIBC_KERNEL_HEADERS instead")
+  endif()
+  if (NOT LIBC_KERNEL_HEADERS STREQUAL "" AND NOT IS_DIRECTORY LIBC_KERNEL_HEADERS)
+    message(FATAL_ERROR "LIBC_KERNEL_HEADERS should be a path to an existing directory")
+  endif()
+  if (LLVM_LIBC_USE_HOST_KERNEL_HEADERS)
+    set(LIBC_KERNEL_HEADERS "/usr/include" CACHE STRING "Path to Linux kernel headers" FORCE)
+  endif()
+endif()
+
 
 message(STATUS
         "Building libc for ${LIBC_TARGET_ARCHITECTURE} on ${LIBC_TARGET_OS} with
diff --git a/libc/docs/getting_started.rst b/libc/docs/getting_started.rst
index 51c295f384a06f..1f62d94d3c3fd5 100644
--- a/libc/docs/getting_started.rst
+++ b/libc/docs/getting_started.rst
@@ -21,6 +21,7 @@ Install dependencies first:
     -DCMAKE_CXX_COMPILER=clang++ \
     -DCMAKE_C_COMPILER=clang \
     -DLLVM_LIBC_FULL_BUILD=ON \
+    -DLLVM_LIBC_USE_HOST_KERNEL_HEADERS=ON \
     -DLLVM_LIBC_INCLUDE_SCUDO=ON \
     -DCOMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC=ON \
     -DCOMPILER_RT_BUILD_GWP_ASAN=OFF \

>From d918f8584f1c1d0f6ea3fb16f6070ae1aa335f39 Mon Sep 17 00:00:00 2001
From: Nick Desaulniers <ndesaulniers at google.com>
Date: Tue, 21 Jan 2025 13:34:18 -0800
Subject: [PATCH 2/6] set LLVM_LIBC_USE_HOST_KERNEL_HEADERS for presubmit tests

---
 .github/workflows/libc-fullbuild-tests.yml | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/.github/workflows/libc-fullbuild-tests.yml b/.github/workflows/libc-fullbuild-tests.yml
index 2c88da653aae4a..4096930b61d5f1 100644
--- a/.github/workflows/libc-fullbuild-tests.yml
+++ b/.github/workflows/libc-fullbuild-tests.yml
@@ -30,7 +30,7 @@ jobs:
           #   cpp_compiler: g++
     steps:
     - uses: actions/checkout at v4
-    
+
     # 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.
@@ -43,7 +43,7 @@ jobs:
         max-size: 1G
         key: libc_fullbuild_${{ matrix.c_compiler }}
         variant: ${{ matrix.ccache-variant }}
-    
+
     # Notice:
     # - MPFR is required by some of the mathlib tests.
     # - Debian has a multilib setup, so we need to symlink the asm directory.
@@ -60,7 +60,7 @@ jobs:
       run: |
         echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
         echo "build-install-dir=${{ github.workspace }}/install" >> "$GITHUB_OUTPUT"
-    
+
     # Configure libc fullbuild with scudo.
     # Use MinSizeRel to reduce the size of the build.
     - name: Configure CMake
@@ -74,6 +74,7 @@ jobs:
         -DCMAKE_INSTALL_PREFIX=${{ steps.strings.outputs.build-install-dir }}
         -DLLVM_ENABLE_RUNTIMES="libc;compiler-rt"
         -DLLVM_LIBC_FULL_BUILD=ON
+        -DLLVM_LIBC_USE_HOST_KERNEL_HEADERS=ON
         -DLLVM_LIBC_INCLUDE_SCUDO=ON
         -DCOMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC=ON
         -DCOMPILER_RT_BUILD_GWP_ASAN=OFF
@@ -83,14 +84,14 @@ jobs:
 
     - name: Build
       run: >
-        cmake 
-        --build ${{ steps.strings.outputs.build-output-dir }} 
+        cmake
+        --build ${{ steps.strings.outputs.build-output-dir }}
         --parallel
         --target install
 
     - name: Test
       run: >
-        cmake 
-        --build ${{ steps.strings.outputs.build-output-dir }} 
+        cmake
+        --build ${{ steps.strings.outputs.build-output-dir }}
         --parallel
         --target check-libc

>From e2c259da9cc0201a36048fe6de39f1ac279c9842 Mon Sep 17 00:00:00 2001
From: Nick Desaulniers <ndesaulniers at google.com>
Date: Wed, 29 Jan 2025 10:01:38 -0800
Subject: [PATCH 3/6] drop LLVM_ prefix from option name

---
 libc/CMakeLists.txt                            |  4 ++--
 libc/cmake/modules/LLVMLibCArchitectures.cmake | 16 ++++++++--------
 libc/docs/getting_started.rst                  |  2 +-
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt
index f78e16a50abd71..4866fa908ee89d 100644
--- a/libc/CMakeLists.txt
+++ b/libc/CMakeLists.txt
@@ -46,10 +46,10 @@ set(LIBC_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})
 
 set(LIBC_ENABLE_USE_BY_CLANG OFF CACHE BOOL "Whether or not to place libc in a build directory findable by a just built clang")
 
-# LLVM_LIBC_USE_HOST_KERNEL_HEADERS is brittle, and frowned upon (prefer
+# LIBC_USE_HOST_KERNEL_HEADERS is brittle, and frowned upon (prefer
 # setting LIBC_KERNEL_HEADERS), but is simpler from a hello world linux host
 # build.
-set(LLVM_LIBC_USE_HOST_KERNEL_HEADERS OFF CACHE BOOL "Add /usr/include to the header seach path")
+set(LIBC_USE_HOST_KERNEL_HEADERS OFF CACHE BOOL "Add /usr/include to the header seach path")
 set(LIBC_KERNEL_HEADERS "" CACHE STRING "Path to Linux kernel headers")
 
 # Defining a global namespace to enclose all libc functions.
diff --git a/libc/cmake/modules/LLVMLibCArchitectures.cmake b/libc/cmake/modules/LLVMLibCArchitectures.cmake
index 8cf4dfac70e498..e02820fed0aa78 100644
--- a/libc/cmake/modules/LLVMLibCArchitectures.cmake
+++ b/libc/cmake/modules/LLVMLibCArchitectures.cmake
@@ -217,22 +217,22 @@ if (LIBC_TARGET_OS_IS_WINDOWS AND LLVM_LIBC_FULL_BUILD)
 endif ()
 
 if (LIBC_TARGET_OS_IS_LINUX)
-  if (NOT LLVM_LIBC_USE_HOST_KERNEL_HEADERS AND NOT LIBC_KERNEL_HEADERS STREQUAL "")
-    message(FATAL_ERROR "MUST specify either LIBC_KERNEL_HEADERS or LLVM_LIBC_USE_HOST_KERNEL_HEADERS")
+  if (NOT LIBC_USE_HOST_KERNEL_HEADERS AND "${LIBC_KERNEL_HEADERS}" STREQUAL "")
+    message(FATAL_ERROR "MUST specify either LIBC_KERNEL_HEADERS or LIBC_USE_HOST_KERNEL_HEADERS")
   endif()
-  if (LLVM_LIBC_USE_HOST_KERNEL_HEADERS AND NOT LIBC_KERNEL_HEADERS STREQUAL "")
-    message(FATAL_ERROR "LLVM_LIBC_USE_HOST_KERNEL_HEADERS and LIBC_USE_HOST_KERNEL_HEADERS are mutually exclusive")
+  if (LIBC_USE_HOST_KERNEL_HEADERS AND NOT "${LIBC_KERNEL_HEADERS}" STREQUAL "")
+    message(FATAL_ERROR "LIBC_USE_HOST_KERNEL_HEADERS and LIBC_USE_HOST_KERNEL_HEADERS are mutually exclusive")
   endif()
-  if(LIBC_TARGET_TRIPLE AND LLVM_LIBC_USE_HOST_KERNEL_HEADERS)
+  if(LIBC_TARGET_TRIPLE AND LIBC_USE_HOST_KERNEL_HEADERS)
     # This is because the syscall numbers are frequently different between
     # different target architectures. Code may compile, but you'll get spooky
     # runtime failures.
-    message(FATAL_ERROR "LLVM_LIBC_USE_HOST_KERNEL_HEADERS should not be set when using LIBC_TARGET_TRIPLE, set LIBC_KERNEL_HEADERS instead")
+    message(FATAL_ERROR "LIBC_USE_HOST_KERNEL_HEADERS should not be set when using LIBC_TARGET_TRIPLE, set LIBC_KERNEL_HEADERS instead")
   endif()
-  if (NOT LIBC_KERNEL_HEADERS STREQUAL "" AND NOT IS_DIRECTORY LIBC_KERNEL_HEADERS)
+  if (NOT "${LIBC_KERNEL_HEADERS}" STREQUAL "" AND NOT IS_DIRECTORY "${LIBC_KERNEL_HEADERS}")
     message(FATAL_ERROR "LIBC_KERNEL_HEADERS should be a path to an existing directory")
   endif()
-  if (LLVM_LIBC_USE_HOST_KERNEL_HEADERS)
+  if (LIBC_USE_HOST_KERNEL_HEADERS)
     set(LIBC_KERNEL_HEADERS "/usr/include" CACHE STRING "Path to Linux kernel headers" FORCE)
   endif()
 endif()
diff --git a/libc/docs/getting_started.rst b/libc/docs/getting_started.rst
index 1f62d94d3c3fd5..e6b9c5a8ed8e8f 100644
--- a/libc/docs/getting_started.rst
+++ b/libc/docs/getting_started.rst
@@ -20,8 +20,8 @@ Install dependencies first:
     -DCMAKE_BUILD_TYPE=Debug \
     -DCMAKE_CXX_COMPILER=clang++ \
     -DCMAKE_C_COMPILER=clang \
+    -DLIBC_USE_HOST_KERNEL_HEADERS=ON \
     -DLLVM_LIBC_FULL_BUILD=ON \
-    -DLLVM_LIBC_USE_HOST_KERNEL_HEADERS=ON \
     -DLLVM_LIBC_INCLUDE_SCUDO=ON \
     -DCOMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC=ON \
     -DCOMPILER_RT_BUILD_GWP_ASAN=OFF \

>From 76e422c57e63fc24e065c1ab74a49a45afaaac84 Mon Sep 17 00:00:00 2001
From: Nick Desaulniers <ndesaulniers at google.com>
Date: Wed, 29 Jan 2025 10:07:46 -0800
Subject: [PATCH 4/6] switch set BOOL to option

---
 libc/CMakeLists.txt | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt
index 4866fa908ee89d..9571655d21dbe2 100644
--- a/libc/CMakeLists.txt
+++ b/libc/CMakeLists.txt
@@ -46,10 +46,9 @@ set(LIBC_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})
 
 set(LIBC_ENABLE_USE_BY_CLANG OFF CACHE BOOL "Whether or not to place libc in a build directory findable by a just built clang")
 
-# LIBC_USE_HOST_KERNEL_HEADERS is brittle, and frowned upon (prefer
-# setting LIBC_KERNEL_HEADERS), but is simpler from a hello world linux host
-# build.
-set(LIBC_USE_HOST_KERNEL_HEADERS OFF CACHE BOOL "Add /usr/include to the header seach path")
+# LIBC_USE_HOST_KERNEL_HEADERS is brittle, and frowned upon (prefer setting
+# LIBC_KERNEL_HEADERS), but is simpler from a hello world linux host build.
+option(LIBC_USE_HOST_KERNEL_HEADERS "Add /usr/include to the header seach path" OFF)
 set(LIBC_KERNEL_HEADERS "" CACHE STRING "Path to Linux kernel headers")
 
 # Defining a global namespace to enclose all libc functions.

>From d4c49a6c94b614a668cd0d5dac63413538400b74 Mon Sep 17 00:00:00 2001
From: Nick Desaulniers <ndesaulniers at google.com>
Date: Wed, 29 Jan 2025 10:56:21 -0800
Subject: [PATCH 5/6] moar docs

---
 libc/docs/full_cross_build.rst |  7 +++++++
 libc/docs/full_host_build.rst  | 12 +++++++++++-
 libc/docs/overlay_mode.rst     |  2 ++
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/libc/docs/full_cross_build.rst b/libc/docs/full_cross_build.rst
index cd1ec89e5d5e90..473a2a5a7ee63c 100644
--- a/libc/docs/full_cross_build.rst
+++ b/libc/docs/full_cross_build.rst
@@ -59,6 +59,7 @@ Below is the CMake command to configure the standalone crossbuild of the libc.
   $> cd build
   $> C_COMPILER=<C compiler> # For example "clang"
   $> CXX_COMPILER=<C++ compiler> # For example "clang++"
+  $> KERNEL_HEADERS=<path/to/built/linux/kernel/headers>
   $> cmake ../runtimes  \
      -G Ninja \
      -DLLVM_ENABLE_RUNTIMES=libc  \
@@ -66,6 +67,7 @@ Below is the CMake command to configure the standalone crossbuild of the libc.
      -DCMAKE_CXX_COMPILER=$CXX_COMPILER \
      -DLLVM_LIBC_FULL_BUILD=ON \
      -DLIBC_TARGET_TRIPLE=<Your target triple> \
+     -DLIBC_KERNEL_HEADERS=$KERNEL_HEADERS \
      -DCMAKE_BUILD_TYPE=<Release|Debug>
 
 We will go over the special options passed to the ``cmake`` command above.
@@ -77,6 +79,10 @@ We will go over the special options passed to the ``cmake`` command above.
 * **The target triple** - This is the target triple of the target for which
   we are building the libc. For example, for a Linux 32-bit Arm target,
   one can specify it as ``arm-linux-eabi``.
+* **The path to the kernel headers** - (Optional) Necessary when targeting
+  Linux. The Linux kernel headers are architecture specific and should be built
+  from source. See :ref:`linux_headers` section for how to build the Linux
+  kernel headers from source.
 
 Build step
 ----------
@@ -116,6 +122,7 @@ CMake configure step
      -DLLVM_ENABLE_PROJECTS=clang \
      -DLLVM_ENABLE_RUNTIMES=libc \
      -DLLVM_LIBC_FULL_BUILD=ON \
+     -DLIBC_KERNEL_HEADERS=$KERNEL_HEADERS \
      -DLLVM_RUNTIME_TARGETS=$TARGET_TRIPLE \
      -DCMAKE_BUILD_TYPE=Debug
 
diff --git a/libc/docs/full_host_build.rst b/libc/docs/full_host_build.rst
index 12aacf181695a9..8fbe1fee3c5207 100644
--- a/libc/docs/full_host_build.rst
+++ b/libc/docs/full_host_build.rst
@@ -28,6 +28,10 @@ development. In this we've set the Ninja generator, set the build type to
 "Debug", and enabled the Scudo allocator. This build also enables generating the
 documentation and verbose cmake logging, which are useful development features.
 
+If targeting Linux, see :ref:`linux_headers` for how to build the Linux kernel
+headers from source, which llvm-libc will depend on. If not targeting Linux,
+the below cmake variable ``LIBC_KERNEL_HEADERS`` should be omitted.
+
 .. note::
    if your build fails with an error saying the compiler can't find
    ``<asm/unistd.h>`` or similar then you're probably missing the symlink from
@@ -50,6 +54,7 @@ documentation and verbose cmake logging, which are useful development features.
       -DLLVM_LIBC_FULL_BUILD=ON \
       -DCMAKE_BUILD_TYPE=Debug \
       -DLLVM_LIBC_INCLUDE_SCUDO=ON \
+      -DLLVM_LIBC_KERNEL_HEADERS=/path/to/kernel/headers/ \
       -DCOMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC=ON \
       -DCOMPILER_RT_BUILD_GWP_ASAN=OFF                       \
       -DCOMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED=OFF        \
@@ -133,6 +138,7 @@ allocator for LLVM-libc.
       -DCMAKE_CXX_COMPILER=clang++ \
       -DLLVM_LIBC_FULL_BUILD=ON \
       -DLLVM_LIBC_INCLUDE_SCUDO=ON \
+      -DLLVM_LIBC_KERNEL_HEADERS=/path/to/kernel/headers/ \
       -DCOMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC=ON \
       -DCOMPILER_RT_BUILD_GWP_ASAN=OFF                       \
       -DCOMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED=OFF        \
@@ -171,6 +177,8 @@ toolchain with which you can build practical/real-world C applications. See
 `<https://github.com/llvm/llvm-project/tree/main/libc/examples>`_ for examples
 of how to start using this new toolchain.
 
+.. _linux_headers:
+
 Linux Headers
 =============
 
@@ -183,7 +191,9 @@ Linux headers in your sysroot.  Let's build them from source.
    $> make LLVM=1 INSTALL_HDR_PATH=/path/to/sysroot -C /tmp/linux headers_install
 
 The headers can be built to target non-host architectures by adding the
-``ARCH={arm|arm64|i386}`` to the above invocation of ``make``.
+``ARCH={arm|arm64|i386}`` to the above invocation of ``make``. Then you should
+set the cmake variable `-DLIBC_KERNEL_HEADERS=/path/to/sysroot` when
+configuring llvm-libc.
 
 Using your newly built libc
 ===========================
diff --git a/libc/docs/overlay_mode.rst b/libc/docs/overlay_mode.rst
index ca04c4c7674a3e..9134af611a9fae 100644
--- a/libc/docs/overlay_mode.rst
+++ b/libc/docs/overlay_mode.rst
@@ -40,6 +40,7 @@ building it with the following cmake command:
   $> mkdir build
   $> cd build
   $> cmake ../runtimes -G Ninja -DLLVM_ENABLE_RUNTIMES="libc"  \
+     -LIBC_USE_HOST_KERNEL_HEADERS=ON \
      -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
      -DCMAKE_BUILD_TYPE=<Debug|Release>                    \  # Select build type
      -DCMAKE_INSTALL_PREFIX=<Your prefix of choice>           # Optional
@@ -78,6 +79,7 @@ performance possible.
 
   $> cmake ../llvm -G Ninja -DLLVM_ENABLE_PROJECTS="clang" \
      -DLLVM_ENABLE_RUNTIMES="libc"  \  # libc is listed as runtime and not as a project
+     -DLIBC_USE_HOST_KERNEL_HEADERS=ON \
      -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
      -DCMAKE_BUILD_TYPE=<Debug|Release>                    \  # Select build type
      -DCMAKE_INSTALL_PREFIX=<Your prefix of choice>           # Optional

>From db5b2f90127b213900db0616705d365f4e29cf9f Mon Sep 17 00:00:00 2001
From: Nick Desaulniers <ndesaulniers at google.com>
Date: Wed, 29 Jan 2025 11:31:24 -0800
Subject: [PATCH 6/6] fixup cmake var name and path

---
 .github/workflows/libc-fullbuild-tests.yml | 2 +-
 libc/docs/full_cross_build.rst             | 2 +-
 libc/docs/full_host_build.rst              | 8 ++++----
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/.github/workflows/libc-fullbuild-tests.yml b/.github/workflows/libc-fullbuild-tests.yml
index 4096930b61d5f1..7bc4622c7ff3d4 100644
--- a/.github/workflows/libc-fullbuild-tests.yml
+++ b/.github/workflows/libc-fullbuild-tests.yml
@@ -73,8 +73,8 @@ jobs:
         -DCMAKE_CXX_COMPILER_LAUNCHER=${{ matrix.ccache-variant }}
         -DCMAKE_INSTALL_PREFIX=${{ steps.strings.outputs.build-install-dir }}
         -DLLVM_ENABLE_RUNTIMES="libc;compiler-rt"
+        -DLIBC_USE_HOST_KERNEL_HEADERS=ON
         -DLLVM_LIBC_FULL_BUILD=ON
-        -DLLVM_LIBC_USE_HOST_KERNEL_HEADERS=ON
         -DLLVM_LIBC_INCLUDE_SCUDO=ON
         -DCOMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC=ON
         -DCOMPILER_RT_BUILD_GWP_ASAN=OFF
diff --git a/libc/docs/full_cross_build.rst b/libc/docs/full_cross_build.rst
index 473a2a5a7ee63c..ce4e67ac80f16a 100644
--- a/libc/docs/full_cross_build.rst
+++ b/libc/docs/full_cross_build.rst
@@ -119,10 +119,10 @@ CMake configure step
      -G Ninja \
      -DCMAKE_C_COMPILER=$C_COMPILER \
      -DCMAKE_CXX_COMPILER=$CXX_COMPILER \
+     -DLIBC_KERNEL_HEADERS=$KERNEL_HEADERS \
      -DLLVM_ENABLE_PROJECTS=clang \
      -DLLVM_ENABLE_RUNTIMES=libc \
      -DLLVM_LIBC_FULL_BUILD=ON \
-     -DLIBC_KERNEL_HEADERS=$KERNEL_HEADERS \
      -DLLVM_RUNTIME_TARGETS=$TARGET_TRIPLE \
      -DCMAKE_BUILD_TYPE=Debug
 
diff --git a/libc/docs/full_host_build.rst b/libc/docs/full_host_build.rst
index 8fbe1fee3c5207..dbe03c6812b248 100644
--- a/libc/docs/full_host_build.rst
+++ b/libc/docs/full_host_build.rst
@@ -48,13 +48,13 @@ the below cmake variable ``LIBC_KERNEL_HEADERS`` should be omitted.
    $> cd build
    $> cmake ../runtimes \
       -G Ninja \
-      -DCMAKE_C_COMPILER=clang \
+      -DCMAKE_BUILD_TYPE=Debug \
       -DCMAKE_CXX_COMPILER=clang++ \
+      -DCMAKE_C_COMPILER=clang \
       -DLLVM_ENABLE_RUNTIMES="libc;compiler-rt" \
+      -DLIBC_KERNEL_HEADERS=/path/to/sysroot/ \
       -DLLVM_LIBC_FULL_BUILD=ON \
-      -DCMAKE_BUILD_TYPE=Debug \
       -DLLVM_LIBC_INCLUDE_SCUDO=ON \
-      -DLLVM_LIBC_KERNEL_HEADERS=/path/to/kernel/headers/ \
       -DCOMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC=ON \
       -DCOMPILER_RT_BUILD_GWP_ASAN=OFF                       \
       -DCOMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED=OFF        \
@@ -136,9 +136,9 @@ allocator for LLVM-libc.
       -DCMAKE_BUILD_TYPE=Release  \
       -DCMAKE_C_COMPILER=clang \
       -DCMAKE_CXX_COMPILER=clang++ \
+      -DLIBC_KERNEL_HEADERS=/path/to/sysroot/ \
       -DLLVM_LIBC_FULL_BUILD=ON \
       -DLLVM_LIBC_INCLUDE_SCUDO=ON \
-      -DLLVM_LIBC_KERNEL_HEADERS=/path/to/kernel/headers/ \
       -DCOMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC=ON \
       -DCOMPILER_RT_BUILD_GWP_ASAN=OFF                       \
       -DCOMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED=OFF        \



More information about the libc-commits mailing list