Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LLVM + CLANG 18 support #3

Merged
merged 152 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
152 commits
Select commit Hold shift + click to select a range
cbdfd08
MAINTAINERS: add CLANG/LLVM BUILD SUPPORT info
nickdesaulniers Jun 28, 2019
f956227
Documentation/llvm: add documentation on building w/ Clang/LLVM
nickdesaulniers Feb 26, 2020
489d67a
Documentation/llvm: fix the name of llvm-size
MaskRay Apr 2, 2020
eacb8e6
kbuild: mark prepare0 as PHONY to fix external module build
masahir0y Jan 15, 2019
4da0540
Makefile: remove CCACHE for now
ExtremeXT Apr 7, 2024
e103f5c
kbuild: add OBJSIZE variable for the size tool
Jan 21, 2019
b8c5c12
x86/boot: kbuild: allow readelf executable to be specified
tpimh Dec 4, 2019
4eee345
net: wan: wanxl: use allow to pass CROSS_COMPILE_M68k for rebuilding …
masahir0y Mar 26, 2020
0bb3204
net: wan: wanxl: use $(M68KCC) instead of $(M68KAS) for rebuilding fi…
masahir0y Mar 26, 2020
50782e4
kbuild: remove AS variable
masahir0y Mar 26, 2020
5682290
kbuild: replace AS=clang with LLVM_IAS=1
masahir0y Apr 8, 2020
aaa9aeb
kbuild: support LLVM=1 to switch the default tools to Clang/LLVM
masahir0y Apr 8, 2020
1998eec
FROMLIST: Kbuild: do not emit debug info for assembly with LLVM_IAS=1
nickdesaulniers Nov 9, 2020
175cd42
x86/lib: Change .weak to SYM_FUNC_START_WEAK for arch/x86/lib/mem*_64.S
MaskRay Nov 3, 2020
3f4bd6c
arm64: lse: fix LSE atomics with LLVM's integrated assembler
samitolvanen Oct 31, 2019
5e813c6
Makefile: Move -Wno-unused-but-set-variable out of GCC only block
nathanchance Apr 29, 2021
87ac800
fortify: Explicitly disable Clang support
kees May 13, 2021
4083f75
Makefile.debug: re-enable debug info for .S files
nickdesaulniers Oct 24, 2022
168deaa
perf llvm: Return -ENOMEM when asprintf() fails
acmel Jul 1, 2021
8bc1b89
perf llvm: Fix inadvertent file creation
captain5050 Jan 5, 2023
3de3ffd
BACKPORT: arm64: Fix minor issues with the dcache_by_line_op macro
wildea01 Dec 10, 2018
de20965
BACKPORT: crypto: arm64/aes-modes - get rid of literal load of addend…
Aug 23, 2018
1f088a4
crypto: arm64/aes-ce-cipher - match round key endianness with generic…
Jul 24, 2017
e4fae0c
BACKPORT: crypto: arm64/aes-ce-cipher - move assembler code to .S file
Nov 21, 2017
4d7b3ef
FROMLIST: Makefile: lld: tell clang to use lld
nickdesaulniers Jan 31, 2019
659312d
arm64: add endianness option to LDFLAGS instead of LD
masahir0y Jul 3, 2018
5ebd64f
arm64: build with baremetal linker target instead of Linux when avail…
olofj Jul 13, 2018
89261c6
FROMLIST: Makefile: lld: set -O2 linker flag when linking with LLD
nickdesaulniers Feb 11, 2019
54b2464
kbuild: clear LDFLAGS in the top Makefile
masahir0y Jun 21, 2020
cce748a
BACKPORT: arm64: Change .weak to SYM_FUNC_START_WEAK_PI for arch/arm6…
MaskRay Oct 29, 2020
7f85d91
arm64: relocatable: fix inconsistencies in linker script and options
Dec 3, 2018
a9b5228
Makefile: Enable MLGO for register allocation
xxmustafacooTR Aug 5, 2024
8b95f94
kbuild: Add support for LLVM's Polly optimizer
halibw Aug 5, 2024
80ef57c
Makefile: llvm / poly optimize flags
xxmustafacooTR Feb 23, 2024
b758a8e
Makefile: Exynos9810 mtunes
xxmustafacooTR Aug 8, 2024
b64394e
defconfig: set pstore compression to LZO-RLE
xxmustafacooTR May 24, 2023
240e387
MAINTAINERS: add CLANG/LLVM BUILD SUPPORT info
nickdesaulniers Jun 28, 2019
d2c9f44
Documentation/llvm: add documentation on building w/ Clang/LLVM
nickdesaulniers Feb 26, 2020
f9df9a9
Documentation/llvm: fix the name of llvm-size
MaskRay Apr 2, 2020
f805e69
kbuild: add OBJSIZE variable for the size tool
Jan 21, 2019
5d2b064
x86/boot: kbuild: allow readelf executable to be specified
tpimh Dec 4, 2019
8a30e0c
net: wan: wanxl: use allow to pass CROSS_COMPILE_M68k for rebuilding …
masahir0y Mar 26, 2020
00200f7
net: wan: wanxl: use $(M68KCC) instead of $(M68KAS) for rebuilding fi…
masahir0y Mar 26, 2020
ad9225c
kbuild: remove AS variable
masahir0y Mar 26, 2020
c656ff2
kbuild: replace AS=clang with LLVM_IAS=1
masahir0y Apr 8, 2020
b77b246
kbuild: support LLVM=1 to switch the default tools to Clang/LLVM
masahir0y Apr 8, 2020
4f996ad
FROMLIST: Kbuild: do not emit debug info for assembly with LLVM_IAS=1
nickdesaulniers Nov 9, 2020
2e6b994
Makefile: Move -Wno-unused-but-set-variable out of GCC only block
nathanchance Apr 29, 2021
f256deb
Makefile.debug: re-enable debug info for .S files
nickdesaulniers Oct 24, 2022
e68f6fd
perf llvm: Return -ENOMEM when asprintf() fails
acmel Jul 1, 2021
54514ab
perf llvm: Fix inadvertent file creation
captain5050 Jan 5, 2023
62a70e0
arm64: add endianness option to LDFLAGS instead of LD
masahir0y Jul 3, 2018
3da8deb
arm64: build with baremetal linker target instead of Linux when avail…
olofj Jul 13, 2018
295a97a
FROMLIST: Makefile: lld: set -O2 linker flag when linking with LLD
nickdesaulniers Feb 11, 2019
268306e
Makefile: Enable MLGO for register allocation
xxmustafacooTR Aug 5, 2024
08bad4a
kbuild: Add support for LLVM's Polly optimizer
halibw Aug 5, 2024
7170ade
Makefile: Make CROSS_COMPILE optional
ghazzor Aug 6, 2024
a1567c7
Makefile: llvm / poly optimize flags
xxmustafacooTR Feb 23, 2024
9d62408
FROMLIST: Makefile: lld: set -O2 linker flag when linking with LLD
nickdesaulniers Feb 11, 2019
ce32644
kbuild: allow lld to be used with CONFIG_LTO_CLANG
samitolvanen Feb 12, 2019
34ec5d0
Makefile: Globally disable compound-token-split-by-space warnings for…
0ctobot Aug 31, 2020
2b7627e
ANDROID: kbuild: limit LTO inlining
samitolvanen Dec 4, 2019
b78ade1
ANDROID: kbuild: merge module sections with LTO
samitolvanen Dec 3, 2019
700b010
ANDROID: kbuild: fix module linker script flags for LTO
samitolvanen Mar 17, 2020
40f3fae
Makefile: Set --lto-O3 LLD linker flag when building with clang LTO
kdrag0n Feb 18, 2019
42d4a26
Revert "kbuild: disable clang's default use of -fmerge-all-constants"
nickdesaulniers Oct 13, 2020
2a3e917
Makefile: evaluate LDFLAGS_BUILD_ID only once
vitkyrka Apr 30, 2017
5374533
kbuild: test --build-id linker flag by ld-option instead of cc-ldoption
masahir0y Feb 23, 2018
e8a650b
kbuild: Remove -Wno-format-invalid-specifier from clang block
nathanchance Aug 16, 2021
93eb556
ANDROID: scripts/Kbuild: avoid <<< for dash shell
nickdesaulniers Mar 21, 2019
d90ccbf
ANDROID: modpost: filter function/data section ldflags
nickdesaulniers Dec 13, 2018
8d714df
Fix build break for Argument list too long
Jul 26, 2019
4d3cfff
kbuild: rename LDFLAGS to KBUILD_LDFLAGS
masahir0y Aug 23, 2018
ada2796
Revert "Makefile: Set --lto-O3 LLD linker flag when building with cla…
halibw Jun 26, 2022
05b0f40
Makefile: evaluate LDFLAGS_BUILD_ID only once
vitkyrka Apr 30, 2017
16a7d67
kbuild: test --build-id linker flag by ld-option instead of cc-ldoption
masahir0y Feb 23, 2018
7ac0c41
scripts: Support a custom compiler name
frap129 Dec 26, 2017
95ee081
BACKPORT: FROMGIT: kbuild: mkcompile_h: Include $LD version in /proc/…
kees Apr 2, 2020
851ee42
Kbuild: add support for ThinLTO
samitolvanen Aug 1, 2019
1180859
scripts/kallsyms: filter arm64's __efistub_ symbols
Mar 1, 2018
fce7754
ANDROID: kbuild: don't select LD_DEAD_CODE_DATA_ELIMINATION with LTO
samitolvanen Apr 30, 2020
b701938
arm64: allow ThinLTO to be selected
samitolvanen Aug 6, 2019
196f897
ANDROID: Makefile: set -Qunused-arguments sooner
ouroboros420 Jun 23, 2022
e64d8f9
drivers: tty: serial: disable LTO for samsung.o
dylanneve1 Apr 25, 2023
8f6da47
arch: arm64: kernel: Disable LTO for cpufeature
libxzr Apr 18, 2023
aaa0b2d
configs: exynos9810: enable LTO_CLANG
dylanneve1 Aug 8, 2024
ecce222
lkdtm: support llvm-objcopy
nickdesaulniers May 15, 2019
ceef859
BACKPORT: kbuild: replace AS=clang with LLVM_IAS=1
nickdesaulniers Aug 8, 2024
330be7e
ANDROID: arm64: vdso: guard against -Wl,-n
nickdesaulniers Jan 31, 2019
b464e21
arm64: support __int128 on gcc 5+
zx2c4 Nov 3, 2017
131e85a
arm64: support __int128 with clang
zx2c4 Dec 23, 2017
3580fd7
BACKPORT: arm64: Add support for relocating the kernel with RELR relo…
pcc Aug 1, 2019
53d3b96
mm, page_alloc: double zone's batchsize
Aug 17, 2018
19ee85b
arm64: Implement __lshrti3 library function
zx2c4 Nov 7, 2017
1d66ad8
UPSTREAM: arm64: make label allocation style consistent in tishift
zx2c4 Nov 7, 2017
c7c7e8b
arm64 / memchr : Optimize memchr routines
raphielscape Aug 10, 2019
1f2caa2
arm64 / lib ; Optimize strlen routines
raphielscape Aug 11, 2019
5692a0e
arm64: lib: strcmp: Optimized string routines for AArch64
Haseo97 Aug 13, 2019
d96162f
arm64: lib: strncmp: Optimized string routines for AArch64
Haseo97 Aug 13, 2019
b40170e
arm64: lib: strlen: Optimized string routines for AArch64
Haseo97 Aug 13, 2019
97a24bc
arm64: lib: strnlen: Optimized string routines for AArch64
Haseo97 Aug 13, 2019
52d5381
arm64: lib: memchr: Optimized string routines for AArch64
Haseo97 Aug 13, 2019
db8153c
UPSTREAM: arm64/lib: copy_page: use consistent prefetch stride
samitolvanen Apr 3, 2018
0eb0fdb
FROMLIST: arm64/lib: copy_page: avoid x18 register in assembler code
samitolvanen Apr 3, 2018
e6bed56
arm64: Don't inline __const_udelay
nine7nine Aug 13, 2018
2e58693
FROMGIT: arm64: export tishift functions to modules
zx2c4 Apr 27, 2018
cd02ff6
arm64/lib: add accelerated crc32 routines
Aug 27, 2018
0f55bc9
arm64/lib: improve CRC32 performance for deep pipelines
Nov 27, 2018
9a36b04
arm64: crc32: always assume ARM64_HAS_CRC32
arter97 Mar 13, 2019
7babec4
arm64: lse: Pass -fomit-frame-pointer to out-of-line ll/sc atomics
wildea01 Feb 9, 2018
2e251f8
arm64: avoid instrumenting atomic_ll_sc.o
Apr 27, 2018
6443922
arm64: crypto: add NEON accelerated XOR implementation
JackieLiu1 Dec 4, 2018
93a9e00
arm64: lib: memory utilities optimization
Apr 21, 2015
9365128
gcc-lto/xor-neon: Disable LTO & -fwhole-program for xor-neon
THEBOSS619 May 2, 2020
b65b757
ANDROID: arm64: add atomic_ll_sc.o to obj-y if using lld
samitolvanen Feb 12, 2019
bd6d0d9
arm64: Import optimized strrchr from newlib
frap129 Aug 14, 2017
07962e4
arm64/lib: add accelerated do_csum for arm64
fshh520 Jan 4, 2019
d61bb7c
arm64: Implement optimised checksum routine
rmurphy-arm Jan 15, 2020
a6fa88e
arm64/checksum: rename do_cum to differentiate different checksum rou…
THEBOSS619 Jul 17, 2020
487cb30
arm64: lib: Bring is some fixes in routines optimization
THEBOSS619 Aug 25, 2020
3dce600
lib/crc: Move polynomial definition to separate header
krzk Jul 17, 2018
35e19da
lib/crc: Use consistent naming for CRC-32 polynomials
krzk Jul 17, 2018
26a77fe
configs: exynos9810: enable CONFIG_LLVM_POLLY
dylanneve1 Aug 9, 2024
f7fdb2d
scripts: Makefile: suppress DTC compiler warnings
jesec Oct 14, 2020
be7911d
ANDROID: use non-canonical CFI jump tables
samitolvanen Nov 20, 2019
2fd8ea0
ANDROID: kbuild: ensure __cfi_check is correctly aligned
samitolvanen Mar 31, 2020
372cbe2
crypto: aes-ce-glue: fix redefinition of '__cfi_aes_cipher_encrypt'
xxmustafacooTR May 14, 2023
df58da8
.gitignore: add scripts/module-lto.lds
xxmustafacooTR May 14, 2023
be1ec3f
BACKPORT: arm64: vdso: use $(LD) instead of $(CC) to link VDSO
masahir0y May 29, 2020
7460460
BACKPORT: arm64: vdso: Explicitly add build-id option
labbott May 29, 2020
b146579
Add support for Unified LTO Bitcode Frontend
xxmustafacooTR Jul 24, 2023
b63653c
drivers: soc: samsung: acpm: disable lto
xxmustafacooTR Jan 24, 2024
825785d
arch: arm64: configs: Enable CONFIG_RELR
arthefaz Apr 19, 2023
ae28651
arm64: support __int128 on gcc 5+
zx2c4 Nov 3, 2017
08a309e
arm64: Implement __lshrti3 library function
zx2c4 Nov 7, 2017
c74d20a
UPSTREAM: arm64: make label allocation style consistent in tishift
zx2c4 Nov 7, 2017
64f7800
FROMGIT: arm64: export tishift functions to modules
zx2c4 Apr 27, 2018
dc99f77
configs: exynos9810: enable ARCH_HAS_RELR
ananjaser1211 Aug 9, 2024
a0faf33
scripts: mkcompile_h: fix long CC name issues
xxmustafacooTR Aug 9, 2024
b30a45f
Makefile: add optimizations, disable CUDA LLVM and misc
ananjaser1211 Aug 9, 2024
85666ca
scripts: import makefile.clang from DS
duhansysl Sep 30, 2024
1bc1f02
arm64: vdso: remove commas between macro name and arguments
jcai19 May 6, 2021
cb04f6a
arm64: alternative: fix build with clang integrated assembler
ihalip Mar 19, 2020
af65bb6
include: sdp: dek: fix static declaration
duhansysl Sep 1, 2024
440c6d6
gpu: mali: r38p1: fix strict-prototypes errors with clang-18
ananjaser1211 Jul 27, 2024
a50499b
gpu: mali: r38p1: fix more strict-prototypes errors with clang-18
ananjaser1211 Jul 26, 2024
a0cafcf
gpu: mali: r38p1: fix implicit-int
ananjaser1211 Jul 26, 2024
767115c
net: wireless: bcmdhd_101_16: fix strict-prototypes errors with clang-18
ananjaser1211 Jul 26, 2024
1b28003
soc: samsung: exynos-hdcp: fix strict-prototypes errors with clang-18
ananjaser1211 Jul 26, 2024
87a747a
drivers: net: wireless: update from M625FXXU3CWB4
ananjaser1211 Jun 23, 2024
dfecf6e
drivers: net: bcmdhd_101_16: reduce log spams
diepquynh Aug 27, 2022
f84d21b
lib/string.c: implement stpcpy
nickdesaulniers Sep 26, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions Documentation/kbuild/kbuild.txt
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,8 @@ KBUILD_VMLINUX_MAIN
All object files for the main part of vmlinux.
KBUILD_VMLINUX_INIT and KBUILD_VMLINUX_MAIN together specify
all the object files used to link vmlinux.

