[libc-commits] [libc] [libc][docs] update docs on how to build linux kernel headers from src (PR #122381)

Nick Desaulniers via libc-commits libc-commits at lists.llvm.org
Thu Jan 9 14:16:52 PST 2025


https://github.com/nickdesaulniers created https://github.com/llvm/llvm-project/pull/122381

It's simpler than the directions we have; which are very very Debian specific.


>From 7836724dd943a2a608534b5a96e74a5df0952fcb Mon Sep 17 00:00:00 2001
From: Nick Desaulniers <ndesaulniers at google.com>
Date: Thu, 9 Jan 2025 14:08:58 -0800
Subject: [PATCH] [libc][docs] update docs on how to build linux kernel headers
 from src

It's simpler than the directions we have; which are very very Debian specific.
---
 libc/docs/full_host_build.rst | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/libc/docs/full_host_build.rst b/libc/docs/full_host_build.rst
index e25079141f47b2..12aacf181695a9 100644
--- a/libc/docs/full_host_build.rst
+++ b/libc/docs/full_host_build.rst
@@ -175,17 +175,15 @@ Linux Headers
 =============
 
 If you are using the full libc on Linux, then you will also need to install
-Linux headers in your sysroot.  The way to do this varies per system.
-
-These instructions should work on a Debian-based x86_64 system:
+Linux headers in your sysroot.  Let's build them from source.
 
 .. code-block:: sh
 
-   $> apt download linux-libc-dev
-   $> dpkg -x linux-libc-dev*deb .
-   $> cp -r usr/* /path/to/sysroot/
-   $> rm -r usr linux-libc-dev*deb
-   $> ln -s /path/to/sysroot/include/x86_64-linux-gnu/asm /path/to/sysroot/include/asm
+   $> git clone --depth=1 git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git /tmp/linux
+   $> 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``.
 
 Using your newly built libc
 ===========================



More information about the libc-commits mailing list