Skip to content

Commit 2db138b

Browse files
committed
Merge tag 'kbuild-fixes-v5.11-2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
Pull Kbuild fixes from Masahiro Yamada: - Use the 'python3' command to invoke python scripts because some distributions do not provide the 'python' command any more. - Clean-up and update documents - Use pkg-config to search libcrypto - Fix duplicated debug flags - Ignore some more stubs in scripts/kallsyms.c * tag 'kbuild-fixes-v5.11-2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: kallsyms: fix nonconverging kallsyms table with lld kbuild: fix duplicated flags in DEBUG_CFLAGS scripts/clang-tools: switch explicitly to Python 3 kbuild: remove PYTHON variable Documentation/llvm: Add a section about supported architectures Revert "checkpatch: add check for keyword 'boolean' in Kconfig definitions" scripts: use pkg-config to locate libcrypto kconfig: mconf: fix HOSTCC call doc: gcc-plugins: update gcc-plugins.rst kbuild: simplify GCC_PLUGINS enablement in dummy-tools/gcc Documentation/Kbuild: Remove references to gcc-plugin.sh scripts: switch explicitly to Python 3
2 parents 825b599 + efe6e30 commit 2db138b

File tree

17 files changed

+94
-55
lines changed

17 files changed

+94
-55
lines changed

Documentation/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ quiet_cmd_sphinx = SPHINX $@ --> file://$(abspath $(BUILDDIR)/$3/$4)
7575
cmd_sphinx = $(MAKE) BUILDDIR=$(abspath $(BUILDDIR)) $(build)=Documentation/userspace-api/media $2 && \
7676
PYTHONDONTWRITEBYTECODE=1 \
7777
BUILDDIR=$(abspath $(BUILDDIR)) SPHINX_CONF=$(abspath $(srctree)/$(src)/$5/$(SPHINX_CONF)) \
78-
$(PYTHON) $(srctree)/scripts/jobserver-exec \
78+
$(PYTHON3) $(srctree)/scripts/jobserver-exec \
7979
$(SHELL) $(srctree)/Documentation/sphinx/parallel-wrapper.sh \
8080
$(SPHINXBUILD) \
8181
-b $2 \

Documentation/kbuild/gcc-plugins.rst

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,13 @@ compiler [1]_. They are useful for runtime instrumentation and static analysis.
1111
We can analyse, change and add further code during compilation via
1212
callbacks [2]_, GIMPLE [3]_, IPA [4]_ and RTL passes [5]_.
1313

14-
The GCC plugin infrastructure of the kernel supports all gcc versions from
15-
4.5 to 6.0, building out-of-tree modules, cross-compilation and building in a
16-
separate directory.
17-
Plugin source files have to be compilable by both a C and a C++ compiler as well
18-
because gcc versions 4.5 and 4.6 are compiled by a C compiler,
19-
gcc-4.7 can be compiled by a C or a C++ compiler,
20-
and versions 4.8+ can only be compiled by a C++ compiler.
14+
The GCC plugin infrastructure of the kernel supports building out-of-tree
15+
modules, cross-compilation and building in a separate directory.
16+
Plugin source files have to be compilable by a C++ compiler.
2117

22-
Currently the GCC plugin infrastructure supports only the x86, arm, arm64 and
23-
powerpc architectures.
18+
Currently the GCC plugin infrastructure supports only some architectures.
19+
Grep "select HAVE_GCC_PLUGINS" to find out which architectures support
20+
GCC plugins.
2421

2522
This infrastructure was ported from grsecurity [6]_ and PaX [7]_.
2623

@@ -47,42 +44,39 @@ Files
4744
This is a compatibility header for GCC plugins.
4845
It should be always included instead of individual gcc headers.
4946

