All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH -next] buildid: fix build when CONFIG_MODULES is not set
@ 2021-05-13 17:15 Randy Dunlap
  2021-05-14  6:54 ` Stephen Boyd
  0 siblings, 1 reply; 2+ messages in thread
From: Randy Dunlap @ 2021-05-13 17:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Randy Dunlap, Stephen Boyd, Andrew Morton

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);
    ^~~~~~~~~~~~~

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Stephen Boyd <swboyd@chromium.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
---
 kernel/kallsyms.c |    2 ++
 1 file changed, 2 insertions(+)

--- linux-next-20210513.orig/kernel/kallsyms.c
+++ linux-next-20210513/kernel/kallsyms.c
@@ -451,7 +451,9 @@ static int __sprint_symbol(char *buffer,
 #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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH -next] buildid: fix build when CONFIG_MODULES is not set
  2021-05-13 17:15 [PATCH -next] buildid: fix build when CONFIG_MODULES is not set Randy Dunlap
@ 2021-05-14  6:54 ` Stephen Boyd
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Boyd @ 2021-05-14  6:54 UTC (permalink / raw)
  To: Randy Dunlap, linux-kernel; +Cc: Andrew Morton

Quoting Randy Dunlap (2021-05-13 10:15:10)
> 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);
>     ^~~~~~~~~~~~~
>
> Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
> Cc: Stephen Boyd <swboyd@chromium.org>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> ---

Reviewed-by: Stephen Boyd <swboyd@chromium.org>

Thanks. I didn't realize that there was an ifdef around the definition
of 'struct module'.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-14  6:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-13 17:15 [PATCH -next] buildid: fix build when CONFIG_MODULES is not set Randy Dunlap
2021-05-14  6:54 ` Stephen Boyd

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.