LLVM
--------------------------------------------------
If this variable is set to 1, Kbuild will use Clang and LLVM utilities instead
of GCC and GNU binutils to build the kernel.
87 changes: 87 additions & 0 deletions Documentation/kbuild/llvm.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
==============================
Building Linux with Clang/LLVM
==============================

This document covers how to build the Linux kernel with Clang and LLVM
utilities.

About
-----

The Linux kernel has always traditionally been compiled with GNU toolchains
such as GCC and binutils. Ongoing work has allowed for `Clang
<https://clang.llvm.org/>`_ and `LLVM <https://llvm.org/>`_ utilities to be
used as viable substitutes. Distributions such as `Android
<https://www.android.com/>`_, `ChromeOS
<https://www.chromium.org/chromium-os>`_, and `OpenMandriva
<https://www.openmandriva.org/>`_ use Clang built kernels. `LLVM is a
collection of toolchain components implemented in terms of C++ objects
<https://www.aosabook.org/en/llvm.html>`_. Clang is a front-end to LLVM that
supports C and the GNU C extensions required by the kernel, and is pronounced
"klang," not "see-lang."

Clang
-----

The compiler used can be swapped out via `CC=` command line argument to `make`.
`CC=` should be set when selecting a config and during a build.

make CC=clang defconfig

