Skip to contentSkip to conversation

kbuild: avoid static_assert for genksyms

PATCH Applied Arnd Bergmann 4 participants 4 messages Dec 3, 2020 – Dec 10, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kbuild: avoid static_assert for genksyms

From: Arnd Bergmann <[email protected]>

genksyms does not know or care about the _Static_assert() built-in, and sometimes falls back to ignoring the later symbols, which causes undefined behavior such as

WARNING: modpost: EXPORT symbol "ethtool_set_ethtool_phy_ops" [vmlinux] version generation failed, symbol will not be versioned.
ld: net/ethtool/common.o: relocation R_AARCH64_ABS32 against `__crc_ethtool_set_ethtool_phy_ops' can not be used when making a shared object net/ethtool/common.o:(_ftrace_annotated_branch+0x0): dangerous relocation: unsupported relocation

Redefine static_assert for genksyms to avoid that.

---
 include/linux/build_bug.h | 5 +++++
 1 file changed, 5 insertions(+)
include/linux/build_bug.h +5 -0
index e3a0be2c90ad..7bb66e15b481 100644
@@ -77,4 +77,9 @@
 #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
 #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
 
+#ifdef __GENKSYMS__
+/* genksyms gets confused by _Static_assert */
+#define _Static_assert(expr, ...)
+#endif
+
 #endif	/* _LINUX_BUILD_BUG_H */
Signature · 1 line
2.27.0
#1 lore raw
Quoted 7 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

genksyms does not know or care about the _Static_assert() built-in, and sometimes falls back to ignoring the later symbols, which causes undefined behavior such as

Quoted 5 lines

WARNING: modpost: EXPORT symbol "ethtool_set_ethtool_phy_ops" [vmlinux] version generation failed, symbol will not be versioned.
ld: net/ethtool/common.o: relocation R_AARCH64_ABS32 against `__crc_ethtool_set_ethtool_phy_ops' can not be used when making a shared object net/ethtool/common.o:(_ftrace_annotated_branch+0x0): dangerous relocation: unsupported relocation

Redefine static_assert for genksyms to avoid that.

Please tell the CONFIG options needed to reproduce this. I do not see it.

Quoted 25 lines
---
 include/linux/build_bug.h | 5 +++++
 1 file changed, 5 insertions(+)
include/linux/build_bug.h +5 -1
index e3a0be2c90ad..7bb66e15b481 100644
@@ -77,4 +77,9 @@
 #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
 #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
 
+#ifdef __GENKSYMS__
+/* genksyms gets confused by _Static_assert */
+#define _Static_assert(expr, ...)
+#endif
+
 #endif /* _LINUX_BUILD_BUG_H */
--

2.27.0

Signature · 2 lines
Best Regards
Masahiro Yamada
#2 lore raw
Quoted 13 lines · Masahiro Yamada
Quoted 11 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

genksyms does not know or care about the _Static_assert() built-in, and sometimes falls back to ignoring the later symbols, which causes undefined behavior such as

WARNING: modpost: EXPORT symbol "ethtool_set_ethtool_phy_ops" [vmlinux] version generation failed, symbol will not be versioned.
ld: net/ethtool/common.o: relocation R_AARCH64_ABS32 against `__crc_ethtool_set_ethtool_phy_ops' can not be used when making a shared object net/ethtool/common.o:(_ftrace_annotated_branch+0x0): dangerous relocation: unsupported relocation

Quoted 6 lines
Quoted 1 line

Redefine static_assert for genksyms to avoid that.

Please tell the CONFIG options needed to reproduce this. I do not see it.

https://people.linaro.org/~ard.biesheuvel/randconfig-modversions-error

#3 lore raw
In reply to Arnd Bergmann
Quoted 24 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

genksyms does not know or care about the _Static_assert() built-in, and sometimes falls back to ignoring the later symbols, which causes undefined behavior such as

WARNING: modpost: EXPORT symbol "ethtool_set_ethtool_phy_ops" [vmlinux] version generation failed, symbol will not be versioned.
ld: net/ethtool/common.o: relocation R_AARCH64_ABS32 against `__crc_ethtool_set_ethtool_phy_ops' can not be used when making a shared object net/ethtool/common.o:(_ftrace_annotated_branch+0x0): dangerous relocation: unsupported relocation

Redefine static_assert for genksyms to avoid that.

---
 include/linux/build_bug.h | 5 +++++
 1 file changed, 5 insertions(+)
include/linux/build_bug.h +0 -0
index e3a0be2c90ad..7bb66e15b481 100644

include/linux/build_bug.h line 84

Quoted 8 lines
include/linux/build_bug.h +5 -0
@@ -77,4 +77,9 @@
 #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
 #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
 
+#ifdef __GENKSYMS__
+/* genksyms gets confused by _Static_assert */
+#define _Static_assert(expr, ...)
+#endif
+

I had sent

	https://lkml.kernel.org/r/[email protected]

3 days before your patch. :-)

I guess what you propose is simpler, but might still have corner cases where we still get warnings. In particular, if some file (for whatever reason) does not include build_bug.h and uses a raw _Static_assert(), then we still get warnings. E.g. I see 1 user of raw _Static_assert() (drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h ).

In the end I don't mind either way, as long as those warnings are fixed in 5.11. :-)

Thanks,
-- Marco