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

Pull Kbuild fixes from Masahiro Yamada:

- Fix UNUSED_KSYMS_WHITELIST for Clang LTO

- Make -s builds really silent irrespective of V= option

- Fix build error when SUBLEVEL or PATCHLEVEL is empty

* tag 'kbuild-fixes-v5.12' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
kbuild: Fix <linux/version.h> for empty SUBLEVEL or PATCHLEVEL again
kbuild: make -s option take precedence over V=1
ia64: remove redundant READELF from arch/ia64/Makefile
kbuild: do not include include/config/auto.conf from adjust_autoksyms.sh
kbuild: fix UNUSED_KSYMS_WHITELIST for Clang LTO
kbuild: lto: add _mcount to list of used symbols

+31 -21
+5 -2
Makefile
··· 96 96 97 97 ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),) 98 98 quiet=silent_ 99 + KBUILD_VERBOSE = 0 99 100 endif 100 101 101 102 export quiet Q KBUILD_VERBOSE ··· 1284 1283 define filechk_version.h 1285 1284 if [ $(SUBLEVEL) -gt 255 ]; then \ 1286 1285 echo \#define LINUX_VERSION_CODE $(shell \ 1287 - expr $(VERSION) \* 65536 + 0$(PATCHLEVEL) \* 256 + 255); \ 1286 + expr $(VERSION) \* 65536 + $(PATCHLEVEL) \* 256 + 255); \ 1288 1287 else \ 1289 1288 echo \#define LINUX_VERSION_CODE $(shell \ 1290 - expr $(VERSION) \* 65536 + 0$(PATCHLEVEL) \* 256 + $(SUBLEVEL)); \ 1289 + expr $(VERSION) \* 65536 + $(PATCHLEVEL) \* 256 + $(SUBLEVEL)); \ 1291 1290 fi; \ 1292 1291 echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + \ 1293 1292 ((c) > 255 ? 255 : (c)))'; \ ··· 1296 1295 echo \#define LINUX_VERSION_SUBLEVEL $(SUBLEVEL) 1297 1296 endef 1298 1297 1298 + $(version_h): PATCHLEVEL := $(if $(PATCHLEVEL), $(PATCHLEVEL), 0) 1299 + $(version_h): SUBLEVEL := $(if $(SUBLEVEL), $(SUBLEVEL), 0) 1299 1300 $(version_h): FORCE 1300 1301 $(call filechk,version.h) 1301 1302
-1
arch/ia64/Makefile
··· 14 14 KBUILD_DEFCONFIG := generic_defconfig 15 15 16 16 NM := $(CROSS_COMPILE)nm -B 17 - READELF := $(CROSS_COMPILE)readelf 18 17 19 18 CHECKFLAGS += -D__ia64=1 -D__ia64__=1 -D_LP64 -D__LP64__ 20 19
-1
init/Kconfig
··· 2283 2283 config UNUSED_KSYMS_WHITELIST 2284 2284 string "Whitelist of symbols to keep in ksymtab" 2285 2285 depends on TRIM_UNUSED_KSYMS 2286 - default "scripts/lto-used-symbollist.txt" if LTO_CLANG 2287 2286 help 2288 2287 By default, all unused exported symbols will be un-exported from the 2289 2288 build when TRIM_UNUSED_KSYMS is selected.
-3
scripts/adjust_autoksyms.sh
··· 34 34 ;; 35 35 esac 36 36 37 - # We need access to CONFIG_ symbols 38 - . include/config/auto.conf 39 - 40 37 # Generate a new symbol list file 41 38 $CONFIG_SHELL $srctree/scripts/gen_autoksyms.sh "$new_ksyms_file" 42 39
+26 -9
scripts/gen_autoksyms.sh
··· 19 19 # We need access to CONFIG_ symbols 20 20 . include/config/auto.conf 21 21 22 - ksym_wl=/dev/null 22 + needed_symbols= 23 + 24 + # Special case for modversions (see modpost.c) 25 + if [ -n "$CONFIG_MODVERSIONS" ]; then 26 + needed_symbols="$needed_symbols module_layout" 27 + fi 28 + 29 + # With CONFIG_LTO_CLANG, LLVM bitcode has not yet been compiled into a binary 30 + # when the .mod files are generated, which means they don't yet contain 31 + # references to certain symbols that will be present in the final binaries. 32 + if [ -n "$CONFIG_LTO_CLANG" ]; then 33 + # intrinsic functions 34 + needed_symbols="$needed_symbols memcpy memmove memset" 35 + # ftrace 36 + needed_symbols="$needed_symbols _mcount" 37 + # stack protector symbols 38 + needed_symbols="$needed_symbols __stack_chk_fail __stack_chk_guard" 39 + fi 40 + 41 + ksym_wl= 23 42 if [ -n "$CONFIG_UNUSED_KSYMS_WHITELIST" ]; then 24 43 # Use 'eval' to expand the whitelist path and check if it is relative 25 44 eval ksym_wl="$CONFIG_UNUSED_KSYMS_WHITELIST" ··· 59 40 EOT 60 41 61 42 [ -f modules.order ] && modlist=modules.order || modlist=/dev/null 62 - sed 's/ko$/mod/' $modlist | 63 - xargs -n1 sed -n -e '2{s/ /\n/g;/^$/!p;}' -- | 64 - cat - "$ksym_wl" | 43 + 44 + { 45 + sed 's/ko$/mod/' $modlist | xargs -n1 sed -n -e '2p' 46 + echo "$needed_symbols" 47 + [ -n "$ksym_wl" ] && cat "$ksym_wl" 48 + } | sed -e 's/ /\n/g' | sed -n -e '/^$/!p' | 65 49 # Remove the dot prefix for ppc64; symbol names with a dot (.) hold entry 66 50 # point addresses. 67 51 sed -e 's/^\.//' | 68 52 sort -u | 69 53 sed -e 's/\(.*\)/#define __KSYM_\1 1/' >> "$output_file" 70 - 71 - # Special case for modversions (see modpost.c) 72 - if [ -n "$CONFIG_MODVERSIONS" ]; then 73 - echo "#define __KSYM_module_layout 1" >> "$output_file" 74 - fi
-5
scripts/lto-used-symbollist.txt
··· 1 - memcpy 2 - memmove 3 - memset 4 - __stack_chk_fail 5 - __stack_chk_guard