50-
**$(src)/scripts/gcc-plugin.sh**
51-
52-
This script checks the availability of the included headers in
53-
gcc-common.h and chooses the proper host compiler to build the plugins
54-
(gcc-4.7 can be built by either gcc or g++).
55-
5647
**$(src)/scripts/gcc-plugins/gcc-generate-gimple-pass.h,
5748
$(src)/scripts/gcc-plugins/gcc-generate-ipa-pass.h,
5849
$(src)/scripts/gcc-plugins/gcc-generate-simple_ipa-pass.h,
5950
$(src)/scripts/gcc-plugins/gcc-generate-rtl-pass.h**
6051

6152
These headers automatically generate the registration structures for
62-
GIMPLE, SIMPLE_IPA, IPA and RTL passes. They support all gcc versions
63-
from 4.5 to 6.0.
53+
GIMPLE, SIMPLE_IPA, IPA and RTL passes.
6454
They should be preferred to creating the structures by hand.
6555

6656

6757
Usage
6858
=====
6959

7060
You must install the gcc plugin headers for your gcc version,
71-
e.g., on Ubuntu for gcc-4.9::
61+
e.g., on Ubuntu for gcc-10::
7262

73-
apt-get install gcc-4.9-plugin-dev
63+
apt-get install gcc-10-plugin-dev
7464

7565
Or on Fedora::
7666

7767
dnf install gcc-plugin-devel
7868

79-
Enable a GCC plugin based feature in the kernel config::
69+
Enable the GCC plugin infrastructure and some plugin(s) you want to use
70+
in the kernel config::
8071

81-
CONFIG_GCC_PLUGIN_CYC_COMPLEXITY = y
72+
CONFIG_GCC_PLUGINS=y
73+
CONFIG_GCC_PLUGIN_CYC_COMPLEXITY=y
74+
CONFIG_GCC_PLUGIN_LATENT_ENTROPY=y
75+
...
8276

83-
To compile only the plugin(s)::
77+
To compile the minimum tool set including the plugin(s)::
8478

85-
make gcc-plugins
79+
make scripts
8680

8781
or just run the kernel make and compile the whole kernel with
8882
the cyclomatic complexity GCC plugin.
@@ -91,7 +85,8 @@ the cyclomatic complexity GCC plugin.
9185
4. How to add a new GCC plugin
9286
==============================
9387

94-
The GCC plugins are in $(src)/scripts/gcc-plugins/. You can use a file or a directory
95-
here. It must be added to $(src)/scripts/gcc-plugins/Makefile,
96-
$(src)/scripts/Makefile.gcc-plugins and $(src)/arch/Kconfig.
88+
The GCC plugins are in scripts/gcc-plugins/. You need to put plugin source files
89+
right under scripts/gcc-plugins/. Creating subdirectories is not supported.
90+
It must be added to scripts/gcc-plugins/Makefile, scripts/Makefile.gcc-plugins
91+
and a relevant Kconfig file.
9792
See the cyc_complexity_plugin.c (CONFIG_GCC_PLUGIN_CYC_COMPLEXITY) GCC plugin.

Documentation/kbuild/llvm.rst

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,50 @@ They can be enabled individually. The full list of the parameters: ::
6363
Currently, the integrated assembler is disabled by default. You can pass
6464
``LLVM_IAS=1`` to enable it.
6565

66+
Supported Architectures
67+
-----------------------
68+
69+
LLVM does not target all of the architectures that Linux supports and
70+
just because a target is supported in LLVM does not mean that the kernel
71+
will build or work without any issues. Below is a general summary of
72+
architectures that currently work with ``CC=clang`` or ``LLVM=1``. Level
73+
of support corresponds to "S" values in the MAINTAINERS files. If an
74+
architecture is not present, it either means that LLVM does not target
75+
it or there are known issues. Using the latest stable version of LLVM or
76+
even the development tree will generally yield the best results.
77+
An architecture's ``defconfig`` is generally expected to work well,
78+
certain configurations may have problems that have not been uncovered
79+
yet. Bug reports are always welcome at the issue tracker below!
80+
81+
.. list-table::
82+
:widths: 10 10 10
83+
:header-rows: 1
84+
85+
* - Architecture
86+
- Level of support
87+
- ``make`` command
88+
* - arm
89+
- Supported
90+
- ``LLVM=1``
91+
* - arm64
92+
- Supported
93+
- ``LLVM=1``
94+
* - mips
95+
- Maintained
96+
- ``CC=clang``
97+
* - powerpc
98+
- Maintained
99+
- ``CC=clang``
100+
* - riscv
101+
- Maintained
102+
- ``CC=clang``
103+
* - s390
104+
- Maintained
105+
- ``CC=clang``
106+
* - x86
107+
- Supported
108+
- ``LLVM=1``
109+
66110
Getting Help
67111
------------
68112

