public inbox for linux-next@vger.kernel.org 
 help / color / mirror / Atom feed
From: Alexey Gladkov <legion@kernel•org>
To: Stephen Rothwell <sfr@canb•auug.org.au>,
	Masahiro Yamada <masahiroy@kernel•org>
Cc: Linux Kernel Mailing List <linux-kernel@vger•kernel.org>,
	Linux Next Mailing List <linux-next@vger•kernel.org>
Subject: [PATCH] kbuild: modpost: Fix the order of includes in .vmlinux.export.c
Date: Wed, 30 Jul 2025 11:00:25 +0200	[thread overview]
Message-ID: <20250730090025.2402129-1-legion@kernel.org> (raw)
In-Reply-To: <20250730161223.63783458@canb.auug.org.au>

The linux/module.h cannot be used at the beginning of file because
linux/dynamic_debug.h adds linux/string.h and then string_32.h, where
some functions may be redefined as `__builtin_<name>` under certain
conditions.

This results in the following error (i386 defconfig):

ld: .vmlinux.export.o: in function `__ksymtab___builtin_memcmp':
.vmlinux.export.c:(___ksymtab+__builtin_memcmp+0x0): undefined reference to `__builtin_memcmp'

Link: https://lore.kernel.org/all/20250730161223.63783458@canb.auug.org.au/
Fixes: c4b487ddc51f ("modpost: Create modalias for builtin modules")
Signed-off-by: Alexey Gladkov <legion@kernel•org>
---
 scripts/mod/modpost.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 67f9cd76bdd2..47c8aa2a6939 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -2070,12 +2070,12 @@ static void write_vmlinux_export_c_file(struct module *mod)
 	struct module_alias *alias, *next;
 
 	buf_printf(&buf,
-		   "#include <linux/export-internal.h>\n"
-		   "#include <linux/module.h>\n");
+		   "#include <linux/export-internal.h>\n");
 
 	add_exported_symbols(&buf, mod);
 
 	buf_printf(&buf,
+		   "#include <linux/module.h>\n"
 		   "#undef __MODULE_INFO_PREFIX\n"
 		   "#define __MODULE_INFO_PREFIX\n");
 
-- 
2.50.1


  reply	other threads:[~2025-07-30  9:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-30  6:12 linux-next: build failure after merge of the kbuild tree Stephen Rothwell
2025-07-30  9:00 ` Alexey Gladkov [this message]
2025-08-04  1:25 ` Stephen Rothwell
2025-08-04  7:09   ` Alexey Gladkov
2025-08-04 22:17     ` Stephen Rothwell
2025-08-05  3:33       ` Stephen Rothwell
2025-08-12 21:51         ` Alexey Gladkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250730090025.2402129-1-legion@kernel.org \
    --to=legion@kernel$(echo .)org \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=linux-next@vger$(echo .)kernel.org \
    --cc=masahiroy@kernel$(echo .)org \
    --cc=sfr@canb$(echo .)auug.org.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox