Kbuild fixes for v6.1

- Fix CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y compile error for
    the combination of Clang >= 14 and GAS <= 2.35.
 
  - Drop vmlinux.bz2 from the rpm package as it just annoyingly increased
    the package size.
 
  - Fix modpost error under build environments using musl.
 
  - Make *.ll files keep value names for easier debugging
 
  - Fix single directory build
 
  - Prevent RISC-V from selecting the broken DWARF5 support when Clang
    and GAS are used together.
 -----BEGIN PGP SIGNATURE-----
 
 iQJJBAABCgAzFiEEbmPs18K1szRHjPqEPYsBB53g2wYFAmNMSCcVHG1hc2FoaXJv
 eUBrZXJuZWwub3JnAAoJED2LAQed4NsGuVsP/j9FBN3x9S14gAHpu4BAFLK0s31W
 A5sGtmEb1keLqW4oY7/5bcr8KgIrY1extJBeSOJHLB1z/cfU7CHd7bl3+oadZH+z
 BNQ7F9SAHm9GuZoM58TMmC5/Eq0a45bqEP32wvoscyrFQ0ka11aQw/lOZmVTYSgO
 NrTHUSD6NmJCG8hbMiJAH8ch+fziSR0JXOomOwJDxs63aXHhavjZ3z7pgySnuPav
 PD46QtKtpjH8H+gx4nJMqDWjaukGlq7+kVIHhZh3oC5KU23UfUc3d3U+Lpati4+w
 Ggl1pmR5iMsYioQ/MaC58hb06WkamAYRfxKWXvpzEAVGIHF+xhMdGybK4FOPQkQh
 J9Rb358LD1d/QtH6C77wajaEj1FvQLaOQ8CHUDSzjgGwJuz+qrpI8kwtgRxJCXgp
 0+2YQxdfWR2kJ9W7lnyguVjM7AYebqS7bCGm2fDPU92NWftw4y2TJii1v10BCD/N
 dB3orKHPp3mosAS2SdTXgMYYMlzFMzgma0PzibWvm4DE4tHtndRMvW/8c5UyB8uk
 ganuHOUg8Vup79OiANSD6lJrzq0fZofvD3euD61mis6s39GAeHvr5rlwy0xOoN8A
 TgOBu2DQFUKrlZH2m4F+hEBzCz26HTkg8+S5DNpb7Qr2EKDlLPT3xjwhQlooipNc
 KuZNXoR6wEstepn/
 =EZAr
 -----END PGP SIGNATURE-----

Merge tag 'kbuild-fixes-v6.1' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild

Pull Kbuild fixes from Masahiro Yamada:

 - Fix CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y compile error for the
   combination of Clang >= 14 and GAS <= 2.35.

 - Drop vmlinux.bz2 from the rpm package as it just annoyingly increased
   the package size.

 - Fix modpost error under build environments using musl.

 - Make *.ll files keep value names for easier debugging

 - Fix single directory build

 - Prevent RISC-V from selecting the broken DWARF5 support when Clang
   and GAS are used together.

* tag 'kbuild-fixes-v6.1' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
  lib/Kconfig.debug: Add check for non-constant .{s,u}leb128 support to DWARF5
  kbuild: fix single directory build
  kbuild: add -fno-discard-value-names to cmd_cc_ll_c
  scripts/clang-tools: Convert clang-tidy args to list
  modpost: put modpost options before argument
  kbuild: Stop including vmlinux.bz2 in the rpm's
  Kconfig.debug: add toolchain checks for DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
  Kconfig.debug: simplify the dependency of DEBUG_INFO_DWARF4/5
This commit is contained in:
Linus Torvalds 2022-10-16 11:12:22 -07:00
commit 2df76606db
6 changed files with 18 additions and 11 deletions

View File

@ -1979,6 +1979,8 @@ endif
single-goals := $(addprefix $(build-dir)/, $(single-no-ko)) single-goals := $(addprefix $(build-dir)/, $(single-no-ko))
KBUILD_MODULES := 1
endif endif
# Preset locale variables to speed up the build process. Limit locale # Preset locale variables to speed up the build process. Limit locale

View File