make CC=clang

Cross Compiling
---------------

A single Clang compiler binary will typically contain all supported backends,
which can help simplify cross compiling.

ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make CC=clang

`CROSS_COMPILE` is not used to prefix the Clang compiler binary, instead
`CROSS_COMPILE` is used to set a command line flag: `--target <triple>`. For
example:

clang --target aarch64-linux-gnu foo.c

LLVM Utilities
--------------

LLVM has substitutes for GNU binutils utilities. Kbuild supports `LLVM=1`
to enable them.

make LLVM=1

They can be enabled individually. The full list of the parameters:

make CC=clang LD=ld.lld AR=llvm-ar NM=llvm-nm STRIP=llvm-strip \\
OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump OBJSIZE=llvm-size \\
READELF=llvm-readelf HOSTCC=clang HOSTCXX=clang++ HOSTAR=llvm-ar \\
HOSTLD=ld.lld

Currently, the integrated assembler is disabled by default. You can pass
`LLVM_IAS=1` to enable it.

Getting Help
------------

- `Website <https://clangbuiltlinux.github.io/>`_
- `Mailing List <https://groups.google.com/forum/#!forum/clang-built-linux>`_: <clang-built-linux@googlegroups.com>
- `Issue Tracker <https://github.com/ClangBuiltLinux/linux/issues>`_
- IRC: #clangbuiltlinux on chat.freenode.net
- `Telegram <https://t.me/ClangBuiltLinux>`_: @ClangBuiltLinux
- `Wiki <https://github.com/ClangBuiltLinux/linux/wiki>`_
- `Beginner Bugs <https://github.com/ClangBuiltLinux/linux/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22>`_

Getting LLVM
-------------

- http://releases.llvm.org/download.html
- https://github.com/llvm/llvm-project
- https://llvm.org/docs/GettingStarted.html
- https://llvm.org/docs/CMake.html
- https://apt.llvm.org/
- https://www.archlinux.org/packages/extra/x86_64/llvm/
- https://github.com/ClangBuiltLinux/tc-build
- https://github.com/ClangBuiltLinux/linux/wiki/Building-Clang-from-source
- https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/
9 changes: 9 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -3134,6 +3134,15 @@ L: alsa-devel@alsa-project.org (moderated for non-subscribers)
S: Maintained
F: sound/soc/codecs/cs*

CLANG/LLVM BUILD SUPPORT
L: clang-built-linux@googlegroups.com
W: https://clangbuiltlinux.github.io/
B: https://github.com/ClangBuiltLinux/linux/issues
C: irc://chat.freenode.net/clangbuiltlinux
S: Supported
K: \b(?i:clang|llvm)\b
F: Documentation/kbuild/llvm.rst

CLEANCACHE API
M: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
L: linux-kernel@vger.kernel.org
Expand Down
Loading