Skip to content

Commit 8afe26f

Browse files
authored
Merge pull request torvalds#111 from zandrey/5.4.x+fslc
Update 5.4.x+fslc to v5.4.61
2 parents 4b0ed61 + 46d5a31 commit 8afe26f

File tree

111 files changed

+983
-478
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+983
-478
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/kbuild.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,3 +262,8 @@ KBUILD_BUILD_USER, KBUILD_BUILD_HOST
262262
These two variables allow to override the user@host string displayed during
263263
boot and in /proc/version. The default value is the output of the commands
264264
whoami and host, respectively.
265+
266+
LLVM
267+
----
268+
If this variable is set to 1, Kbuild will use Clang and LLVM utilities instead
269+
of GCC and GNU binutils to build the kernel.

Documentation/kbuild/llvm.rst

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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. Kbuild supports `LLVM=1`
51+
to enable them.
52+
53+
make LLVM=1
54+
55+
They can be enabled individually. The full list of the parameters:
56+
57+
make CC=clang LD=ld.lld AR=llvm-ar NM=llvm-nm STRIP=llvm-strip \\
58+
OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump OBJSIZE=llvm-size \\
59+
READELF=llvm-readelf HOSTCC=clang HOSTCXX=clang++ HOSTAR=llvm-ar \\
60+
HOSTLD=ld.lld
61+
62+
Currently, the integrated assembler is disabled by default. You can pass
63+
`LLVM_IAS=1` to enable it.
64+
65+
Getting Help
66+
------------
67+
68+
- `Website <https://clangbuiltlinux.github.io/>`_
69+
- `Mailing List <https://groups.google.com/forum/#!forum/clang-built-linux>`_: <clang-built-linux@googlegroups.com>
70+
- `Issue Tracker <https://github.com/ClangBuiltLinux/linux/issues>`_
71+
- IRC: #clangbuiltlinux on chat.freenode.net
72+
- `Telegram <https://t.me/ClangBuiltLinux>`_: @ClangBuiltLinux
73+
- `Wiki <https://github.com/ClangBuiltLinux/linux/wiki>`_
74+
- `Beginner Bugs <https://github.com/ClangBuiltLinux/linux/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22>`_
75+
76+
Getting LLVM
77+
-------------
78+
79+
- http://releases.llvm.org/download.html
80+
- https://github.com/llvm/llvm-project
81+
- https://llvm.org/docs/GettingStarted.html
82+
- https://llvm.org/docs/CMake.html
83+
- https://apt.llvm.org/
84+
- https://www.archlinux.org/packages/extra/x86_64/llvm/
85+
- https://github.com/ClangBuiltLinux/tc-build
86+
- https://github.com/ClangBuiltLinux/linux/wiki/Building-Clang-from-source
87+
- 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
@@ -4028,6 +4028,7 @@ B: https://github.com/ClangBuiltLinux/linux/issues
40284028
C: irc://chat.freenode.net/clangbuiltlinux
40294029
S: Supported
40304030
K: \b(?i:clang|llvm)\b
4031+
F: Documentation/kbuild/llvm.rst
40314032

40324033
CLEANCACHE API
40334034
M: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>

Makefile

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: GPL-2.0
22
VERSION = 5
33
PATCHLEVEL = 4
4-
SUBLEVEL = 60
4+
SUBLEVEL = 61
55
EXTRAVERSION =
66
NAME = Kleptomaniac Octopus
77

@@ -394,8 +394,13 @@ HOST_LFS_CFLAGS := $(shell getconf LFS_CFLAGS 2>/dev/null)
394394
HOST_LFS_LDFLAGS := $(shell getconf LFS_LDFLAGS 2>/dev/null)
395395
HOST_LFS_LIBS := $(shell getconf LFS_LIBS 2>/dev/null)
396396

397-
HOSTCC = gcc
398-
HOSTCXX = g++
397+
ifneq ($(LLVM),)
398+
HOSTCC = clang
399+
HOSTCXX = clang++
400+
else
401+
HOSTCC = gcc
402+
HOSTCXX = g++
403+
endif
399404
KBUILD_HOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 \
400405
-fomit-frame-pointer -std=gnu89 $(HOST_LFS_CFLAGS) \
401406
$(HOSTCFLAGS)
@@ -404,16 +409,28 @@ KBUILD_HOSTLDFLAGS := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS)
404409
KBUILD_HOSTLDLIBS := $(HOST_LFS_LIBS) $(HOSTLDLIBS)
405410