@ -231,6 +231,11 @@ config DEBUG_INFO
in the "Debug information" choice below, indicating that debug in the "Debug information" choice below, indicating that debug
information will be generated for build targets. information will be generated for build targets.
# Clang is known to generate .{s,u}leb128 with symbol deltas with DWARF5, which
# some targets may not support: https://sourceware.org/bugzilla/show_bug.cgi?id=27215
config AS_HAS_NON_CONST_LEB128
def_bool $(as-instr,.uleb128 .Lexpr_end4 - .Lexpr_start3\n.Lexpr_start3:\n.Lexpr_end4:)
choice choice
prompt "Debug information" prompt "Debug information"
depends on DEBUG_KERNEL depends on DEBUG_KERNEL
@ -253,6 +258,7 @@ config DEBUG_INFO_NONE
config DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT config DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
bool "Rely on the toolchain's implicit default DWARF version" bool "Rely on the toolchain's implicit default DWARF version"
select DEBUG_INFO select DEBUG_INFO
depends on !CC_IS_CLANG || AS_IS_LLVM || CLANG_VERSION < 140000 || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128)
help help
The implicit default version of DWARF debug info produced by a The implicit default version of DWARF debug info produced by a
toolchain changes over time. toolchain changes over time.
@ -264,7 +270,7 @@ config DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
config DEBUG_INFO_DWARF4 config DEBUG_INFO_DWARF4
bool "Generate DWARF Version 4 debuginfo" bool "Generate DWARF Version 4 debuginfo"
select DEBUG_INFO select DEBUG_INFO
depends on !CC_IS_CLANG || (CC_IS_CLANG && (AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502))) depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)
help help
Generate DWARF v4 debug info. This requires gcc 4.5+, binutils 2.35.2 Generate DWARF v4 debug info. This requires gcc 4.5+, binutils 2.35.2
if using clang without clang's integrated assembler, and gdb 7.0+. if using clang without clang's integrated assembler, and gdb 7.0+.
@ -276,7 +282,7 @@ config DEBUG_INFO_DWARF4
config DEBUG_INFO_DWARF5 config DEBUG_INFO_DWARF5
bool "Generate DWARF Version 5 debuginfo" bool "Generate DWARF Version 5 debuginfo"
select DEBUG_INFO select DEBUG_INFO
depends on !CC_IS_CLANG || (CC_IS_CLANG && (AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502))) depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128)
help help
Generate DWARF v5 debug info. Requires binutils 2.35.2, gcc 5.0+ (gcc Generate DWARF v5 debug info. Requires binutils 2.35.2, gcc 5.0+ (gcc
5.0+ accepts the -gdwarf-5 flag but only had partial support for some 5.0+ accepts the -gdwarf-5 flag but only had partial support for some

View File

@ -140,7 +140,7 @@ $(obj)/%.symtypes : $(src)/%.c FORCE
# LLVM assembly # LLVM assembly
# Generate .ll files from .c # Generate .ll files from .c
quiet_cmd_cc_ll_c = CC $(quiet_modtag) $@ quiet_cmd_cc_ll_c = CC $(quiet_modtag) $@
cmd_cc_ll_c = $(CC) $(c_flags) -emit-llvm -S -o $@ $< cmd_cc_ll_c = $(CC) $(c_flags) -emit-llvm -S -fno-discard-value-names -o $@ $<
$(obj)/%.ll: $(src)/%.c FORCE $(obj)/%.ll: $(src)/%.c FORCE
$(call if_changed_dep,cc_ll_c) $(call if_changed_dep,cc_ll_c)

View File

@ -119,7 +119,7 @@ quiet_cmd_modpost = MODPOST $@
echo >&2 "WARNING: $(missing-input) is missing."; \ echo >&2 "WARNING: $(missing-input) is missing."; \
echo >&2 " Modules may not have dependencies or modversions."; \ echo >&2 " Modules may not have dependencies or modversions."; \
echo >&2 " You may get many unresolved symbol warnings.";) \ echo >&2 " You may get many unresolved symbol warnings.";) \
sed 's/ko$$/o/' $(or $(modorder-if-needed), /dev/null) | $(MODPOST) $(modpost-args) $(vmlinux.o-if-present) -T - sed 's/ko$$/o/' $(or $(modorder-if-needed), /dev/null) | $(MODPOST) $(modpost-args) -T - $(vmlinux.o-if-present)
targets += $(output-symdump) targets += $(output-symdump)
$(output-symdump): $(modorder-if-needed) $(vmlinux.o-if-present) $(moudle.symvers-if-present) $(MODPOST) FORCE $(output-symdump): $(modorder-if-needed) $(vmlinux.o-if-present) $(moudle.symvers-if-present) $(MODPOST) FORCE

View File

@ -45,13 +45,14 @@ def init(l, a):
def run_analysis(entry): def run_analysis(entry):
# Disable all checks, then re-enable the ones we want # Disable all checks, then re-enable the ones we want
checks = "-checks=-*," checks = []
checks.append("-checks=-*")
if args.type == "clang-tidy": if args.type == "clang-tidy":
checks += "linuxkernel-*" checks.append("linuxkernel-*")
else: else:
checks += "clang-analyzer-*" checks.append("clang-analyzer-*")
checks += ",-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling" checks.append("-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling")
p = subprocess.run(["clang-tidy", "-p", args.path, checks, entry["file"]], p = subprocess.run(["clang-tidy", "-p", args.path, ",".join(checks), entry["file"]],
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT, stderr=subprocess.STDOUT,
cwd=entry["directory"]) cwd=entry["directory"])

View File

@ -97,8 +97,6 @@ $M $MAKE %{?_smp_mflags} INSTALL_MOD_PATH=%{buildroot} modules_install
$MAKE %{?_smp_mflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install $MAKE %{?_smp_mflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install
cp System.map %{buildroot}/boot/System.map-$KERNELRELEASE cp System.map %{buildroot}/boot/System.map-$KERNELRELEASE
cp .config %{buildroot}/boot/config-$KERNELRELEASE cp .config %{buildroot}/boot/config-$KERNELRELEASE
bzip2 -9 --keep vmlinux
mv vmlinux.bz2 %{buildroot}/boot/vmlinux-$KERNELRELEASE.bz2
$S$M rm -f %{buildroot}/lib/modules/$KERNELRELEASE/build $S$M rm -f %{buildroot}/lib/modules/$KERNELRELEASE/build
$S$M rm -f %{buildroot}/lib/modules/$KERNELRELEASE/source $S$M rm -f %{buildroot}/lib/modules/$KERNELRELEASE/source
$S$M mkdir -p %{buildroot}/usr/src/kernels/$KERNELRELEASE $S$M mkdir -p %{buildroot}/usr/src/kernels/$KERNELRELEASE