(cc Sami, Masahiro)
This appears to be an interaction with gendwarfksyms:
# AS arch/x86/entry/entry.o
clang-15 -Wp,-MMD,arch/x86/entry/.entry.o.d -nostdinc
-I/usr/local/google/home/ardb/linux/arch/x86/include
-I./arch/x86/include/generated
-I/usr/local/google/home/ardb/linux/include -I./include
-I/usr/local/google/home/ardb/linux/arch/x86/include/uapi
-I./arch/x86/include/generated/uapi
-I/usr/local/google/home/ardb/linux/include/uapi
-I./include/generated/uapi -include
/usr/local/google/home/ardb/linux/include/linux/compiler-version.h
-include /usr/local/google/home/ardb/linux/include/linux/kconfig.h
-D__KERNEL__ --target=x86_64-linux-gnu -fintegrated-as
-Werror=unknown-warning-option -Werror=ignored-optimization-argument
-Werror=option-ignored -Werror=unused-command-line-argument
-fmacro-prefix-map=/usr/local/google/home/ardb/linux/= -D__ASSEMBLY__
-fno-PIE -m64 -g -gdwarf-4
-I/usr/local/google/home/ardb/linux/arch/x86/entry -Iarch/x86/entry
-DKBUILD_MODFILE='"arch/x86/entry/entry"' -DKBUILD_MODNAME='"entry"'
-D__KBUILD_MODNAME=kmod_entry -c -o arch/x86/entry/entry.o
/usr/local/google/home/ardb/linux/arch/x86/entry/entry.S
# cmd_gen_symversions_S arch/x86/entry/entry.o
if llvm-nm-15 arch/x86/entry/entry.o 2>/dev/null | grep -q '
__export_symbol_'; then { echo "#include <linux/kernel.h>" ; echo
"#include <linux/string.h>" ; echo "#include <asm/asm-prototypes.h>" ;
llvm-nm-15 arch/x86/entry/entry.o | sed -n 's/.*
__export_symbol_\(.*\)/EXPORT_SYMBOL(\1);/p' ; } | clang-15 ... -c -o
arch/x86/entry/entry.gendwarfksyms.o -xc -; llvm-nm-15
arch/x86/entry/entry.o | sed -n 's/.* __export_symbol_\(.*\)/\1/p' |
./scripts/gendwarfksyms/gendwarfksyms
arch/x86/entry/entry.gendwarfksyms.o >> arch/x86/entry/.entry.o.cmd;
fi
<stdin>:4:15: error: use of undeclared identifier '__ref_stack_chk_guard'
EXPORT_SYMBOL(__ref_stack_chk_guard);
^
1 error generated.
The issue here is that we deliberately hide __ref_stack_chk_guard from
the compiler, because Clang will otherwise generate incorrect code.
[0]
I managed to work around this issue using the hack below, but I'm not
too familiar with the gendwarfksyms code, so I'll leave it up to Sami
and Masahiro to decide whether this is the right approach before
sending out a patch.
--- a/arch/x86/include/asm/asm-prototypes.h
+++ b/arch/x86/include/asm/asm-prototypes.h
@@ -20,6 +20,7 @@
extern void cmpxchg8b_emu(void);
#endif
-#if defined(__GENKSYMS__) && defined(CONFIG_STACKPROTECTOR)
+#if (defined(__GENKSYMS__) || defined(__GENDWARFKSYMS__)) \
+ && defined(CONFIG_STACKPROTECTOR)
extern unsigned long __ref_stack_chk_guard;
#endif
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -311,7 +311,8 @@
ifdef CONFIG_GENDWARFKSYMS
cmd_gensymtypes_S = \
$(getasmexports) | \
- $(CC) $(c_flags) -c -o $(@:.o=.gendwarfksyms.o) -xc -; \
+ $(CC) -D__GENDWARFKSYMS__ \
+ $(c_flags) -c -o $(@:.o=.gendwarfksyms.o) -xc -; \
$(call getexportsymbols,\1) | \
$(gendwarfksyms) $(@:.o=.gendwarfksyms.o)
else
(Note that simply #define'ing __GENKSYMS__ here and relying on that in
asm-prototypes.h doesn't work.)
[0] 577c134d311b ("x86/stackprotector: Work around strict Clang TLS
symbol requirements")