Documentation/kbuild/makefiles.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ more details, with real examples.
755755
bits on the scripts nonetheless.
756756

757757
Kbuild provides variables $(CONFIG_SHELL), $(AWK), $(PERL),
758-
$(PYTHON) and $(PYTHON3) to refer to interpreters for the respective
758+
and $(PYTHON3) to refer to interpreters for the respective
759759
scripts.
760760

761761
Example::

Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,6 @@ AWK = awk
452452
INSTALLKERNEL := installkernel
453453
DEPMOD = depmod
454454
PERL = perl
455-
PYTHON = python
456455
PYTHON3 = python3
457456
CHECK = sparse
458457
BASH = bash
@@ -508,7 +507,7 @@ CLANG_FLAGS :=
508507

509508
export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE LD CC
510509
export CPP AR NM STRIP OBJCOPY OBJDUMP READELF PAHOLE RESOLVE_BTFIDS LEX YACC AWK INSTALLKERNEL
511-
export PERL PYTHON PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX
510+
export PERL PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX
512511
export KGZIP KBZIP2 KLZOP LZMA LZ4 XZ ZSTD
513512
export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE
514513

@@ -812,10 +811,12 @@ KBUILD_CFLAGS += -ftrivial-auto-var-init=zero
812811
KBUILD_CFLAGS += -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
813812
endif
814813

814+
DEBUG_CFLAGS :=
815+
815816
# Workaround for GCC versions < 5.0
816817
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61801
817818
ifdef CONFIG_CC_IS_GCC
818-
DEBUG_CFLAGS := $(call cc-ifversion, -lt, 0500, $(call cc-option, -fno-var-tracking-assignments))
819+
DEBUG_CFLAGS += $(call cc-ifversion, -lt, 0500, $(call cc-option, -fno-var-tracking-assignments))
819820
endif
820821

821822
ifdef CONFIG_DEBUG_INFO

arch/ia64/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ vmlinux.bin: vmlinux FORCE
6969
$(call if_changed,objcopy)
7070

7171
unwcheck: vmlinux
72-
-$(Q)READELF=$(READELF) $(PYTHON) $(srctree)/arch/ia64/scripts/unwcheck.py $<
72+
-$(Q)READELF=$(READELF) $(PYTHON3) $(srctree)/arch/ia64/scripts/unwcheck.py $<
7373

7474
archclean:
7575

arch/ia64/scripts/unwcheck.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# SPDX-License-Identifier: GPL-2.0
33
#
44
# Usage: unwcheck.py FILE

scripts/Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
# scripts contains sources for various helper programs used throughout
44
# the kernel for the build process.
55

6+
CRYPTO_LIBS = $(shell pkg-config --libs libcrypto 2> /dev/null || echo -lcrypto)
7+
CRYPTO_CFLAGS = $(shell pkg-config --cflags libcrypto 2> /dev/null)
8+
69
hostprogs-always-$(CONFIG_BUILD_BIN2C) += bin2c
710
hostprogs-always-$(CONFIG_KALLSYMS) += kallsyms
811
hostprogs-always-$(BUILD_C_RECORDMCOUNT) += recordmcount
@@ -14,8 +17,9 @@ hostprogs-always-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE) += insert-sys-cert
1417

