History

kbuild: compile constant module information only once

Various information about modules is compiled into the info sections. For that a dedicated .mod.c file is generated by modpost for each module and then linked into the module. However most of the information in the .mod.c is the same for all modules, internal and external. Split the shared information into a dedicated source file that is compiled once and then linked into all modules. This avoids frequent rebuilds for all .mod.c files when using CONFIG_LOCALVERSION_AUTO because the local version ends up in .mod.c through UTS_RELEASE and VERMAGIC_STRING. The modules are still relinked in this case. The code is also easier to maintain as it's now in a proper source file instead of an inline string literal.

Thomas Weißschuh committed 2 years ago

Commit fdf94e41 parent cd615d73 files · +30 −25Browse files

Showing the changes to scripts/mod (1 of 3 files). Show all

Unified · Split

scripts/mod/modpost.c+0−23
@@ -1755,26 +1755,9 @@ static void check_modname_len(struct module *mod) · 1754 unmodified lines
17551755 static void add_header(struct buffer *b, struct module *mod)
17561756 {
17571757 buf_printf(b, "#include <linux/module.h>\n");
1758− /*
1759− * Include build-salt.h after module.h in order to
1760− * inherit the definitions.
1761− */
1762− buf_printf(b, "#define INCLUDE_VERMAGIC\n");
1763− buf_printf(b, "#include <linux/build-salt.h>\n");
1764− buf_printf(b, "#include <linux/elfnote-lto.h>\n");
17651758 buf_printf(b, "#include <linux/export-internal.h>\n");
1766− buf_printf(b, "#include <linux/vermagic.h>\n");
17671759 buf_printf(b, "#include <linux/compiler.h>\n");
17681760 buf_printf(b, "\n");
1769− buf_printf(b, "#ifdef CONFIG_UNWINDER_ORC\n");
1770− buf_printf(b, "#include <asm/orc_header.h>\n");
1771− buf_printf(b, "ORC_HEADER;\n");
1772− buf_printf(b, "#endif\n");
1773− buf_printf(b, "\n");
1774− buf_printf(b, "BUILD_SALT;\n");
1775− buf_printf(b, "BUILD_LTO_INFO;\n");
1776− buf_printf(b, "\n");
1777− buf_printf(b, "MODULE_INFO(vermagic, VERMAGIC_STRING);\n");
17781761 buf_printf(b, "MODULE_INFO(name, KBUILD_MODNAME);\n");
17791762 buf_printf(b, "\n");
17801763 buf_printf(b, "__visible struct module __this_module\n");
@@ -1792,12 +1775,6 @@ static void add_header(struct buffer *b, struct module *mod) · 11 unmodified lines
17921775 if (!external_module)
17931776 buf_printf(b, "\nMODULE_INFO(intree, \"Y\");\n");
17941777
1795− buf_printf(b,
1796− "\n"
1797− "#ifdef CONFIG_MITIGATION_RETPOLINE\n"
1798− "MODULE_INFO(retpoline, \"Y\");\n"
1799− "#endif\n");
1800−
18011778 if (strstarts(mod->name, "drivers/staging"))
18021779 buf_printf(b, "\nMODULE_INFO(staging, \"Y\");\n");
18031780

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t