Skip to contentSkip to conversation

kbuild: modpost: Explicitly warn about unprototyped symbols

PATCH In review Mark Brown 2 participants 3 messages Jun 7, 2021 – Jun 22, 2021 Kbuild

lore
Share & tools
lore

Mark Brown

author
#0 lore raw

PATCH v2 1/1 kbuild: modpost: Explicitly warn about unprototyped symbols

One common cause of modpost version generation failures is a failure to prototype exported assembly functions - the tooling requires this for exported functions even if they are not and should not be called from C code in order to do the version mangling for symbols. Unfortunately the error message is currently rather abstruse, simply saying that "version generation failed" and even diving into the code doesn't directly show what's going on since there's several steps between the problem and it being observed.

Provide an explicit hint as to the likely cause of a version generation failure to help anyone who runs into this in future more readily diagnose and fix the problem.

---

v2:
- Reword and reformat error message.
- Fix duplicated is.

 scripts/mod/modpost.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
scripts/mod/modpost.c +5 -2
index 3e623ccc020b..270a7df898e2 100644
@@ -660,8 +660,11 @@ static void handle_modversion(const struct module *mod,
 	unsigned int crc;
 
 	if (sym->st_shndx == SHN_UNDEF) {
-		warn("EXPORT symbol \"%s\" [%s%s] version generation failed, symbol will not be versioned.\n",
-		     symname, mod->name, mod->is_vmlinux ? "" : ".ko");
+		warn("EXPORT symbol \"%s\" [%s%s] version ...\n"
+		     "Is \"%s\" prototyped in <asm/asm-prototypes.h>?\n",
+		     symname, mod->name, mod->is_vmlinux ? "" : ".ko",
+		     symname);
+
 		return;
 	}
 
Signature · 1 line
2.20.1
#1 lore raw
Quoted 10 lines · Mark Brown

One common cause of modpost version generation failures is a failure to prototype exported assembly functions - the tooling requires this for exported functions even if they are not and should not be called from C code in order to do the version mangling for symbols. Unfortunately the error message is currently rather abstruse, simply saying that "version generation failed" and even diving into the code doesn't directly show what's going on since there's several steps between the problem and it being observed.

Quoted 6 lines

Provide an explicit hint as to the likely cause of a version generation failure to help anyone who runs into this in future more readily diagnose and fix the problem.

---

Applied to linux-kbuild. Thanks.

Quoted 29 lines

v2:
- Reword and reformat error message.
- Fix duplicated is.

 scripts/mod/modpost.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
scripts/mod/modpost.c +5 -3
index 3e623ccc020b..270a7df898e2 100644
@@ -660,8 +660,11 @@ static void handle_modversion(const struct module *mod,
        unsigned int crc;
 
        if (sym->st_shndx == SHN_UNDEF) {
-               warn("EXPORT symbol \"%s\" [%s%s] version generation failed, symbol will not be versioned.\n",
-                    symname, mod->name, mod->is_vmlinux ? "" : ".ko");
+               warn("EXPORT symbol \"%s\" [%s%s] version ...\n"
+                    "Is \"%s\" prototyped in <asm/asm-prototypes.h>?\n",
+                    symname, mod->name, mod->is_vmlinux ? "" : ".ko",
+                    symname);
+
                return;
        }
 
--

2.20.1

Signature · 2 lines
Best Regards
Masahiro Yamada
author
#2 lore raw
Quoted 7 lines · Masahiro Yamada
Quoted 3 lines · Mark Brown

One common cause of modpost version generation failures is a failure to prototype exported assembly functions - the tooling requires this for exported functions even if they are not and should not be called from C

Applied to linux-kbuild. Thanks.

This doesn't seem to be showing up in -next, was there some issue? Looks like the kbuild tree that -next is picking up wasn't updated since 1st June.