mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2024-12-29 09:12:07 +00:00
kbuild: change module.order to list *.o instead of *.ko
scripts/Makefile.build replaces the suffix .o with .ko, then scripts/Makefile.modpost calls the sed command to change .ko back to the original .o suffix. Instead of converting the suffixes back-and-forth, store the .o paths in modules.order, and replace it with .ko in 'make modules_install'. This avoids the unneeded sed command. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
This commit is contained in:
parent
875ef1a57f
commit
f65a486821
2
Makefile
2
Makefile
@ -1564,7 +1564,7 @@ __modinst_pre:
|
|||||||
rm -f $(MODLIB)/build ; \
|
rm -f $(MODLIB)/build ; \
|
||||||
ln -s $(CURDIR) $(MODLIB)/build ; \
|
ln -s $(CURDIR) $(MODLIB)/build ; \
|
||||||
fi
|
fi
|
||||||
@sed 's:^:kernel/:' modules.order > $(MODLIB)/modules.order
|
@sed 's:^\(.*\)\.o$$:kernel/\1.ko:' modules.order > $(MODLIB)/modules.order
|
||||||
@cp -f modules.builtin $(MODLIB)/
|
@cp -f modules.builtin $(MODLIB)/
|
||||||
@cp -f $(objtree)/modules.builtin.modinfo $(MODLIB)/
|
@cp -f $(objtree)/modules.builtin.modinfo $(MODLIB)/
|
||||||
|
|
||||||
|
@ -435,7 +435,7 @@ $(obj)/built-in.a: $(real-obj-y) FORCE
|
|||||||
# modules.order unless contained modules are updated.
|
# modules.order unless contained modules are updated.
|
||||||
|
|
||||||
cmd_modules_order = { $(foreach m, $(real-prereqs), \
|
cmd_modules_order = { $(foreach m, $(real-prereqs), \
|
||||||
$(if $(filter %/modules.order, $m), cat $m, echo $(patsubst %.o,%.ko,$m));) :; } \
|
$(if $(filter %/modules.order, $m), cat $m, echo $m);) :; } \
|
||||||
> $@
|
> $@
|
||||||
|
|
||||||
$(obj)/modules.order: $(obj-m) FORCE
|
$(obj)/modules.order: $(obj-m) FORCE
|
||||||
|
@ -15,7 +15,7 @@ include $(srctree)/scripts/Makefile.lib
|
|||||||
# find all modules listed in modules.order
|
# find all modules listed in modules.order
|
||||||
modules := $(call read-file, $(MODORDER))
|
modules := $(call read-file, $(MODORDER))
|
||||||
|
|
||||||
__modfinal: $(modules)
|
__modfinal: $(modules:%.o=%.ko)
|
||||||
@:
|
@:
|
||||||
|
|
||||||
# modname and part-of-module are set to make c_flags define proper module flags
|
# modname and part-of-module are set to make c_flags define proper module flags
|
||||||
@ -57,13 +57,13 @@ if_changed_except = $(if $(call newer_prereqs_except,$(2))$(cmd-check), \
|
|||||||
printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:)
|
printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:)
|
||||||
|
|
||||||
# Re-generate module BTFs if either module's .ko or vmlinux changed
|
# Re-generate module BTFs if either module's .ko or vmlinux changed
|
||||||
$(modules): %.ko: %.o %.mod.o scripts/module.lds $(and $(CONFIG_DEBUG_INFO_BTF_MODULES),$(KBUILD_BUILTIN),vmlinux) FORCE
|
%.ko: %.o %.mod.o scripts/module.lds $(and $(CONFIG_DEBUG_INFO_BTF_MODULES),$(KBUILD_BUILTIN),vmlinux) FORCE
|
||||||
+$(call if_changed_except,ld_ko_o,vmlinux)
|
+$(call if_changed_except,ld_ko_o,vmlinux)
|
||||||
ifdef CONFIG_DEBUG_INFO_BTF_MODULES
|
ifdef CONFIG_DEBUG_INFO_BTF_MODULES
|
||||||
+$(if $(newer-prereqs),$(call cmd,btf_ko))
|
+$(if $(newer-prereqs),$(call cmd,btf_ko))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
targets += $(modules) $(modules:.ko=.mod.o)
|
targets += $(modules:%.o=%.ko) $(modules:%.o=%.mod.o)
|
||||||
|
|
||||||
# Add FORCE to the prequisites of a target to force it to be always rebuilt.
|
# Add FORCE to the prequisites of a target to force it to be always rebuilt.
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
@ -26,7 +26,7 @@ suffix-$(CONFIG_MODULE_COMPRESS_GZIP) := .gz
|
|||||||
suffix-$(CONFIG_MODULE_COMPRESS_XZ) := .xz
|
suffix-$(CONFIG_MODULE_COMPRESS_XZ) := .xz
|
||||||
suffix-$(CONFIG_MODULE_COMPRESS_ZSTD) := .zst
|
suffix-$(CONFIG_MODULE_COMPRESS_ZSTD) := .zst
|
||||||
|
|
||||||
modules := $(patsubst $(extmod_prefix)%, $(dst)/%$(suffix-y), $(modules))
|
modules := $(patsubst $(extmod_prefix)%.o, $(dst)/%.ko$(suffix-y), $(modules))
|
||||||
|
|
||||||
__modinst: $(modules)
|
__modinst: $(modules)
|
||||||
@:
|
@:
|
||||||
|
@ -107,7 +107,10 @@ ifneq ($(KBUILD_MODPOST_WARN)$(missing-input),)
|
|||||||
modpost-args += -w
|
modpost-args += -w
|
||||||
endif
|
endif
|
||||||
|
|
||||||
modorder-if-needed := $(if $(KBUILD_MODULES), $(MODORDER))
|
ifdef KBUILD_MODULES
|
||||||
|
modorder-if-needed := $(MODORDER)
|
||||||
|
modpost-args += -T $(MODORDER)
|
||||||
|
endif
|
||||||
|
|
||||||
MODPOST = scripts/mod/modpost
|
MODPOST = scripts/mod/modpost
|
||||||
|
|
||||||
@ -119,7 +122,7 @@ quiet_cmd_modpost = MODPOST $@
|
|||||||
echo >&2 "WARNING: $(missing-input) is missing."; \
|
echo >&2 "WARNING: $(missing-input) is missing."; \
|
||||||
echo >&2 " Modules may not have dependencies or modversions."; \
|
echo >&2 " Modules may not have dependencies or modversions."; \
|
||||||
echo >&2 " You may get many unresolved symbol warnings.";) \
|
echo >&2 " You may get many unresolved symbol warnings.";) \
|
||||||
sed 's/ko$$/o/' $(or $(modorder-if-needed), /dev/null) | $(MODPOST) $(modpost-args) -T - $(vmlinux.o-if-present)
|
$(MODPOST) $(modpost-args) $(vmlinux.o-if-present)
|
||||||
|
|
||||||
targets += $(output-symdump)
|
targets += $(output-symdump)
|
||||||
$(output-symdump): $(modorder-if-needed) $(vmlinux.o-if-present) $(module.symvers-if-present) $(MODPOST) FORCE
|
$(output-symdump): $(modorder-if-needed) $(vmlinux.o-if-present) $(module.symvers-if-present) $(MODPOST) FORCE
|
||||||
|
@ -138,10 +138,10 @@ def cmdfiles_for_modorder(modorder):
|
|||||||
"""
|
"""
|
||||||
with open(modorder) as f:
|
with open(modorder) as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
ko = line.rstrip()
|
obj = line.rstrip()
|
||||||
base, ext = os.path.splitext(ko)
|
base, ext = os.path.splitext(obj)
|
||||||
if ext != '.ko':
|
if ext != '.o':
|
||||||
sys.exit('{}: module path must end with .ko'.format(ko))
|
sys.exit('{}: module path must end with .o'.format(obj))
|
||||||
mod = base + '.mod'
|
mod = base + '.mod'
|
||||||
# Read from *.mod, to get a list of objects that compose the module.
|
# Read from *.mod, to get a list of objects that compose the module.
|
||||||
with open(mod) as m:
|
with open(mod) as m:
|
||||||
|
@ -48,7 +48,7 @@ cat > "$output_file" << EOT
|
|||||||
EOT
|
EOT
|
||||||
|
|
||||||
{
|
{
|
||||||
[ -n "${read_modorder}" ] && sed 's/ko$/usyms/' modules.order | xargs cat
|
[ -n "${read_modorder}" ] && sed 's/o$/usyms/' modules.order | xargs cat
|
||||||
echo "$needed_symbols"
|
echo "$needed_symbols"
|
||||||
[ -n "$ksym_wl" ] && cat "$ksym_wl"
|
[ -n "$ksym_wl" ] && cat "$ksym_wl"
|
||||||
} | sed -e 's/ /\n/g' | sed -n -e '/^$/!p' |
|
} | sed -e 's/ /\n/g' | sed -n -e '/^$/!p' |
|
||||||
|
@ -1856,11 +1856,9 @@ static void read_symbols_from_files(const char *filename)
|
|||||||
FILE *in = stdin;
|
FILE *in = stdin;
|
||||||
char fname[PATH_MAX];
|
char fname[PATH_MAX];
|
||||||
|
|
||||||
if (strcmp(filename, "-") != 0) {
|
in = fopen(filename, "r");
|
||||||
in = fopen(filename, "r");
|
if (!in)
|
||||||
if (!in)
|
fatal("Can't open filenames file %s: %m", filename);
|
||||||
fatal("Can't open filenames file %s: %m", filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (fgets(fname, PATH_MAX, in) != NULL) {
|
while (fgets(fname, PATH_MAX, in) != NULL) {
|
||||||
if (strends(fname, "\n"))
|
if (strends(fname, "\n"))
|
||||||
@ -1868,8 +1866,7 @@ static void read_symbols_from_files(const char *filename)
|
|||||||
read_symbols(fname);
|
read_symbols(fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in != stdin)
|
fclose(in);
|
||||||
fclose(in);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SZ 500
|
#define SZ 500
|
||||||
|
@ -16,7 +16,7 @@ check_same_name_modules()
|
|||||||
for m in $(sed 's:.*/::' "$1" | sort | uniq -d)
|
for m in $(sed 's:.*/::' "$1" | sort | uniq -d)
|
||||||
do
|
do
|
||||||
echo "error: the following would cause module name conflict:" >&2
|
echo "error: the following would cause module name conflict:" >&2
|
||||||
sed -n "/\/$m/s:^: :p" "$1" >&2
|
sed -n "/\/$m/s:^\(.*\)\.o\$: \1.ko:p" "$1" >&2
|
||||||
exit_code=1
|
exit_code=1
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user