From: Randy Dunlap Date: Wed, 2 Jun 2021 03:53:28 +0000 (+1000) Subject: buildid: fix build when CONFIG_MODULES is not set X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=5cbeea3e5cec3602553232a333c470de8ca495f0;p=users%2Fjedix%2Flinux-maple.git buildid: fix build when CONFIG_MODULES is not set Omit the static_assert() when CONFIG_MODULES is not set/enabled. Fixes these build errors: ../kernel/kallsyms.c: In function `__sprint_symbol': ../include/linux/kernel.h:53:43: error: dereferencing pointer to incomplete type `struct module' #define typeof_member(T, m) typeof(((T*)0)->m) ^ ../include/linux/build_bug.h:78:41: error: static assertion failed: "sizeof(typeof_member(struct module, build_id)) == 20" #define __static_assert(expr, msg, ...) _Static_assert(expr, msg) ^ ../kernel/kallsyms.c:454:4: note: in expansion of macro `static_assert' static_assert(sizeof(typeof_member(struct module, build_id)) == 20); ^~~~~~~~~~~~~ Link: https://lkml.kernel.org/r/20210513171510.20328-1-rdunlap@infradead.org Signed-off-by: Randy Dunlap Signed-off-by: Andrew Morton Signed-off-by: Stephen Rothwell --- diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c index 92411224a4dac..1355b0404fcd0 100644 --- a/kernel/kallsyms.c +++ b/kernel/kallsyms.c @@ -451,7 +451,9 @@ static int __sprint_symbol(char *buffer, unsigned long address, #if IS_ENABLED(CONFIG_STACKTRACE_BUILD_ID) if (add_buildid && buildid) { /* build ID should match length of sprintf */ +#if IS_ENABLED(CONFIG_MODULES) static_assert(sizeof(typeof_member(struct module, build_id)) == 20); +#endif len += sprintf(buffer + len, " %20phN", buildid); } #endif