Skip to content

Commit 06d5d30

Browse files
committed
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
2 parents cd27845 + 207da4c commit 06d5d30

File tree

6 files changed

+31
-21
lines changed

6 files changed

+31
-21
lines changed

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ endif
9696

9797
ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)
9898
quiet=silent_
99+
KBUILD_VERBOSE = 0
99100
endif
100101

101102
export quiet Q KBUILD_VERBOSE
@@ -1283,10 +1284,10 @@ endef
12831284
define filechk_version.h
12841285
if [ $(SUBLEVEL) -gt 255 ]; then \
12851286
echo \#define LINUX_VERSION_CODE $(shell \
1286-
expr $(VERSION) \* 65536 + 0$(PATCHLEVEL) \* 256 + 255); \
1287+
expr $(VERSION) \* 65536 + $(PATCHLEVEL) \* 256 + 255); \
12871288
else \
12881289
echo \#define LINUX_VERSION_CODE $(shell \
1289-
expr $(VERSION) \* 65536 + 0$(PATCHLEVEL) \* 256 + $(SUBLEVEL)); \
1290+
expr $(VERSION) \* 65536 + $(PATCHLEVEL) \* 256 + $(SUBLEVEL)); \
12901291
fi; \
12911292
echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + \
12921293
((c) > 255 ? 255 : (c)))'; \
@@ -1295,6 +1296,8 @@ define filechk_version.h
12951296
echo \#define LINUX_VERSION_SUBLEVEL $(SUBLEVEL)
12961297
endef
12971298

1299+
$(version_h): PATCHLEVEL := $(if $(PATCHLEVEL), $(PATCHLEVEL), 0)
1300+
$(version_h): SUBLEVEL := $(if $(SUBLEVEL), $(SUBLEVEL), 0)
12981301
$(version_h): FORCE
12991302
$(call filechk,version.h)
13001303

arch/ia64/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
KBUILD_DEFCONFIG := generic_defconfig
1515

1616
NM := $(CROSS_COMPILE)nm -B
17-
READELF := $(CROSS_COMPILE)readelf
1817

1918
CHECKFLAGS += -D__ia64=1 -D__ia64__=1 -D_LP64 -D__LP64__
2019

init/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2283,7 +2283,6 @@ config TRIM_UNUSED_KSYMS
22832283
config UNUSED_KSYMS_WHITELIST
22842284
string "Whitelist of symbols to keep in ksymtab"
22852285
depends on TRIM_UNUSED_KSYMS
2286-
default "scripts/lto-used-symbollist.txt" if LTO_CLANG
22872286
help
22882287
By default, all unused exported symbols will be un-exported from the
22892288
build when TRIM_UNUSED_KSYMS is selected.

scripts/adjust_autoksyms.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ case "$KBUILD_VERBOSE" in
3434
;;
3535
esac
3636

37-
# We need access to CONFIG_ symbols
38-
. include/config/auto.conf
39-
4037
# Generate a new symbol list file
4138
$CONFIG_SHELL $srctree/scripts/gen_autoksyms.sh "$new_ksyms_file"
4239

scripts/gen_autoksyms.sh

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,26 @@ esac
1919
# We need access to CONFIG_ symbols
2020
. include/config/auto.conf
2121

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=
2342
if [ -n "$CONFIG_UNUSED_KSYMS_WHITELIST" ]; then
2443
# Use 'eval' to expand the whitelist path and check if it is relative
2544
eval ksym_wl="$CONFIG_UNUSED_KSYMS_WHITELIST"
@@ -40,16 +59,14 @@ cat > "$output_file" << EOT
4059
EOT
4160

4261
[ -f modules.order ] && modlist=modules.order || modlist=/dev/null
43-
sed 's/ko$/mod/' $modlist |
44-
xargs -n1 sed -n -e '2{s/ /\n/g;/^$/!p;}' -- |
45-
cat - "$ksym_wl" |
62+
63+
{
64+
sed 's/ko$/mod/' $modlist | xargs -n1 sed -n -e '2p'
65+
echo "$needed_symbols"
66+
[ -n "$ksym_wl" ] && cat "$ksym_wl"
67+
} | sed -e 's/ /\n/g' | sed -n -e '/^$/!p' |
4668
# Remove the dot prefix for ppc64; symbol names with a dot (.) hold entry
4769
# point addresses.
4870
sed -e 's/^\.//' |
4971
sort -u |
5072
sed -e 's/\(.*\)/#define __KSYM_\1 1/' >> "$output_file"
51-
52-
# Special case for modversions (see modpost.c)
53-
if [ -n "$CONFIG_MODVERSIONS" ]; then
54-
echo "#define __KSYM_module_layout 1" >> "$output_file"
55-
fi

scripts/lto-used-symbollist.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)