1518
HOSTCFLAGS_sorttable.o = -I$(srctree)/tools/include
1619
HOSTCFLAGS_asn1_compiler.o = -I$(srctree)/include
17-
HOSTLDLIBS_sign-file = -lcrypto
18-
HOSTLDLIBS_extract-cert = -lcrypto
20+
HOSTLDLIBS_sign-file = $(CRYPTO_LIBS)
21+
HOSTCFLAGS_extract-cert.o = $(CRYPTO_CFLAGS)
22+
HOSTLDLIBS_extract-cert = $(CRYPTO_LIBS)
1923

2024
ifdef CONFIG_UNWINDER_ORC
2125
ifeq ($(ARCH),x86_64)

scripts/bloat-o-meter

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
#
33
# Copyright 2004 Matt Mackall <[email protected]>
44
#

scripts/checkpatch.pl

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3390,13 +3390,6 @@ sub process {
33903390
}
33913391
}
33923392

3393-
# discourage the use of boolean for type definition attributes of Kconfig options
3394-
if ($realfile =~ /Kconfig/ &&
3395-
$line =~ /^\+\s*\bboolean\b/) {
3396-
WARN("CONFIG_TYPE_BOOLEAN",
3397-
"Use of boolean is deprecated, please use bool instead.\n" . $herecurr);
3398-
}
3399-
34003393
if (($realfile =~ /Makefile.*/ || $realfile =~ /Kbuild.*/) &&
34013394
($line =~ /\+(EXTRA_[A-Z]+FLAGS).*/)) {
34023395
my $flag = $1;

scripts/clang-tools/gen_compile_commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# SPDX-License-Identifier: GPL-2.0
33
#
44
# Copyright (C) Google LLC, 2018

scripts/clang-tools/run-clang-tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# SPDX-License-Identifier: GPL-2.0
33
#
44
# Copyright (C) Google LLC, 2020

scripts/diffconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# SPDX-License-Identifier: GPL-2.0
33
#
44
# diffconfig - a tool to compare .config files.

scripts/dummy-tools/gcc

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,12 @@ if arg_contain -S "$@"; then
7575
fi
7676
fi
7777

78-
# For scripts/gcc-plugin.sh
78+
# To set GCC_PLUGINS
7979
if arg_contain -print-file-name=plugin "$@"; then
8080
plugin_dir=$(mktemp -d)
8181

82-
sed -n 's/.*#include "\(.*\)"/\1/p' $(dirname $0)/../gcc-plugins/gcc-common.h |
83-
while read header
84-
do
85-
mkdir -p $plugin_dir/include/$(dirname $header)
86-
touch $plugin_dir/include/$header
87-
done
82+
mkdir -p $plugin_dir/include
83+
touch $plugin_dir/include/plugin-version.h
8884

8985
echo $plugin_dir
9086
exit 0

scripts/jobserver-exec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# SPDX-License-Identifier: GPL-2.0+
33
#
44
# This determines how many parallel tasks "make" is expecting, as it is

scripts/kallsyms.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@ static bool is_ignored_symbol(const char *name, char type)
112112
"__crc_", /* modversions */
113113
"__efistub_", /* arm64 EFI stub namespace */
114114
"__kvm_nvhe_", /* arm64 non-VHE KVM namespace */
115+
"__AArch64ADRPThunk_", /* arm64 lld */
116+
"__ARMV5PILongThunk_", /* arm lld */
117+
"__ARMV7PILongThunk_",
118+
"__ThumbV7PILongThunk_",
119+
"__LA25Thunk_", /* mips lld */
120+
"__microLA25Thunk_",
115121
NULL
116122
};
117123

scripts/kconfig/mconf-cfg.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fi
3535

3636
# As a final fallback before giving up, check if $HOSTCC knows of a default
3737
# ncurses installation (e.g. from a vendor-specific sysroot).
38-
if echo '#include <ncurses.h>' | "${HOSTCC}" -E - >/dev/null 2>&1; then
38+
if echo '#include <ncurses.h>' | ${HOSTCC} -E - >/dev/null 2>&1; then
3939
echo cflags=\"-D_GNU_SOURCE\"
4040
echo libs=\"-lncurses\"
4141
exit 0

0 commit comments

Comments
 (0)