406411
# Make variables (CC, etc...)
407-
AS = $(CROSS_COMPILE)as
408-
LD = $(CROSS_COMPILE)ld
409-
CC = $(CROSS_COMPILE)gcc
410412
CPP = $(CC) -E
413+
ifneq ($(LLVM),)
414+
CC = clang
415+
LD = ld.lld
416+
AR = llvm-ar
417+
NM = llvm-nm
418+
OBJCOPY = llvm-objcopy
419+
OBJDUMP = llvm-objdump
420+
READELF = llvm-readelf
421+
OBJSIZE = llvm-size
422+
STRIP = llvm-strip
423+
else
424+
CC = $(CROSS_COMPILE)gcc
425+
LD = $(CROSS_COMPILE)ld
411426
AR = $(CROSS_COMPILE)ar
412427
NM = $(CROSS_COMPILE)nm
413-
STRIP = $(CROSS_COMPILE)strip
414428
OBJCOPY = $(CROSS_COMPILE)objcopy
415429
OBJDUMP = $(CROSS_COMPILE)objdump
430+
READELF = $(CROSS_COMPILE)readelf
416431
OBJSIZE = $(CROSS_COMPILE)size
432+
STRIP = $(CROSS_COMPILE)strip
433+
endif
417434
PAHOLE = pahole
418435
LEX = flex
419436
YACC = bison
@@ -422,7 +439,6 @@ INSTALLKERNEL := installkernel
422439
DEPMOD = /sbin/depmod
423440
PERL = perl
424441
PYTHON = python
425-
PYTHON2 = python2
426442
PYTHON3 = python3
427443
CHECK = sparse
428444
BASH = bash
@@ -471,9 +487,9 @@ KBUILD_LDFLAGS :=
471487
GCC_PLUGINS_CFLAGS :=
472488
CLANG_FLAGS :=
473489

474-
export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE AS LD CC
475-
export CPP AR NM STRIP OBJCOPY OBJDUMP OBJSIZE PAHOLE LEX YACC AWK INSTALLKERNEL
476-
export PERL PYTHON PYTHON2 PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX
490+
export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE LD CC
491+
export CPP AR NM STRIP OBJCOPY OBJDUMP OBJSIZE READELF PAHOLE LEX YACC AWK INSTALLKERNEL
492+
export PERL PYTHON PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX
477493
export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE
478494

479495
export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS KBUILD_LDFLAGS
@@ -534,7 +550,7 @@ endif
534550
ifneq ($(GCC_TOOLCHAIN),)
535551
CLANG_FLAGS += --gcc-toolchain=$(GCC_TOOLCHAIN)
536552
endif
537-
ifeq ($(shell $(AS) --version 2>&1 | head -n 1 | grep clang),)
553+
ifneq ($(LLVM_IAS),1)
538554
CLANG_FLAGS += -no-integrated-as
539555
endif
540556
CLANG_FLAGS += -Werror=unknown-warning-option

arch/alpha/include/asm/io.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -502,10 +502,10 @@ extern inline void writeq(u64 b, volatile void __iomem *addr)
502502
}
503503
#endif
504504

505-
#define ioread16be(p) be16_to_cpu(ioread16(p))
506-
#define ioread32be(p) be32_to_cpu(ioread32(p))
507-
#define iowrite16be(v,p) iowrite16(cpu_to_be16(v), (p))
508-
#define iowrite32be(v,p) iowrite32(cpu_to_be32(v), (p))
505+
#define ioread16be(p) swab16(ioread16(p))
506+
#define ioread32be(p) swab32(ioread32(p))
507+
#define iowrite16be(v,p) iowrite16(swab16(v), (p))
508+
#define iowrite32be(v,p) iowrite32(swab32(v), (p))
509509

510510
#define inb_p inb
511511
#define inw_p inw

arch/arm/include/asm/kvm_host.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ int __kvm_arm_vcpu_set_events(struct kvm_vcpu *vcpu,
266266

267267
#define KVM_ARCH_WANT_MMU_NOTIFIER
268268
int kvm_unmap_hva_range(struct kvm *kvm,
269-
unsigned long start, unsigned long end);
269+
unsigned long start, unsigned long end, unsigned flags);
270270
int kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte);
271271

272272
unsigned long kvm_arm_num_regs(struct kvm_vcpu *vcpu);

arch/arm64/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ zinstall install:
146146
PHONY += vdso_install
147147
vdso_install:
148148
$(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso $@
149+
$(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso32 $@
149150

150151
# We use MRPROPER_FILES and CLEAN_FILES now
151152
archclean:

arch/arm64/include/asm/kvm_host.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ int __kvm_arm_vcpu_set_events(struct kvm_vcpu *vcpu,
427427

428428
#define KVM_ARCH_WANT_MMU_NOTIFIER
429429
int kvm_unmap_hva_range(struct kvm *kvm,
430-
unsigned long start, unsigned long end);
430+
unsigned long start, unsigned long end, unsigned flags);
431431
int kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte);
432432
int kvm_age_hva(struct kvm *kvm, unsigned long start, unsigned long end);
433433
int kvm_test_age_hva(struct kvm *kvm, unsigned long hva);

arch/arm64/kernel/vdso32/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ quiet_cmd_vdsosym = VDSOSYM $@
190190
cmd_vdsosym = $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@
191191

192192
# Install commands for the unstripped file
193-
quiet_cmd_vdso_install = INSTALL $@
193+
quiet_cmd_vdso_install = INSTALL32 $@
194194
cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/vdso32.so
195195

196196
vdso.so: $(obj)/vdso.so.dbg

0 commit comments

Comments
 (0)