Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfcf1b6a

Browse files
nickdesaulniersmasahir0y
authored andcommitted
Documentation/llvm: add documentation on building w/ Clang/LLVM
Added to kbuild documentation. Provides more official info on buildingkernels with Clang and LLVM than our wiki.Suggested-by: Kees Cook <keescook@chromium.org>Reviewed-by: Kees Cook <keescook@chromium.org>Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>Reviewed-by: Sedat Dilek <sedat.dilek@gmail.com>Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
1 parenta1af8d7 commitfcf1b6a

File tree

3 files changed

+82
-0
lines changed

3 files changed

+82
-0
lines changed

‎Documentation/kbuild/index.rst‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Kernel Build System
1919

2020
issues
2121
reproducible-builds
22+
llvm
2223

2324
..only::subproject and html
2425

‎Documentation/kbuild/llvm.rst‎

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
==============================
2+
Building Linux with Clang/LLVM
3+
==============================
4+
5+
This document covers how to build the Linux kernel with Clang and LLVM
6+
utilities.
7+
8+
About
9+
-----
10+
11+
The Linux kernel has always traditionally been compiled with GNU toolchains
12+
such as GCC and binutils. Ongoing work has allowed for `Clang
13+
<https://clang.llvm.org/>`_ and `LLVM<https://llvm.org/>`_ utilities to be
14+
used as viable substitutes. Distributions such as `Android
15+
<https://www.android.com/>`_, `ChromeOS
16+
<https://www.chromium.org/chromium-os>`_, and `OpenMandriva
17+
<https://www.openmandriva.org/>`_ use Clang built kernels. `LLVM is a
18+
collection of toolchain components implemented in terms of C++ objects
19+
<https://www.aosabook.org/en/llvm.html>`_. Clang is a front-end to LLVM that
20+
supports C and the GNU C extensions required by the kernel, and is pronounced
21+
"klang," not "see-lang."
22+
23+
Clang
24+
-----
25+
26+
The compiler used can be swapped out via `CC=` command line argument to `make`.
27+
`CC=` should be set when selecting a config and during a build.
28+
29+
make CC=clang defconfig
30+
31+
make CC=clang
32+
33+
Cross Compiling
34+
---------------
35+
36+
A single Clang compiler binary will typically contain all supported backends,
37+
which can help simplify cross compiling.
38+
39+
ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make CC=clang
40+
41+
`CROSS_COMPILE` is not used to prefix the Clang compiler binary, instead
42+
`CROSS_COMPILE` is used to set a command line flag: `--target <triple>`. For
43+
example:
44+
45+
clang --target aarch64-linux-gnu foo.c
46+
47+
LLVM Utilities
48+
--------------
49+
50+
LLVM has substitutes for GNU binutils utilities. These can be invoked as
51+
additional parameters to `make`.
52+
53+
make CC=clang AS=clang LD=ld.lld AR=llvm-ar NM=llvm-nm STRIP=llvm-strip\\
54+
OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump OBJSIZE=llvm-objsize\\
55+
READELF=llvm-readelf HOSTCC=clang HOSTCXX=clang++ HOSTAR=llvm-ar\\
56+
HOSTLD=ld.lld
57+
58+
Getting Help
59+
------------
60+
61+
- `Website<https://clangbuiltlinux.github.io/>`_
62+
- `Mailing List<https://groups.google.com/forum/#!forum/clang-built-linux>`_: <clang-built-linux@googlegroups.com>
63+
- `Issue Tracker<https://github.com/ClangBuiltLinux/linux/issues>`_
64+
- IRC: #clangbuiltlinux on chat.freenode.net
65+
- `Telegram<https://t.me/ClangBuiltLinux>`_: @ClangBuiltLinux
66+
- `Wiki<https://github.com/ClangBuiltLinux/linux/wiki>`_
67+
- `Beginner Bugs<https://github.com/ClangBuiltLinux/linux/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22>`_
68+
69+
Getting LLVM
70+
-------------
71+
72+
- http://releases.llvm.org/download.html
73+
- https://github.com/llvm/llvm-project
74+
- https://llvm.org/docs/GettingStarted.html
75+
- https://llvm.org/docs/CMake.html
76+
- https://apt.llvm.org/
77+
- https://www.archlinux.org/packages/extra/x86_64/llvm/
78+
- https://github.com/ClangBuiltLinux/tc-build
79+
- https://github.com/ClangBuiltLinux/linux/wiki/Building-Clang-from-source
80+
- https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/

‎MAINTAINERS‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4119,6 +4119,7 @@ B:https://github.com/ClangBuiltLinux/linux/issues
41194119
C:irc://chat.freenode.net/clangbuiltlinux
41204120
S:Supported
41214121
K:\b(?i:clang|llvm)\b
4122+
F:Documentation/kbuild/llvm.rst
41224123

41234124
CLEANCACHE API
41244125
M:Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp