mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 01:32:21 +02:00
Kbuild / Kconfig changes for 7.2
Kbuild:
- Remove broken module linking exclusion for BTF
- Add documentation around how offset header files work
- Include unstripped vDSO libraries in pacman packages
- Bump minimum version of LLVM for building the kernel to 17.0.1 and
clean up unnecessary workarounds
- Use a context manager in run-clang-tools
- Add dist macro value if present to release tag for RPM packages
- Detect and report truncated buf_printf() output in modpost
- Add __llvm_covfun and __llvm_covmap to section whitelist in modpost
- Support Clang's distributed ThinLTO mode
- Remove architecture specific configurations for AutoFDO and Propeller
to ease individual architecture maintenance
Kconfig:
- Add kconfig-sym-check target to look for dangling Kconfig symbol
references and invalid tristate literal values
- Harden against potential NULL pointer dereference
- Fix typo in Kconfig test comment
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
-----BEGIN PGP SIGNATURE-----
iHUEABYKAB0WIQR74yXHMTGczQHYypIdayaRccAalgUCaijIpwAKCRAdayaRccAa
lszAAQD0PuP+a0IejIyubuvEeB0ecG5nvKZIV99veIaivp9J4QD+PwYuPf+Y9A0r
PqiV0IBrnhbmjNrSj8Clt2eHXqa4jg4=
=J1xQ
-----END PGP SIGNATURE-----
Merge tag 'kbuild-7.2-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kbuild/linux
Pull Kbuild / Kconfig updates from Nathan Chancellor:
"Kbuild:
- Remove broken module linking exclusion for BTF
- Add documentation around how offset header files work
- Include unstripped vDSO libraries in pacman packages
- Bump minimum version of LLVM for building the kernel to 17.0.1 and
clean up unnecessary workarounds
- Use a context manager in run-clang-tools
- Add dist macro value if present to release tag for RPM packages
- Detect and report truncated buf_printf() output in modpost
- Add __llvm_covfun and __llvm_covmap to section whitelist in modpost
- Support Clang's distributed ThinLTO mode
- Remove architecture specific configurations for AutoFDO and
Propeller to ease individual architecture maintenance
Kconfig:
- Add kconfig-sym-check target to look for dangling Kconfig symbol
references and invalid tristate literal values
- Harden against potential NULL pointer dereference
- Fix typo in Kconfig test comment"
* tag 'kbuild-7.2-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kbuild/linux: (31 commits)
kconfig: tests: fix typo in comment
kconfig: Remove the architecture specific config for Propeller
kconfig: Remove the architecture specific config for AutoFDO
modpost: Add __llvm_covfun and __llvm_covmap to section_white_list
kconfig: add kconfig-sym-check static checker
kbuild: Remove unnecessary 'T' modifier in cmd_ar_builtin_fixup
kbuild: distributed build support for Clang ThinLTO
kbuild: move vmlinux.a build rule to scripts/Makefile.vmlinux_a
scripts: modpost: detect and report truncated buf_printf() output
kbuild: rpm-pkg: append %{?dist} macro to Release tag
run-clang-tools: run multiprocessing.Pool as context manager
compiler-clang.h: Drop explicit version number from "all" diagnostic macro
compiler-clang.h: Remove __cleanup -Wunused-variable workaround
kbuild: Remove check for broken scoping with clang < 17 in CC_HAS_ASM_GOTO_OUTPUT
x86/entry/vdso32: Remove conditional omission of '.cfi_offset eflags'
x86/module: Revert "Deal with GOT based stack cookie load on Clang < 17"
x86/build: Drop unnecessary '-ffreestanding' addition to KBUILD_CFLAGS
scripts/Makefile.warn: Drop -Wformat handling for clang < 16
riscv: Drop tautological condition from TOOLCHAIN_NEEDS_OLD_ISA_SPEC
riscv: Remove tautological condition from selection of ARCH_SUPPORTS_CFI
...
This commit is contained in:
commit
73f399414a
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -57,6 +57,7 @@
|
|||
*.zst
|
||||
Module.symvers
|
||||
dtbs-list
|
||||
builtin.order
|
||||
modules.order
|
||||
|
||||
#
|
||||
|
|
@ -68,6 +69,7 @@ modules.order
|
|||
/vmlinux.32
|
||||
/vmlinux.map
|
||||
/vmlinux.symvers
|
||||
/vmlinux.thinlto-index
|
||||
/vmlinux.unstripped
|
||||
/vmlinux-gdb.py
|
||||
/vmlinuz
|
||||
|
|
|
|||
|
|
@ -61,6 +61,9 @@ process consists of the following steps:
|
|||
the AutoFDO profile via offline tools.
|
||||
|
||||
The support requires a Clang compiler LLVM 17 or later.
|
||||
Current supported architectures include x86/x86_64 (via LBR) and
|
||||
arm64 (via SPE or ETM).
|
||||
|
||||
|
||||
Preparation
|
||||
===========
|
||||
|
|
@ -141,6 +144,35 @@ Here is an example workflow for AutoFDO kernel:
|
|||
|
||||
$ perf record --pfm-events RETIRED_TAKEN_BRANCH_INSTRUCTIONS:k -a -N -b -c <count> -o <perf_file> -- <loadtest>
|
||||
|
||||
- For arm64 with SPE:
|
||||
|
||||
There are a few kernel features that must be enabled to collect SPE profiles on Arm.
|
||||
Below is a list of the required features:
|
||||
|
||||
- CONFIG_ARM_SPE_PMU=y
|
||||
- CONFIG_PID_IN_CONTEXTIDR=y
|
||||
- kpti=off
|
||||
|
||||
Use the following command to generate SPE perf data file::
|
||||
|
||||
$ perf record -e ' arm_spe_0/branch_filter=1,load_filter=0,store_filter=0/' -a -c <count> -N --no-switch-events -o <perf_file> -- <loadtest>
|
||||
|
||||
- For arm64 with ETM trace:
|
||||
|
||||
Follow the instructions in `Linaro OpenCSD document
|
||||
<https://github.com/Linaro/OpenCSD/blob/master/decoder/tests/auto-fdo/autofdo.md>`_
|
||||
to record ETM traces for AutoFDO::
|
||||
|
||||
$ perf record -e cs_etm/@tmc_etr0/k -a -o <etm_perf_file> -- <loadtest>
|
||||
$ perf inject -i <etm_perf_file> -o <perf_file> --itrace=i500009il
|
||||
|
||||
For ARM platforms running Android, follow the instructions in `Android simpleperf
|
||||
document <https://android.googlesource.com/kernel/common/+/refs/heads/android-mainline/gki/aarch64/afdo>`_
|
||||
to record ETM traces for AutoFDO::
|
||||
|
||||
$ simpleperf record -e cs-etm:k -a -o <etm_perf_file> -- <loadtest>
|
||||
$ simpleperf inject -i <etm_perf_file> -o <text_perf_file> --symdir <vmlinux_dir>
|
||||
|
||||
4) (Optional) Download the raw perf file to the host machine.
|
||||
|
||||
5) To generate an AutoFDO profile, two offline tools are available:
|
||||
|
|
@ -162,6 +194,15 @@ Here is an example workflow for AutoFDO kernel:
|
|||
|
||||
$ llvm-profdata merge -o <profile_file> <profile_1> <profile_2> ... <profile_n>
|
||||
|
||||
For arm64 SPE, use the following command::
|
||||
|
||||
$ create_llvm_prof --binary=<vmlinux> --profile=<perf_file> --profiler=perf_spe --format=extbinary --out=<profile_file>
|
||||
|
||||
For arm64 ETM, use the following command::
|
||||
|
||||
$ create_llvm_prof --binary=<vmlinux> --profile=<text_perf_file> --profiler=text -format=extbinary -out=<profile_file>
|
||||
|
||||
|
||||
6) Rebuild the kernel using the AutoFDO profile file with the same config as step 1,
|
||||
(Note CONFIG_AUTOFDO_CLANG needs to be enabled)::
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,10 @@ A few important notes about adopting Propeller optimization:
|
|||
and the linker(ld.lld).
|
||||
|
||||
#. In addition to LLVM toolchain, Propeller requires a profiling
|
||||
conversion tool: https://github.com/google/autofdo with a release
|
||||
after v0.30.1: https://github.com/google/autofdo/releases/tag/v0.30.1.
|
||||
conversion tool: https://github.com/google/llvm-propeller.
|
||||
|
||||
Current supported architectures include x86/X86_64 (via LBR),
|
||||
and arm64 (via SPE).
|
||||
|
||||
The Propeller optimization process involves the following steps:
|
||||
|
||||
|
|
@ -124,17 +126,30 @@ Here is an example workflow for building an AutoFDO+Propeller kernel:
|
|||
|
||||
$ perf record --pfm-event RETIRED_TAKEN_BRANCH_INSTRUCTIONS:k -a -N -b -c <count> -o <perf_file> -- <loadtest>
|
||||
|
||||
Note you can repeat the above steps to collect multiple <perf_file>s.
|
||||
- For arm64 with SPE::
|
||||
There are a few kernel features that must be enabled to collect SPE profiles on Arm.
|
||||
Below is a list of the required features:
|
||||
|
||||
- CONFIG_ARM_SPE_PMU=y
|
||||
- CONFIG_PID_IN_CONTEXTIDR=y
|
||||
- kpti=off
|
||||
|
||||
Use the following command to generate SPE perf data file::
|
||||
|
||||
$ perf record -e 'arm_spe_0/branch_filter=1,load_filter=0,store_filter=0/' -a -N -c <count> --no-switch-events -o <perf_file> -- <loadtest>
|
||||
|
||||
Note you can repeat the above steps to collect multiple <perf_file>s.
|
||||
|
||||
4) (Optional) Download the raw perf file(s) to the host machine.
|
||||
|
||||
5) Use the create_llvm_prof tool (https://github.com/google/autofdo) to
|
||||
5) Use the generate_propeller_profiles tool (https://github.com/google/llvm-propeller) to
|
||||
generate Propeller profile. ::
|
||||
|
||||
$ create_llvm_prof --binary=<vmlinux> --profile=<perf_file>
|
||||
--format=propeller --propeller_output_module_name
|
||||
--out=<propeller_profile_prefix>_cc_profile.txt
|
||||
--propeller_symorder=<propeller_profile_prefix>_ld_profile.txt
|
||||
$ generate_propeller_profiles \
|
||||
--binary=<vmlinux> --profile=<perf_file> \
|
||||
--format=propeller --propeller_output_module_name \
|
||||
--out=<propeller_profile_prefix>_cc_profile.txt \
|
||||
--propeller_symorder=<propeller_profile_prefix>_ld_profile.txt
|
||||
|
||||
"<propeller_profile_prefix>" can be something like "/home/user/dir/any_string".
|
||||
|
||||
|
|
@ -146,10 +161,20 @@ Here is an example workflow for building an AutoFDO+Propeller kernel:
|
|||
you can create a temp list file "<perf_file_list>" with each line
|
||||
containing one perf file name and run::
|
||||
|
||||
$ create_llvm_prof --binary=<vmlinux> --profile=@<perf_file_list>
|
||||
--format=propeller --propeller_output_module_name
|
||||
--out=<propeller_profile_prefix>_cc_profile.txt
|
||||
--propeller_symorder=<propeller_profile_prefix>_ld_profile.txt
|
||||
$ generate_propeller_profiles \
|
||||
--binary=<vmlinux> --profile=@<perf_file_list> \
|
||||
--format=propeller --propeller_output_module_name \
|
||||
--out=<propeller_profile_prefix>_cc_profile.txt \
|
||||
--propeller_symorder=<propeller_profile_prefix>_ld_profile.txt
|
||||
|
||||
For arm64 SPE, add the option '--profiler=perf_spe', like::
|
||||
|
||||
$ generate_propeller_profiles \
|
||||
--binary=<vmlinux> --profile=<perf_file> \
|
||||
--profiler=perf_spe \
|
||||
--format=propeller --propeller_output_module_name \
|
||||
--out=<propeller_profile_prefix>_cc_profile.txt \
|
||||
--propeller_symorder=<propeller_profile_prefix>_ld_profile.txt
|
||||
|
||||
6) Rebuild the kernel using the AutoFDO and Propeller
|
||||
profiles. ::
|
||||
|
|
|
|||
|
|
@ -1285,8 +1285,39 @@ Example::
|
|||
In this example, the file target maketools will be processed
|
||||
before descending down in the subdirectories.
|
||||
|
||||
See also chapter XXX-TODO that describes how kbuild supports
|
||||
generating offset header files.
|
||||
Generating offset header files
|
||||
------------------------------
|
||||
|
||||
The ``include/generated/asm-offsets.h`` header exposes C structure
|
||||
member offsets and other compile-time constants to assembly code. It
|
||||
is generated from ``arch/$(SRCARCH)/kernel/asm-offsets.c``.
|
||||
|
||||
The source file uses ``DEFINE()``, ``OFFSET()``, ``BLANK()`` and
|
||||
``COMMENT()`` from ``<linux/kbuild.h>``. These emit marker strings
|
||||
through inline asm that Kbuild extracts from the compiled assembly
|
||||
output.
|
||||
|
||||
Example::
|
||||
|
||||
#include <linux/kbuild.h>
|
||||
#include <linux/sched.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
OFFSET(TSK_ACTIVE_MM, task_struct, active_mm);
|
||||
DEFINE(THREAD_SIZE, THREAD_SIZE);
|
||||
BLANK();
|
||||
return 0;
|
||||
}
|
||||
|
||||
The rules are defined in the top-level ``Kbuild`` and
|
||||
``scripts/Makefile.lib``. The header is built during Kbuild's
|
||||
``prepare`` phase, after ``archprepare`` and before descending into
|
||||
subdirectories.
|
||||
|
||||
The same mechanism generates ``include/generated/bounds.h`` from
|
||||
``kernel/bounds.c`` and ``include/generated/rq-offsets.h`` from
|
||||
``kernel/sched/rq-offsets.c``.
|
||||
|
||||
List directories to visit when descending
|
||||
-----------------------------------------
|
||||
|
|
@ -1690,9 +1721,3 @@ Credits
|
|||
- Updates by Kai Germaschewski <kai@tp1.ruhr-uni-bochum.de>
|
||||
- Updates by Sam Ravnborg <sam@ravnborg.org>
|
||||
- Language QA by Jan Engelhardt <jengelh@gmx.de>
|
||||
|
||||
TODO
|
||||
====
|
||||
|
||||
- Generating offset header files.
|
||||
- Add more variables to chapters 7 or 9?
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ bindgen (optional) 0.71.1 bindgen --version
|
|||
binutils 2.30 ld -v
|
||||
bison 2.0 bison --version
|
||||
btrfs-progs 0.18 btrfs --version
|
||||
Clang/LLVM (optional) 15.0.0 clang --version
|
||||
Clang/LLVM (optional) 17.0.1 clang --version
|
||||
e2fsprogs 1.41.4 e2fsck -V
|
||||
flex 2.5.35 flex --version
|
||||
gdb 7.2 gdb --version
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ PC Card, per esempio, probabilmente non dovreste preoccuparvi di pcmciautils.
|
|||
Programma Versione minima Comando per verificare la versione
|
||||
====================== ================= ========================================
|
||||
GNU C 8.1 gcc --version
|
||||
Clang/LLVM (optional) 13.0.0 clang --version
|
||||
Clang/LLVM (optional) 17.0.1 clang --version
|
||||
Rust (opzionale) 1.78.0 rustc --version
|
||||
bindgen (opzionale) 0.65.1 bindgen --version
|
||||
GNU make 4.0 make --version
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ PC Card por exemplo, provavelmente não precisará se preocupar com o pcmciautil
|
|||
Programa Versão mínima Comando para verificar a versão
|
||||
====================== =============== ========================================
|
||||
GNU C 8.1 gcc --version
|
||||
Clang/LLVM (optional) 15.0.0 clang --version
|
||||
Clang/LLVM (optional) 17.0.1 clang --version
|
||||
Rust (optional) 1.78.0 rustc --version
|
||||
bindgen (optional) 0.65.1 bindgen --version
|
||||
GNU make 4.0 make --version
|
||||
|
|
|
|||
55
Makefile
55
Makefile
|
|
@ -293,6 +293,7 @@ version_h := include/generated/uapi/linux/version.h
|
|||
clean-targets := %clean mrproper cleandocs
|
||||
no-dot-config-targets := $(clean-targets) \
|
||||
cscope gtags TAGS tags help% %docs check% coccicheck \
|
||||
kconfig-sym-check \
|
||||
$(version_h) headers headers_% archheaders archscripts \
|
||||
%asm-generic kernelversion %src-pkg dt_binding_check \
|
||||
outputmakefile rustavailable rustfmt rustfmtcheck \
|
||||
|
|
@ -1074,11 +1075,16 @@ export CC_FLAGS_SCS
|
|||
endif
|
||||
|
||||
ifdef CONFIG_LTO_CLANG
|
||||
ifdef CONFIG_LTO_CLANG_THIN
|
||||
CC_FLAGS_LTO := -flto=thin -fsplit-lto-unit
|
||||
KBUILD_LDFLAGS += $(call ld-option,--lto-whole-program-visibility -mllvm -always-rename-promoted-locals=false)
|
||||
else
|
||||
ifdef CONFIG_LTO_CLANG_FULL
|
||||
CC_FLAGS_LTO := -flto
|
||||
else
|
||||
CC_FLAGS_LTO := -flto=thin -fsplit-lto-unit
|
||||
|
||||
# These LLVM options were initially added with only in-process ThinLTO
|
||||
# support, so avoid distributed ThinLTO support for now.
|
||||
ifdef CONFIG_LTO_CLANG_THIN
|
||||
KBUILD_LDFLAGS += $(call ld-option,--lto-whole-program-visibility -mllvm -always-rename-promoted-locals=false)
|
||||
endif
|
||||
endif
|
||||
CC_FLAGS_LTO += -fvisibility=hidden
|
||||
|
||||
|
|
@ -1294,7 +1300,7 @@ export ARCH_DRIVERS := $(drivers-y) $(drivers-m)
|
|||
KBUILD_VMLINUX_OBJS := built-in.a $(patsubst %/, %/lib.a, $(filter %/, $(libs-y)))
|
||||
KBUILD_VMLINUX_LIBS := $(filter-out %/, $(libs-y))
|
||||
|
||||
export KBUILD_VMLINUX_LIBS
|
||||
export KBUILD_VMLINUX_OBJS KBUILD_VMLINUX_LIBS
|
||||
export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds
|
||||
|
||||
ifdef CONFIG_TRIM_UNUSED_KSYMS
|
||||
|
|
@ -1303,16 +1309,12 @@ ifdef CONFIG_TRIM_UNUSED_KSYMS
|
|||
KBUILD_MODULES := y
|
||||
endif
|
||||
|
||||
# '$(AR) mPi' needs 'T' to workaround the bug of llvm-ar <= 14
|
||||
quiet_cmd_ar_vmlinux.a = AR $@
|
||||
cmd_ar_vmlinux.a = \
|
||||
rm -f $@; \
|
||||
$(AR) cDPrST $@ $(KBUILD_VMLINUX_OBJS); \
|
||||
$(AR) mPiT $$($(AR) t $@ | sed -n 1p) $@ $$($(AR) t $@ | grep -F -f $(srctree)/scripts/head-object-list.txt)
|
||||
PHONY += vmlinux_a
|
||||
vmlinux_a: $(KBUILD_VMLINUX_OBJS) scripts/head-object-list.txt FORCE
|
||||
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vmlinux_a
|
||||
|
||||
targets += vmlinux.a
|
||||
vmlinux.a: $(KBUILD_VMLINUX_OBJS) scripts/head-object-list.txt FORCE
|
||||
$(call if_changed,ar_vmlinux.a)
|
||||
vmlinux.a: vmlinux_a
|
||||
@:
|
||||
|
||||
PHONY += vmlinux_o
|
||||
vmlinux_o: vmlinux.a $(KBUILD_VMLINUX_LIBS)
|
||||
|
|
@ -1691,6 +1693,7 @@ endif # CONFIG_MODULES
|
|||
CLEAN_FILES += vmlinux.symvers modules-only.symvers \
|
||||
modules.builtin modules.builtin.modinfo modules.nsdeps \
|
||||
modules.builtin.ranges vmlinux.o.map vmlinux.unstripped \
|
||||
vmlinux.thinlto-index builtin.order \
|
||||
compile_commands.json rust/test \
|
||||
rust-project.json .vmlinux.objs .vmlinux.export.c \
|
||||
.builtin-dtbs-list .builtin-dtbs.S
|
||||
|
|
@ -1801,14 +1804,15 @@ help:
|
|||
echo ' (default: $(INSTALL_HDR_PATH))'; \
|
||||
echo ''
|
||||
@echo 'Static analysers:'
|
||||
@echo ' checkstack - Generate a list of stack hogs and consider all functions'
|
||||
@echo ' with a stack size larger than MINSTACKSIZE (default: 100)'
|
||||
@echo ' versioncheck - Sanity check on version.h usage'
|
||||
@echo ' includecheck - Check for duplicate included header files'
|
||||
@echo ' headerdep - Detect inclusion cycles in headers'
|
||||
@echo ' coccicheck - Check with Coccinelle'
|
||||
@echo ' clang-analyzer - Check with clang static analyzer'
|
||||
@echo ' clang-tidy - Check with clang-tidy'
|
||||
@echo ' checkstack - Generate a list of stack hogs and consider all functions'
|
||||
@echo ' with a stack size larger than MINSTACKSIZE (default: 100)'
|
||||
@echo ' versioncheck - Sanity check on version.h usage'
|
||||
@echo ' includecheck - Check for duplicate included header files'
|
||||
@echo ' headerdep - Detect inclusion cycles in headers'
|
||||
@echo ' coccicheck - Check with Coccinelle'
|
||||
@echo ' kconfig-sym-check - Check for dangling Kconfig symbol references'
|
||||
@echo ' clang-analyzer - Check with clang static analyzer'
|
||||
@echo ' clang-tidy - Check with clang-tidy'
|
||||
@echo ''
|
||||
@echo 'Tools:'
|
||||
@echo ' nsdeps - Generate missing symbol namespace dependencies'
|
||||
|
|
@ -2152,7 +2156,7 @@ clean: $(clean-dirs)
|
|||
$(call cmd,rmfiles)
|
||||
@find . $(RCS_FIND_IGNORE) \
|
||||
\( -name '*.[aios]' -o -name '*.rsi' -o -name '*.ko' -o -name '.*.cmd' \
|
||||
-o -name '*.ko.*' \
|
||||
-o -name '*.ko.*' -o -name '*.o.thinlto.bc' \
|
||||
-o -name '*.dtb' -o -name '*.dtbo' \
|
||||
-o -name '*.dtb.S' -o -name '*.dtbo.S' \
|
||||
-o -name '*.dt.yaml' -o -name 'dtbs-list' \
|
||||
|
|
@ -2228,7 +2232,7 @@ endif
|
|||
# Scripts to check various things for consistency
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
PHONY += includecheck versioncheck coccicheck
|
||||
PHONY += includecheck versioncheck coccicheck kconfig-sym-check
|
||||
|
||||
includecheck:
|
||||
find $(srctree)/* $(RCS_FIND_IGNORE) \
|
||||
|
|
@ -2243,6 +2247,9 @@ versioncheck:
|
|||
coccicheck:
|
||||
$(Q)$(BASH) $(srctree)/scripts/$@
|
||||
|
||||
kconfig-sym-check:
|
||||
$(Q)$(PERL) $(srctree)/scripts/kconfig/kconfig-sym-check.pl $(srctree) $(KCONFIG_SYM_CHECK_EXCLUDES)
|
||||
|
||||
PHONY += checkstack kernelrelease kernelversion image_name
|
||||
|
||||
# UML needs a little special treatment here. It wants to use the host
|
||||
|
|
|
|||
33
arch/Kconfig
33
arch/Kconfig
|
|
@ -806,9 +806,6 @@ config HAS_LTO_CLANG
|
|||
depends on $(success,$(AR) --help | head -n 1 | grep -qi llvm)
|
||||
depends on ARCH_SUPPORTS_LTO_CLANG
|
||||
depends on !FTRACE_MCOUNT_USE_RECORDMCOUNT
|
||||
# https://github.com/ClangBuiltLinux/linux/issues/1721
|
||||
depends on (!KASAN || KASAN_HW_TAGS || CLANG_VERSION >= 170000) || !DEBUG_INFO
|
||||
depends on (!KCOV || CLANG_VERSION >= 170000) || !DEBUG_INFO
|
||||
depends on !GCOV_KERNEL
|
||||
help
|
||||
The compiler and Kconfig options support building with Clang's
|
||||
|
|
@ -861,15 +858,30 @@ config LTO_CLANG_THIN
|
|||
https://clang.llvm.org/docs/ThinLTO.html
|
||||
|
||||
If unsure, say Y.
|
||||
endchoice
|
||||
|
||||
config ARCH_SUPPORTS_AUTOFDO_CLANG
|
||||
bool
|
||||
config LTO_CLANG_THIN_DIST
|
||||
bool "Clang ThinLTO in distributed mode (EXPERIMENTAL)"
|
||||
depends on HAS_LTO_CLANG && ARCH_SUPPORTS_LTO_CLANG_THIN
|
||||
select LTO_CLANG
|
||||
help
|
||||
This option enables Clang's ThinLTO in distributed build mode.
|
||||
In this mode, the linker performs the thin-link, generating
|
||||
ThinLTO index files. Subsequently, the build system explicitly
|
||||
invokes ThinLTO backend compilation using these index files
|
||||
and pre-linked IR objects. The resulting native object files
|
||||
are with the .thinlto-native.o suffix.
|
||||
|
||||
This build mode offers improved visibility into the ThinLTO
|
||||
process through explicit subcommand exposure. It also makes
|
||||
final native object files directly available, benefiting
|
||||
tools like objtool and kpatch. Additionally, it provides
|
||||
crucial granular control over back-end options, enabling
|
||||
module-specific compiler options, and simplifies debugging.
|
||||
endchoice
|
||||
|
||||
config AUTOFDO_CLANG
|
||||
bool "Enable Clang's AutoFDO build (EXPERIMENTAL)"
|
||||
depends on ARCH_SUPPORTS_AUTOFDO_CLANG
|
||||
depends on CC_IS_CLANG && CLANG_VERSION >= 170000
|
||||
depends on CC_IS_CLANG
|
||||
help
|
||||
This option enables Clang’s AutoFDO build. When
|
||||
an AutoFDO profile is specified in variable
|
||||
|
|
@ -883,13 +895,10 @@ config AUTOFDO_CLANG
|
|||
|
||||
If unsure, say N.
|
||||
|
||||
config ARCH_SUPPORTS_PROPELLER_CLANG
|
||||
bool
|
||||
|
||||
config PROPELLER_CLANG
|
||||
bool "Enable Clang's Propeller build"
|
||||
depends on ARCH_SUPPORTS_PROPELLER_CLANG
|
||||
depends on CC_IS_CLANG && CLANG_VERSION >= 190000
|
||||
depends on $(cc-option,-fbasic-block-sections=list=/dev/null)
|
||||
help
|
||||
This option enables Clang’s Propeller build. When the Propeller
|
||||
profiles is specified in variable CLANG_PROPELLER_PROFILE_PREFIX
|
||||
|
|
|
|||
|
|
@ -8,16 +8,12 @@ comment "CPU Core family selection"
|
|||
config ARCH_MULTI_V4
|
||||
bool "ARMv4 based platforms (FA526, StrongARM)"
|
||||
depends on !ARCH_MULTI_V6_V7
|
||||
# https://github.com/llvm/llvm-project/issues/50764
|
||||
depends on !LD_IS_LLD || LLD_VERSION >= 160000
|
||||
select ARCH_MULTI_V4_V5
|
||||
select CPU_FA526 if !(CPU_SA110 || CPU_SA1100)
|
||||
|
||||
config ARCH_MULTI_V4T
|
||||
bool "ARMv4T based platforms (ARM720T, ARM920T, ...)"
|
||||
depends on !ARCH_MULTI_V6_V7
|
||||
# https://github.com/llvm/llvm-project/issues/50764
|
||||
depends on !LD_IS_LLD || LLD_VERSION >= 160000
|
||||
select ARCH_MULTI_V4_V5
|
||||
select CPU_ARM920T if !(CPU_ARM7TDMI || CPU_ARM720T || \
|
||||
CPU_ARM740T || CPU_ARM9TDMI || CPU_ARM922T || \
|
||||
|
|
|
|||
|
|
@ -368,6 +368,7 @@ SECTIONS
|
|||
|
||||
STABS_DEBUG
|
||||
DWARF_DEBUG
|
||||
PROPELLER_DATA
|
||||
MODINFO
|
||||
ELF_DETAILS
|
||||
|
||||
|
|
|
|||
|
|
@ -61,8 +61,7 @@ config RISCV
|
|||
select ARCH_OPTIONAL_KERNEL_RWX_DEFAULT
|
||||
select ARCH_STACKWALK
|
||||
select ARCH_SUPPORTS_ATOMIC_RMW
|
||||
# clang >= 17: https://github.com/llvm/llvm-project/commit/62fa708ceb027713b386c7e0efda994f8bdc27e2
|
||||
select ARCH_SUPPORTS_CFI if (!CC_IS_CLANG || CLANG_VERSION >= 170000)
|
||||
select ARCH_SUPPORTS_CFI
|
||||
select ARCH_SUPPORTS_DEBUG_PAGEALLOC if MMU
|
||||
select ARCH_SUPPORTS_HUGE_PFNMAP if TRANSPARENT_HUGEPAGE
|
||||
select ARCH_SUPPORTS_HUGETLBFS if MMU
|
||||
|
|
@ -874,19 +873,18 @@ config TOOLCHAIN_NEEDS_EXPLICIT_ZICSR_ZIFENCEI
|
|||
and Zifencei are supported in binutils from version 2.36 onwards.
|
||||
To make life easier, and avoid forcing toolchains that default to a
|
||||
newer ISA spec to version 2.2, relax the check to binutils >= 2.36.
|
||||
For clang < 17 or GCC < 11.3.0, for which this is not possible or need
|
||||
special treatment, this is dealt with in TOOLCHAIN_NEEDS_OLD_ISA_SPEC.
|
||||
For GCC < 11.3.0, for which this is not possible or need special
|
||||
treatment, this is dealt with in TOOLCHAIN_NEEDS_OLD_ISA_SPEC.
|
||||
|
||||
config TOOLCHAIN_NEEDS_OLD_ISA_SPEC
|
||||
def_bool y
|
||||
depends on TOOLCHAIN_NEEDS_EXPLICIT_ZICSR_ZIFENCEI
|
||||
# https://github.com/llvm/llvm-project/commit/22e199e6afb1263c943c0c0d4498694e15bf8a16
|
||||
# https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=d29f5d6ab513c52fd872f532c492e35ae9fd6671
|
||||
depends on (CC_IS_CLANG && CLANG_VERSION < 170000) || (CC_IS_GCC && GCC_VERSION < 110300)
|
||||
depends on CC_IS_GCC && GCC_VERSION < 110300
|
||||
help
|
||||
Certain versions of clang and GCC do not support zicsr and zifencei via
|
||||
-march. This option causes an older ISA spec compatible with these older
|
||||
versions of clang and GCC to be passed to GAS, which has the same result
|
||||
Certain versions of GCC do not support zicsr and zifencei via -march.
|
||||
This option causes an older ISA spec compatible with these older
|
||||
versions of GCC to be passed to GAS, which has the same result
|
||||
as passing zicsr and zifencei to -march.
|
||||
|
||||
config FPU
|
||||
|
|
|
|||
|
|
@ -130,8 +130,6 @@ config X86
|
|||
select ARCH_SUPPORTS_LTO_CLANG
|
||||
select ARCH_SUPPORTS_LTO_CLANG_THIN
|
||||
select ARCH_SUPPORTS_RT
|
||||
select ARCH_SUPPORTS_AUTOFDO_CLANG
|
||||
select ARCH_SUPPORTS_PROPELLER_CLANG if X86_64
|
||||
select ARCH_USE_BUILTIN_BSWAP
|
||||
select ARCH_USE_CMPXCHG_LOCKREF if X86_CX8
|
||||
select ARCH_USE_MEMTEST
|
||||
|
|
|
|||
|
|
@ -128,11 +128,6 @@ ifeq ($(CONFIG_X86_32),y)
|
|||
include $(srctree)/arch/x86/Makefile_32.cpu
|
||||
KBUILD_CFLAGS += $(cflags-y)
|
||||
|
||||
ifneq ($(call clang-min-version, 160000),y)
|
||||
# https://github.com/llvm/llvm-project/issues/53645
|
||||
KBUILD_CFLAGS += -ffreestanding
|
||||
endif
|
||||
|
||||
percpu_seg := fs
|
||||
else
|
||||
BITS := 64
|
||||
|
|
|
|||
|
|
@ -22,17 +22,7 @@
|
|||
CFI_OFFSET cs, IA32_SIGCONTEXT_cs
|
||||
CFI_OFFSET ss, IA32_SIGCONTEXT_ss
|
||||
CFI_OFFSET ds, IA32_SIGCONTEXT_ds
|
||||
/*
|
||||
* .cfi_offset eflags requires LLVM 16 or newer:
|
||||
*
|
||||
* https://github.com/llvm/llvm-project/commit/67bd3c58c0c7389e39c5a2f4d3b1a30459ccf5b7
|
||||
*
|
||||
* Check for 16.0.1 to ensure the support is present, as 16.0.0 may be a
|
||||
* prerelease version.
|
||||
*/
|
||||
#if defined(CONFIG_AS_IS_GNU) || (defined(CONFIG_AS_IS_LLVM) && CONFIG_AS_VERSION >= 160001)
|
||||
CFI_OFFSET eflags, IA32_SIGCONTEXT_flags
|
||||
#endif
|
||||
.endm
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -54,9 +54,8 @@ typedef struct user_i387_struct elf_fpregset_t;
|
|||
#define R_X86_64_GLOB_DAT 6 /* Create GOT entry */
|
||||
#define R_X86_64_JUMP_SLOT 7 /* Create PLT entry */
|
||||
#define R_X86_64_RELATIVE 8 /* Adjust by program base */
|
||||
#define R_X86_64_GOTPCREL 9 /* 32 bit signed pc relative offset to GOT */
|
||||
#define R_X86_64_GOTPCRELX 41
|
||||
#define R_X86_64_REX_GOTPCRELX 42
|
||||
#define R_X86_64_GOTPCREL 9 /* 32 bit signed pc relative
|
||||
offset to GOT */
|
||||
#define R_X86_64_32 10 /* Direct 32 bit zero extended */
|
||||
#define R_X86_64_32S 11 /* Direct 32 bit sign extended */
|
||||
#define R_X86_64_16 12 /* Direct 16 bit zero extended */
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@
|
|||
#include <linux/jump_label.h>
|
||||
#include <linux/random.h>
|
||||
#include <linux/memory.h>
|
||||
#include <linux/stackprotector.h>
|
||||
|
||||
#include <asm/text-patching.h>
|
||||
#include <asm/page.h>
|
||||
|
|
@ -132,20 +131,6 @@ static int __write_relocate_add(Elf64_Shdr *sechdrs,
|
|||
goto overflow;
|
||||
size = 4;
|
||||
break;
|
||||
#if defined(CONFIG_STACKPROTECTOR) && \
|
||||
defined(CONFIG_CC_IS_CLANG) && CONFIG_CLANG_VERSION < 170000
|
||||
case R_X86_64_REX_GOTPCRELX: {
|
||||
static unsigned long __percpu *const addr = &__stack_chk_guard;
|
||||
|
||||
if (sym->st_value != (u64)addr) {
|
||||
pr_err("%s: Unsupported GOTPCREL relocation\n", me->name);
|
||||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
val = (u64)&addr + rel[i].r_addend;
|
||||
fallthrough;
|
||||
}
|
||||
#endif
|
||||
case R_X86_64_PC32:
|
||||
case R_X86_64_PLT32:
|
||||
val -= (u64)loc;
|
||||
|
|
|
|||
|
|
@ -423,10 +423,7 @@ SECTIONS
|
|||
|
||||
STABS_DEBUG
|
||||
DWARF_DEBUG
|
||||
#ifdef CONFIG_PROPELLER_CLANG
|
||||
.llvm_bb_addr_map : { *(.llvm_bb_addr_map) }
|
||||
#endif
|
||||
|
||||
PROPELLER_DATA
|
||||
MODINFO
|
||||
ELF_DETAILS
|
||||
|
||||
|
|
|
|||
|
|
@ -1011,6 +1011,12 @@
|
|||
#define PERCPU_DECRYPTED_SECTION
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PROPELLER_CLANG
|
||||
#define PROPELLER_DATA \
|
||||
.llvm_bb_addr_map : { *(.llvm_bb_addr_map) }
|
||||
#else
|
||||
#define PROPELLER_DATA
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Default discarded sections.
|
||||
|
|
|
|||
|
|
@ -5,15 +5,6 @@
|
|||
|
||||
/* Compiler specific definitions for Clang compiler */
|
||||
|
||||
/*
|
||||
* Clang prior to 17 is being silly and considers many __cleanup() variables
|
||||
* as unused (because they are, their sole purpose is to go out of scope).
|
||||
*
|
||||
* https://github.com/llvm/llvm-project/commit/877210faa447f4cc7db87812f8ed80e398fedd61
|
||||
*/
|
||||
#undef __cleanup
|
||||
#define __cleanup(func) __maybe_unused __attribute__((__cleanup__(func)))
|
||||
|
||||
/* all clang versions usable with the kernel support KASAN ABI version 5 */
|
||||
#define KASAN_ABI_VERSION 5
|
||||
|
||||
|
|
@ -137,10 +128,10 @@
|
|||
#define __diag_clang_23(s)
|
||||
#endif
|
||||
|
||||
#define __diag_clang_13(s) __diag(s)
|
||||
#define __diag_clang_all(s) __diag(s)
|
||||
|
||||
#define __diag_ignore_all(option, comment) \
|
||||
__diag_clang(13, ignore, option)
|
||||
__diag_clang(all, ignore, option)
|
||||
|
||||
/*
|
||||
* clang has horrible behavior with "g" or "rm" constraints for asm
|
||||
|
|
|
|||
|
|
@ -118,10 +118,7 @@ config GCC_ASM_GOTO_OUTPUT_BROKEN
|
|||
config CC_HAS_ASM_GOTO_OUTPUT
|
||||
def_bool y
|
||||
depends on !GCC_ASM_GOTO_OUTPUT_BROKEN
|
||||
# Detect basic support
|
||||
depends on $(success,echo 'int foo(int x) { asm goto ("": "=r"(x) ::: bar); return x; bar: return 0; }' | $(CC) -x c - -c -o /dev/null)
|
||||
# Detect clang (< v17) scoped label issues
|
||||
depends on $(success,echo 'void b(void **);void* c(void);int f(void){{asm goto(""::::l0);return 0;l0:return 1;}void *x __attribute__((cleanup(b)))=c();{asm goto(""::::l1);return 2;l1:return 3;}}' | $(CC) -x c - -c -o /dev/null)
|
||||
|
||||
config CC_HAS_ASM_GOTO_TIED_OUTPUT
|
||||
depends on CC_HAS_ASM_GOTO_OUTPUT
|
||||
|
|
|
|||
|
|
@ -249,6 +249,13 @@ ifdef CONFIG_LTO_CLANG
|
|||
cmd_ld_single = $(if $(objtool-enabled)$(is-single-obj-m), ; $(LD) $(ld_flags) -r -o $(tmp-target) $@; mv $(tmp-target) $@)
|
||||
endif
|
||||
|
||||
ifdef CONFIG_LTO_CLANG_THIN_DIST
|
||||
# Save the _c_flags, sliently.
|
||||
quiet_cmd_save_c_flags =
|
||||
saved_c_flags = $(_c_flags) $(modkern_cflags)
|
||||
cmd_save_c_flags = printf '\n%s\n' 'saved_c_flags_$@ := $(call escsq,$(saved_c_flags))' >> $(dot-target).cmd
|
||||
endif
|
||||
|
||||
quiet_cmd_cc_o_c = CC $(quiet_modtag) $@
|
||||
cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< \
|
||||
$(cmd_ld_single) \
|
||||
|
|
@ -256,6 +263,7 @@ quiet_cmd_cc_o_c = CC $(quiet_modtag) $@
|
|||
|
||||
define rule_cc_o_c
|
||||
$(call cmd_and_fixdep,cc_o_c)
|
||||
$(call cmd,save_c_flags)
|
||||
$(call cmd,checksrc)
|
||||
$(call cmd,checkdoc)
|
||||
$(call cmd,gen_objtooldep)
|
||||
|
|
|
|||
|
|
@ -46,17 +46,9 @@ quiet_cmd_btf_ko = BTF [M] $@
|
|||
$(CONFIG_SHELL) $(srctree)/scripts/gen-btf.sh --btf_base $(objtree)/vmlinux $@; \
|
||||
fi;
|
||||
|
||||
# Same as newer-prereqs, but allows to exclude specified extra dependencies
|
||||
newer_prereqs_except = $(filter-out $(PHONY) $(1),$?)
|
||||
|
||||
# Same as if_changed, but allows to exclude specified extra dependencies
|
||||
if_changed_except = $(if $(call newer_prereqs_except,$(2))$(cmd-check), \
|
||||
$(cmd); \
|
||||
printf '%s\n' 'savedcmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:)
|
||||
|
||||
# Re-generate module BTFs if either module's .ko or vmlinux changed
|
||||
%.ko: %.o %.mod.o .module-common.o $(objtree)/scripts/module.lds $(and $(CONFIG_DEBUG_INFO_BTF_MODULES),$(KBUILD_BUILTIN),$(objtree)/vmlinux) FORCE
|
||||
+$(call if_changed_except,ld_ko_o,$(objtree)/vmlinux)
|
||||
+$(call if_changed,ld_ko_o)
|
||||
ifdef CONFIG_DEBUG_INFO_BTF_MODULES
|
||||
+$(if $(newer-prereqs),$(call cmd,btf_ko))
|
||||
endif
|
||||
|
|
|
|||
40
scripts/Makefile.thinlto
Normal file
40
scripts/Makefile.thinlto
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
PHONY := __default
|
||||
__default:
|
||||
|
||||
include include/config/auto.conf
|
||||
include $(srctree)/scripts/Kbuild.include
|
||||
include $(srctree)/scripts/Makefile.lib
|
||||
|
||||
native-objs := $(patsubst %.o,%.thinlto-native.o,$(call read-file, vmlinux.thinlto-index))
|
||||
|
||||
__default: $(native-objs)
|
||||
|
||||
# Generate .thinlto-native.o (obj) from .o (bitcode) and .thinlto.bc (summary) files
|
||||
# ---------------------------------------------------------------------------
|
||||
quiet_cmd_cc_o_bc = CC $(quiet_modtag) $@
|
||||
be_flags = $(shell sed -n '/saved_c_flags_/s/.*:= //p' \
|
||||
$(dir $(<)).$(notdir $(<)).cmd)
|
||||
cmd_cc_o_bc = \
|
||||
$(CC) $(be_flags) -x ir -fno-lto -Wno-unused-command-line-argument \
|
||||
-fthinlto-index=$(word 2, $^) -c -o $@ $<
|
||||
|
||||
targets += $(native-objs)
|
||||
$(native-objs): %.thinlto-native.o: %.o %.o.thinlto.bc FORCE
|
||||
$(call if_changed,cc_o_bc)
|
||||
|
||||
# Add FORCE to the prerequisites of a target to force it to be always rebuilt.
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
PHONY += FORCE
|
||||
FORCE:
|
||||
|
||||
# Read all saved command lines and dependencies for the $(targets) we
|
||||
# may be building above, using $(if_changed{,_dep}). As an
|
||||
# optimization, we don't need to read them if the target does not
|
||||
# exist, we will rebuild anyway in that case.
|
||||
|
||||
existing-targets := $(wildcard $(sort $(targets)))
|
||||
|
||||
-include $(foreach f, $(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
|
||||
|
||||
.PHONY: $(PHONY)
|
||||
82
scripts/Makefile.vmlinux_a
Normal file
82
scripts/Makefile.vmlinux_a
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
|
||||
PHONY := __default
|
||||
__default: vmlinux.a
|
||||
|
||||
include include/config/auto.conf
|
||||
include $(srctree)/scripts/Kbuild.include
|
||||
include $(srctree)/scripts/Makefile.lib
|
||||
|
||||
# Link of built-in-fixup.a
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
quiet_cmd_ar_builtin_fixup = AR $@
|
||||
cmd_ar_builtin_fixup = \
|
||||
rm -f $@; \
|
||||
$(AR) cDPrST $@ $(KBUILD_VMLINUX_OBJS); \
|
||||
$(AR) mPi $$($(AR) t $@ | sed -n 1p) $@ $$($(AR) t $@ | grep -F -f $(srctree)/scripts/head-object-list.txt)
|
||||
|
||||
targets += built-in-fixup.a
|
||||
built-in-fixup.a: $(KBUILD_VMLINUX_OBJS) scripts/head-object-list.txt FORCE
|
||||
$(call if_changed,ar_builtin_fixup)
|
||||
|
||||
ifdef CONFIG_LTO_CLANG_THIN_DIST
|
||||
|
||||
quiet_cmd_builtin.order = GEN $@
|
||||
cmd_builtin.order = $(AR) t $< > $@
|
||||
|
||||
targets += builtin.order
|
||||
builtin.order: built-in-fixup.a FORCE
|
||||
$(call if_changed,builtin.order)
|
||||
|
||||
quiet_cmd_ld_thinlto_index = LD $@
|
||||
cmd_ld_thinlto_index = \
|
||||
$(LD) $(KBUILD_LDFLAGS) -r --thinlto-index-only=$@ @$<
|
||||
|
||||
targets += vmlinux.thinlto-index
|
||||
vmlinux.thinlto-index: builtin.order FORCE
|
||||
$(call if_changed,ld_thinlto_index)
|
||||
|
||||
quiet_cmd_ar_vmlinux.a = GEN $@
|
||||
cmd_ar_vmlinux.a = \
|
||||
rm -f $@; \
|
||||
while read -r obj; do \
|
||||
if grep -Fqx $${obj} $(word 2, $^); then \
|
||||
echo $${obj%.o}.thinlto-native.o; \
|
||||
else \
|
||||
echo $${obj}; \
|
||||
fi; \
|
||||
done < $< | xargs $(AR) cDPrS --thin $@
|
||||
|
||||
targets += vmlinux.a
|
||||
vmlinux.a: builtin.order vmlinux.thinlto-index FORCE
|
||||
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.thinlto
|
||||
$(call if_changed,ar_vmlinux.a)
|
||||
|
||||
else
|
||||
|
||||
# vmlinux.a
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
targets += vmlinux.a
|
||||
vmlinux.a: built-in-fixup.a FORCE
|
||||
$(call if_changed,copy)
|
||||
|
||||
endif
|
||||
|
||||
# Add FORCE to the prerequisites of a target to force it to be always rebuilt.
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
PHONY += FORCE
|
||||
FORCE:
|
||||
|
||||
# Read all saved command lines and dependencies for the $(targets) we
|
||||
# may be building above, using $(if_changed{,_dep}). As an
|
||||
# optimization, we don't need to read them if the target does not
|
||||
# exist, we will rebuild anyway in that case.
|
||||
|
||||
existing-targets := $(wildcard $(sort $(targets)))
|
||||
|
||||
-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
|
||||
|
||||
.PHONY: $(PHONY)
|
||||
|
|
@ -135,16 +135,6 @@ KBUILD_CFLAGS += $(call cc-option, -Wno-stringop-truncation)
|
|||
KBUILD_CFLAGS += -Wno-override-init # alias for -Wno-initializer-overrides in clang
|
||||
|
||||
ifdef CONFIG_CC_IS_CLANG
|
||||
# Clang before clang-16 would warn on default argument promotions.
|
||||
ifneq ($(call clang-min-version, 160000),y)
|
||||
# Disable -Wformat
|
||||
KBUILD_CFLAGS += -Wno-format
|
||||
# Then re-enable flags that were part of the -Wformat group that aren't
|
||||
# problematic.
|
||||
KBUILD_CFLAGS += -Wformat-extra-args -Wformat-invalid-specifier
|
||||
KBUILD_CFLAGS += -Wformat-zero-length -Wnonnull
|
||||
KBUILD_CFLAGS += -Wformat-insufficient-args
|
||||
endif
|
||||
KBUILD_CFLAGS += -Wno-pointer-to-enum-cast
|
||||
KBUILD_CFLAGS += -Wno-tautological-constant-out-of-range-compare
|
||||
KBUILD_CFLAGS += -Wno-unaligned-access
|
||||
|
|
|
|||
|
|
@ -79,14 +79,15 @@ def run_analysis(entry):
|
|||
|
||||
|
||||
def main():
|
||||
try:
|
||||
args = parse_arguments()
|
||||
args = parse_arguments()
|
||||
|
||||
lock = multiprocessing.Lock()
|
||||
pool = multiprocessing.Pool(initializer=init, initargs=(lock, args))
|
||||
# Read JSON data into the datastore variable
|
||||
with open(args.path, "r") as f:
|
||||
datastore = json.load(f)
|
||||
# Read JSON data into the datastore variable
|
||||
with open(args.path) as f:
|
||||
datastore = json.load(f)
|
||||
|
||||
lock = multiprocessing.Lock()
|
||||
try:
|
||||
with multiprocessing.Pool(initializer=init, initargs=(lock, args)) as pool:
|
||||
pool.map(run_analysis, datastore)
|
||||
except BrokenPipeError:
|
||||
# Python flushes standard streams on exit; redirect remaining output
|
||||
|
|
|
|||
|
|
@ -297,9 +297,7 @@ static int conf_askvalue(struct symbol *sym, const char *def)
|
|||
line[1] = 0;
|
||||
|
||||
if (!sym_is_changeable(sym)) {
|
||||
printf("%s\n", def);
|
||||
line[0] = '\n';
|
||||
line[1] = 0;
|
||||
printf("%s\n", def ?: "");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -307,7 +305,7 @@ static int conf_askvalue(struct symbol *sym, const char *def)
|
|||
case oldconfig:
|
||||
case syncconfig:
|
||||
if (sym_has_value(sym)) {
|
||||
printf("%s\n", def);
|
||||
printf("%s\n", def ?: "");
|
||||
return 0;
|
||||
}
|
||||
/* fall through */
|
||||
|
|
|
|||
132
scripts/kconfig/kconfig-sym-check.pl
Executable file
132
scripts/kconfig/kconfig-sym-check.pl
Executable file
|
|
@ -0,0 +1,132 @@
|
|||
#!/usr/bin/env perl
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
my $srctree = shift @ARGV;
|
||||
unless (defined $srctree) {
|
||||
$srctree = `git rev-parse --show-toplevel 2>/dev/null`;
|
||||
chomp $srctree;
|
||||
my $msg = "Usage: $0 <srctree> [excludes file]\n";
|
||||
$msg .= "Please provide <srctree>.";
|
||||
$msg .= " Is it '$srctree'?" if $srctree;
|
||||
$msg .= "\n";
|
||||
die $msg;
|
||||
}
|
||||
my $kconfig_sym_check_excludes = defined $ARGV[0] ? $ARGV[0] : undef;
|
||||
|
||||
sub indent_depth {
|
||||
my ($ws) = @_;
|
||||
my $col = 0;
|
||||
for my $c (split //, $ws) {
|
||||
$col = $c eq "\t" ? int($col / 8) * 8 + 8 : $col + 1;
|
||||
}
|
||||
return $col;
|
||||
}
|
||||
|
||||
my @files = `git -C \Q$srctree\E ls-files '*Kconfig*' 2>/dev/null`;
|
||||
if (@files) {
|
||||
chomp @files;
|
||||
@files = map { "$srctree/$_" } @files;
|
||||
} else {
|
||||
@files = `find \Q$srctree\E -name '*Kconfig*'`;
|
||||
chomp @files;
|
||||
}
|
||||
|
||||
@files = grep { !m{/scripts/kconfig/tests/} } @files;
|
||||
|
||||
my %configs = ();
|
||||
my %refs = ();
|
||||
|
||||
foreach my $file (@files) {
|
||||
open F, $file or die "Cannot open $file: $!";
|
||||
|
||||
my $help = 0;
|
||||
my $help_level;
|
||||
my $level;
|
||||
|
||||
while (<F>) {
|
||||
chomp;
|
||||
|
||||
while (/\\\s*$/) {
|
||||
s/\\\s*$/ /;
|
||||
my $cont = <F> // last;
|
||||
chomp $cont;
|
||||
$_ .= $cont;
|
||||
}
|
||||
|
||||
next if /^\s*$/;
|
||||
next if /^\s*#/;
|
||||
|
||||
/^(\s*)/;
|
||||
$level = indent_depth($1);
|
||||
|
||||
if ($help && $level < $help_level) {
|
||||
$help = 0;
|
||||
}
|
||||
|
||||
next if ($help);
|
||||
|
||||
if (/^\s*(help|\-\-\-help\-\-\-)$/) {
|
||||
$help = 1;
|
||||
my $next;
|
||||
while (defined($next = <F>)) {
|
||||
last unless $next =~ /^\s*(?:#.*)?$/;
|
||||
}
|
||||
last unless defined $next;
|
||||
$next =~ /^(\s*)/;
|
||||
if (indent_depth($1) >= $level) {
|
||||
$help_level = indent_depth($1);
|
||||
} else {
|
||||
$help = 0;
|
||||
}
|
||||
$_ = $next;
|
||||
redo;
|
||||
}
|
||||
|
||||
if (/^\s*(config|menuconfig)\s+([a-zA-Z0-9_]+)\s*(#.*)?$/) {
|
||||
$configs{$2}++;
|
||||
next;
|
||||
}
|
||||
|
||||
if (/^\s*(default|def_bool|def_tristate|select|depends\s+on|imply|visible\s+if|range|if|bool|tristate|int|hex|string|prompt)\s+(.+)\s*$/) {
|
||||
my $s = $2;
|
||||
$s =~ s/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'//g;
|
||||
$s =~ s/#.*//;
|
||||
$s =~ s/\$\((?:[^()]*|\((?:[^()]*|\([^()]*\))*\))*\)//g;
|
||||
$s =~ s/%%[^%]*%%//g;
|
||||
my @syms = split /[^a-zA-Z0-9_]+/, $s;
|
||||
map {
|
||||
$refs{$_}++ if (/[a-zA-Z]/ && $_ ne "if" && $_ ne "y" && $_ ne "n" && $_ ne "m" && !/^0[xX][0-9a-fA-F]+$/);
|
||||
} @syms
|
||||
}
|
||||
}
|
||||
|
||||
close F;
|
||||
}
|
||||
|
||||
my %known_syms = ();
|
||||
if (defined $kconfig_sym_check_excludes) {
|
||||
my $file = $kconfig_sym_check_excludes;
|
||||
open(F, "<", $file) or die "Cannot open $file: $!";
|
||||
while (<F>) {
|
||||
chomp;
|
||||
next if /^\s*$/;
|
||||
next if /^\s*#/;
|
||||
$known_syms{$1}++ if (/^\s*([a-zA-Z0-9_]+)\s*(#.*)?$/);
|
||||
}
|
||||
}
|
||||
|
||||
my $ret = 0;
|
||||
foreach my $k (sort keys %refs) {
|
||||
next if (exists $configs{$k} || exists $known_syms{$k});
|
||||
|
||||
print "$k";
|
||||
print " - warning: '$k' is probably not what you want; Kconfig tristate literals are always lowercase ('n', 'y', 'm')" if ($k eq "N" || $k eq "Y" || $k eq "M");
|
||||
print "\n";
|
||||
|
||||
$ret = 1;
|
||||
}
|
||||
|
||||
exit $ret;
|
||||
|
|
@ -8,7 +8,7 @@ for symbols with unmet dependency.
|
|||
This was not working correctly for choice values because choice needs
|
||||
a bit different symbol computation.
|
||||
|
||||
This checks that no unneeded "# COFIG_... is not set" is contained in
|
||||
This checks that no unneeded "# CONFIG_... is not set" is contained in
|
||||
the .config file.
|
||||
|
||||
Related Linux commit: cb67ab2cd2b8abd9650292c986c79901e3073a59
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ llvm)
|
|||
if [ "$SRCARCH" = loongarch ]; then
|
||||
echo 18.0.0
|
||||
else
|
||||
echo 15.0.0
|
||||
echo 17.0.1
|
||||
fi
|
||||
;;
|
||||
rustc)
|
||||
|
|
|
|||
|
|
@ -765,6 +765,8 @@ static const char *const section_white_list[] =
|
|||
".gnu.lto*",
|
||||
".discard.*",
|
||||
".llvm.call-graph-profile", /* call graph */
|
||||
"__llvm_covfun",
|
||||
"__llvm_covmap",
|
||||
NULL
|
||||
};
|
||||
|
||||
|
|
@ -1487,13 +1489,22 @@ static void extract_crcs_for_object(const char *object, struct module *mod)
|
|||
char cmd_file[PATH_MAX];
|
||||
char *buf, *p;
|
||||
const char *base;
|
||||
int dirlen, ret;
|
||||
int dirlen, baselen_without_suffix, ret;
|
||||
|
||||
base = get_basename(object);
|
||||
dirlen = base - object;
|
||||
|
||||
ret = snprintf(cmd_file, sizeof(cmd_file), "%.*s.%s.cmd",
|
||||
dirlen, object, base);
|
||||
baselen_without_suffix = strlen(object) - dirlen - strlen(".o");
|
||||
|
||||
/*
|
||||
* When CONFIG_LTO_CLANG_THIN_DIST=y, the ELF is *.thinlto-native.o
|
||||
* but the symbol CRCs are recorded in *.o.cmd file.
|
||||
*/
|
||||
if (strends(object, ".thinlto-native.o"))
|
||||
baselen_without_suffix -= strlen(".thinlto-native");
|
||||
|
||||
ret = snprintf(cmd_file, sizeof(cmd_file), "%.*s.%.*s.o.cmd",
|
||||
dirlen, object, baselen_without_suffix, base);
|
||||
if (ret >= sizeof(cmd_file)) {
|
||||
error("%s: too long path was truncated\n", cmd_file);
|
||||
return;
|
||||
|
|
@ -1689,8 +1700,17 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
|
|||
|
||||
va_start(ap, fmt);
|
||||
len = vsnprintf(tmp, SZ, fmt, ap);
|
||||
buf_write(buf, tmp, len);
|
||||
va_end(ap);
|
||||
|
||||
if (len < 0) {
|
||||
perror("vsnprintf failed");
|
||||
exit(1);
|
||||
}
|
||||
if (len >= SZ)
|
||||
fatal("buf_printf output truncated for string %s: %d bytes needed, %d available\n",
|
||||
tmp, len + 1, SZ);
|
||||
|
||||
buf_write(buf, tmp, len);
|
||||
}
|
||||
|
||||
void buf_write(struct buffer *buf, const char *s, int len)
|
||||
|
|
|
|||
|
|
@ -121,6 +121,9 @@ _package-debug(){
|
|||
install -Dt "${debugdir}" -m644 vmlinux
|
||||
mkdir -p "${builddir}"
|
||||
ln -sr "${debugdir}/vmlinux" "${builddir}/vmlinux"
|
||||
|
||||
echo "Installing unstripped vDSO(s)..."
|
||||
${MAKE} INSTALL_MOD_PATH="${pkgdir}/usr" vdso_install
|
||||
}
|
||||
|
||||
for _p in "${pkgname[@]}"; do
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
Name: kernel
|
||||
Summary: The Linux Kernel
|
||||
Version: %(echo %{KERNELRELEASE} | sed -e 's/-/_/g')
|
||||
Release: %{pkg_release}
|
||||
Release: %{pkg_release}%{?dist}
|
||||
License: GPL
|
||||
Group: System Environment/Kernel
|
||||
Vendor: The Linux Community
|
||||
|
|
|
|||
|
|
@ -188,10 +188,8 @@ config INIT_ON_FREE_DEFAULT_ON
|
|||
synthetic workloads have measured as high as 8%.
|
||||
|
||||
config CC_HAS_ZERO_CALL_USED_REGS
|
||||
# supported by gcc-11 or newer and all supported versions of clang
|
||||
def_bool $(cc-option,-fzero-call-used-regs=used-gpr)
|
||||
# https://github.com/ClangBuiltLinux/linux/issues/1766
|
||||
# https://github.com/llvm/llvm-project/issues/59242
|
||||
depends on !CC_IS_CLANG || CLANG_VERSION > 150006
|
||||
|
||||
config ZERO_CALL_USED_REGS
|
||||
bool "Enable register zeroing on function exit"
|
||||
|
|
@ -216,8 +214,6 @@ menu "Bounds checking"
|
|||
config FORTIFY_SOURCE
|
||||
bool "Harden common str/mem functions against buffer overflows"
|
||||
depends on ARCH_HAS_FORTIFY_SOURCE
|
||||
# https://github.com/llvm/llvm-project/issues/53645
|
||||
depends on !X86_32 || !CC_IS_CLANG || CLANG_VERSION >= 160000
|
||||
help
|
||||
Detect overflows of buffers in common string and memory functions
|
||||
where the compiler can determine and validate the buffer sizes.
|
||||
|
|
@ -279,9 +275,6 @@ endmenu
|
|||
|
||||
config CC_HAS_RANDSTRUCT
|
||||
def_bool $(cc-option,-frandomize-layout-seed-file=/dev/null)
|
||||
# Randstruct was first added in Clang 15, but it isn't safe to use until
|
||||
# Clang 16 due to https://github.com/llvm/llvm-project/issues/60349
|
||||
depends on !CC_IS_CLANG || CLANG_VERSION >= 160000
|
||||
|
||||
choice
|
||||
prompt "Randomize layout of sensitive kernel structures"
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user