Skip to content

Commit 368d060

Browse files
committed
Merge tag 'kbuild-v5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
Pull Kbuild updates from Masahiro Yamada: - detect missing include guard in UAPI headers - do not create orphan built-in.a or obj-y objects - generate modules.builtin more simply, and drop tristate.conf - simplify built-in initramfs creation - make linux-headers deb package thinner - optimize the deb package build script - misc cleanups * tag 'kbuild-v5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (34 commits) builddeb: split libc headers deployment out into a function builddeb: split kernel headers deployment out into a function builddeb: remove redundant make for ARCH=um builddeb: avoid invoking sub-shells where possible builddeb: remove redundant $objtree/ builddeb: match temporary directory name to the package name builddeb: remove unneeded files in hdrobjfiles for headers package kbuild: use -S instead of -E for precise cc-option test in Kconfig builddeb: allow selection of .deb compressor kbuild: remove 'Building modules, stage 2.' log kbuild: remove *.tmp file when filechk fails kbuild: remove PYTHON2 variable modpost: assume STT_SPARC_REGISTER is defined gen_initramfs.sh: remove intermediate cpio_list on errors initramfs: refactor the initramfs build rules gen_initramfs.sh: always output cpio even without -o option initramfs: add default_cpio_list, and delete -d option support initramfs: generate dependency list and cpio at the same time initramfs: specify $(src)/gen_initramfs.sh as a prerequisite in Makefile initramfs: make initramfs compression choice non-optional ...
2 parents acd7750 + 451dff3 commit 368d060

File tree

20 files changed

+281
-449
lines changed

20 files changed

+281
-449
lines changed

Documentation/kbuild/kconfig.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,6 @@ KCONFIG_AUTOCONFIG
154154
This environment variable can be set to specify the path & name of the
155155
"auto.conf" file. Its default value is "include/config/auto.conf".
156156

157-
KCONFIG_TRISTATE
158-
----------------
159-
This environment variable can be set to specify the path & name of the
160-
"tristate.conf" file. Its default value is "include/config/tristate.conf".
161-
162157
KCONFIG_AUTOHEADER
163158
------------------
164159
This environment variable can be set to specify the path & name of the

Makefile

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,6 @@ INSTALLKERNEL := installkernel
423423
DEPMOD = /sbin/depmod
424424
PERL = perl
425425
PYTHON = python
426-
PYTHON2 = python2
427426
PYTHON3 = python3
428427
CHECK = sparse
429428
BASH = bash
@@ -474,7 +473,7 @@ CLANG_FLAGS :=
474473

475474
export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE AS LD CC
476475
export CPP AR NM STRIP OBJCOPY OBJDUMP OBJSIZE READELF PAHOLE LEX YACC AWK INSTALLKERNEL
477-
export PERL PYTHON PYTHON2 PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX
476+
export PERL PYTHON PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX
478477
export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE
479478

480479
export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS KBUILD_LDFLAGS
@@ -674,7 +673,7 @@ $(KCONFIG_CONFIG):
674673
#
675674
# This exploits the 'multi-target pattern rule' trick.
676675
# The syncconfig should be executed only once to make all the targets.
677-
%/auto.conf %/auto.conf.cmd %/tristate.conf: $(KCONFIG_CONFIG)
676+
%/auto.conf %/auto.conf.cmd: $(KCONFIG_CONFIG)
678677
$(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
679678
else # !may-sync-config
680679
# External modules and some install targets need include/generated/autoconf.h
@@ -1278,24 +1277,13 @@ all: modules
12781277
# using awk while concatenating to the final file.
12791278

12801279
PHONY += modules
1281-
modules: $(if $(KBUILD_BUILTIN),vmlinux) modules.order modules.builtin
1280+
modules: $(if $(KBUILD_BUILTIN),vmlinux) modules.order
12821281
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
12831282
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh
12841283

12851284
modules.order: descend
12861285
$(Q)$(AWK) '!x[$$0]++' $(addsuffix /$@, $(build-dirs)) > $@
12871286

1288-
modbuiltin-dirs := $(addprefix _modbuiltin_, $(build-dirs))
1289-
1290-
modules.builtin: $(modbuiltin-dirs)
1291-
$(Q)$(AWK) '!x[$$0]++' $(addsuffix /$@, $(build-dirs)) > $@
1292-
1293-
PHONY += $(modbuiltin-dirs)
1294-
# tristate.conf is not included from this Makefile. Add it as a prerequisite
1295-
# here to make it self-healing in case somebody accidentally removes it.
1296-
$(modbuiltin-dirs): include/config/tristate.conf
1297-
$(Q)$(MAKE) $(modbuiltin)=$(patsubst _modbuiltin_%,%,$@)
1298-
12991287
# Target to prepare building external modules
13001288
PHONY += modules_prepare
13011289
modules_prepare: prepare
@@ -1315,7 +1303,7 @@ _modinst_:
13151303
ln -s $(CURDIR) $(MODLIB)/build ; \
13161304
fi
13171305
@sed 's:^:kernel/:' modules.order > $(MODLIB)/modules.order
1318-
@sed 's:^:kernel/:' modules.builtin > $(MODLIB)/modules.builtin
1306+
@cp -f modules.builtin $(MODLIB)/
13191307
@cp -f $(objtree)/modules.builtin.modinfo $(MODLIB)/
13201308
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
13211309

@@ -1357,7 +1345,7 @@ endif # CONFIG_MODULES
13571345

13581346
# Directories & files removed with 'make clean'
13591347
CLEAN_DIRS += include/ksym
1360-
CLEAN_FILES += modules.builtin.modinfo modules.nsdeps
1348+
CLEAN_FILES += modules.builtin modules.builtin.modinfo modules.nsdeps
13611349

13621350
# Directories & files removed with 'make mrproper'
13631351
MRPROPER_DIRS += include/config include/generated \
@@ -1712,7 +1700,7 @@ clean: $(clean-dirs)
17121700
-o -name '*.lex.c' -o -name '*.tab.[ch]' \
17131701
-o -name '*.asn1.[ch]' \
17141702
-o -name '*.symtypes' -o -name 'modules.order' \
1715-
-o -name modules.builtin -o -name '.tmp_*.o.*' \
1703+
-o -name '.tmp_*.o.*' \
17161704
-o -name '*.c.[012]*.*' \
17171705
-o -name '*.ll' \
17181706
-o -name '*.gcno' \) -type f -print | xargs rm -f

include/linux/module.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,16 @@ extern void cleanup_module(void);
169169
*/
170170
#define MODULE_SOFTDEP(_softdep) MODULE_INFO(softdep, _softdep)
171171

172+
/*
173+
* MODULE_FILE is used for generating modules.builtin
174+
* So, make it no-op when this is being built as a module
175+
*/
176+
#ifdef MODULE
177+
#define MODULE_FILE
178+
#else
179+
#define MODULE_FILE MODULE_INFO(file, KBUILD_MODFILE);
180+
#endif
181+
172182
/*
173183
* The following license idents are currently accepted as indicating free
174184
* software modules
@@ -213,7 +223,7 @@ extern void cleanup_module(void);
213223
* 2. So the community can ignore bug reports including proprietary modules
214224
* 3. So vendors can do likewise based on their own policies
215225
*/
216-
#define MODULE_LICENSE(_license) MODULE_INFO(license, _license)
226+
#define MODULE_LICENSE(_license) MODULE_FILE MODULE_INFO(license, _license)
217227

218228
/*
219229
* Author(s), use "Name <email>" or just "Name", for multiple

scripts/Kbuild.include

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ real-prereqs = $(filter-out $(PHONY), $^)
3232
# Escape single quote for use in echo statements
3333
escsq = $(subst $(squote),'\$(squote)',$1)
3434

35+
###
36+
# Quote a string to pass it to C files. foo => '"foo"'
37+
stringify = $(squote)$(quote)$1$(quote)$(squote)
38+
3539
###
3640
# Easy method for doing a status message
3741
kecho := :
@@ -55,14 +59,13 @@ kecho := $($(quiet)kecho)
5559
# - stdin is piped in from the first prerequisite ($<) so one has
5660
# to specify a valid file as first prerequisite (often the kbuild file)
5761
define filechk
58-
$(Q)set -e; \
59-
mkdir -p $(dir $@); \
60-
{ $(filechk_$(1)); } > [email protected]; \
61-
if [ -r $@ ] && cmp -s $@ [email protected]; then \
62-
63-
else \
64-
$(kecho) ' UPD $@'; \
65-
mv -f [email protected] $@; \
62+
$(Q)set -e; \
63+
mkdir -p $(dir $@); \
64+
trap "rm -f $(dot-target).tmp" EXIT; \
65+
{ $(filechk_$(1)); } > $(dot-target).tmp; \
66+
if [ ! -r $@ ] || ! cmp -s $@ $(dot-target).tmp; then \
67+
$(kecho) ' UPD $@'; \
68+
mv -f $(dot-target).tmp $@; \
6669
fi
6770
endef
6871

@@ -159,12 +162,6 @@ ld-ifversion = $(shell [ $(ld-version) $(1) $(2) ] && echo $(3) || echo $(4))
159162
# $(Q)$(MAKE) $(build)=dir
160163
build := -f $(srctree)/scripts/Makefile.build obj
161164

162-
###
163-
# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.modbuiltin obj=
164-
# Usage:
165-
# $(Q)$(MAKE) $(modbuiltin)=dir
166-
modbuiltin := -f $(srctree)/scripts/Makefile.modbuiltin obj
167-
168165
###
169166
# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.dtbinst obj=
170167
# Usage:

scripts/Kconfig.include

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ failure = $(if-success,$(1),n,y)
2525

2626
# $(cc-option,<flag>)
2727
# Return y if the compiler supports <flag>, n otherwise
28-
cc-option = $(success,$(CC) -Werror $(CLANG_FLAGS) $(1) -E -x c /dev/null -o /dev/null)
28+
cc-option = $(success,$(CC) -Werror $(CLANG_FLAGS) $(1) -S -x c /dev/null -o /dev/null)
2929

3030
# $(ld-option,<flag>)
3131
# Return y if the linker supports <flag>, n otherwise

scripts/Makefile.build

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ lib-target := $(obj)/lib.a
6666
real-obj-y += $(obj)/lib-ksyms.o
6767
endif
6868

69-
ifneq ($(strip $(real-obj-y) $(need-builtin)),)
69+
ifdef need-builtin
7070
builtin-target := $(obj)/built-in.a
7171
endif
7272

@@ -372,7 +372,7 @@ $(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler
372372
# ---------------------------------------------------------------------------
373373

374374
# To build objects in subdirs, we need to descend into the directories
375-
$(sort $(subdir-obj-y)): $(subdir-ym) ;
375+
$(obj)/%/built-in.a: $(obj)/% ;
376376

377377
#
378378
# Rule to compile a set of .o files into one .a file (without symbol table)

scripts/Makefile.lib

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ __subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y)))
3535
subdir-y += $(__subdir-y)
3636
__subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m)))
3737
subdir-m += $(__subdir-m)
38+
ifdef need-builtin
3839
obj-y := $(patsubst %/, %/built-in.a, $(obj-y))
40+
else
41+
obj-y := $(filter-out %/, $(obj-y))
42+
endif
3943
obj-m := $(filter-out %/, $(obj-m))
4044

4145
# Subdirectories we need to descend into
@@ -80,22 +84,25 @@ multi-used-m := $(addprefix $(obj)/,$(multi-used-m))
8084
subdir-ym := $(addprefix $(obj)/,$(subdir-ym))
8185

8286
# Finds the multi-part object the current object will be linked into.
83-
# If the object belongs to two or more multi-part objects, all of them are
84-
# concatenated with a colon separator.
85-
modname-multi = $(subst $(space),:,$(sort $(foreach m,$(multi-used),\
86-
$(if $(filter $*.o, $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$(m:.o=)))))
87+
# If the object belongs to two or more multi-part objects, list them all.
88+
modname-multi = $(sort $(foreach m,$(multi-used),\
89+
$(if $(filter $*.o, $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$(m:.o=))))
90+
91+
__modname = $(if $(modname-multi),$(modname-multi),$(basetarget))
8792

88-
modname = $(if $(modname-multi),$(modname-multi),$(basetarget))
93+
modname = $(subst $(space),:,$(__modname))
94+
modfile = $(addprefix $(obj)/,$(__modname))
8995

9096
# target with $(obj)/ and its suffix stripped
9197
target-stem = $(basename $(patsubst $(obj)/%,%,$@))
9298

9399
# These flags are needed for modversions and compiling, so we define them here
94100
# $(modname_flags) defines KBUILD_MODNAME as the name of the module it will
95101
# end up in (or would, if it gets compiled in)
96-
name-fix = $(squote)$(quote)$(subst $(comma),_,$(subst -,_,$1))$(quote)$(squote)
102+
name-fix = $(call stringify,$(subst $(comma),_,$(subst -,_,$1)))
97103
basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget))
98104
modname_flags = -DKBUILD_MODNAME=$(call name-fix,$(modname))
105+
modfile_flags = -DKBUILD_MODFILE=$(call stringify,$(modfile))
99106

100107
orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) \
101108
$(ccflags-y) $(CFLAGS_$(target-stem).o)
@@ -154,7 +161,7 @@ quiet_modtag = $(if $(part-of-module),[M], )
154161
modkern_cflags = \
155162
$(if $(part-of-module), \
156163
$(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \
157-
$(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL))
164+
$(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL) $(modfile_flags))
158165

159166
modkern_aflags = $(if $(part-of-module), \
160167
$(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE), \

scripts/Makefile.modbuiltin

Lines changed: 0 additions & 57 deletions
This file was deleted.

scripts/Makefile.modpost

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ quiet_cmd_modpost = MODPOST $(words $(modules)) modules
9090
cmd_modpost = sed 's/ko$$/o/' $(MODORDER) | $(MODPOST)
9191

9292
__modpost:
93-
@$(kecho) ' Building modules, stage 2.'
9493
$(call cmd,modpost)
9594
ifneq ($(KBUILD_MODPOST_NOFINAL),1)
9695
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal

scripts/kconfig/confdata.c

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -710,25 +710,6 @@ static struct conf_printer header_printer_cb =
710710
.print_comment = header_print_comment,
711711
};
712712

713-
/*
714-
* Tristate printer
715-
*
716-
* This printer is used when generating the `include/config/tristate.conf' file.
717-
*/
718-
static void
719-
tristate_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
720-
{
721-
722-
if (sym->type == S_TRISTATE && *value != 'n')
723-
fprintf(fp, "%s%s=%c\n", CONFIG_, sym->name, (char)toupper(*value));
724-
}
725-
726-
static struct conf_printer tristate_printer_cb =
727-
{
728-
.print_symbol = tristate_print_symbol,
729-
.print_comment = kconfig_print_comment,
730-
};
731-
732713
static void conf_write_symbol(FILE *fp, struct symbol *sym,
733714
struct conf_printer *printer, void *printer_arg)
734715
{
@@ -1062,7 +1043,7 @@ int conf_write_autoconf(int overwrite)
10621043
struct symbol *sym;
10631044
const char *name;
10641045
const char *autoconf_name = conf_get_autoconfig_name();
1065-
FILE *out, *tristate, *out_h;
1046+
FILE *out, *out_h;
10661047
int i;
10671048

10681049
if (!overwrite && is_present(autoconf_name))
@@ -1077,39 +1058,25 @@ int conf_write_autoconf(int overwrite)
10771058
if (!out)
10781059
return 1;
10791060

1080-
tristate = fopen(".tmpconfig_tristate", "w");
1081-
if (!tristate) {
1082-
fclose(out);
1083-
return 1;
1084-
}
1085-
10861061
out_h = fopen(".tmpconfig.h", "w");
10871062
if (!out_h) {
10881063
fclose(out);
1089-
fclose(tristate);
10901064
return 1;
10911065
}
10921066

10931067
conf_write_heading(out, &kconfig_printer_cb, NULL);
1094-
1095-
conf_write_heading(tristate, &tristate_printer_cb, NULL);
1096-
10971068
conf_write_heading(out_h, &header_printer_cb, NULL);
10981069

10991070
for_all_symbols(i, sym) {
11001071
sym_calc_value(sym);
11011072
if (!(sym->flags & SYMBOL_WRITE) || !sym->name)
11021073
continue;
11031074

1104-
/* write symbol to auto.conf, tristate and header files */
1075+
/* write symbols to auto.conf and autoconf.h */
11051076
conf_write_symbol(out, sym, &kconfig_printer_cb, (void *)1);
1106-
1107-
conf_write_symbol(tristate, sym, &tristate_printer_cb, (void *)1);
1108-
11091077
conf_write_symbol(out_h, sym, &header_printer_cb, NULL);
11101078
}
11111079
fclose(out);
1112-
fclose(tristate);
11131080
fclose(out_h);
11141081

11151082
name = getenv("KCONFIG_AUTOHEADER");
@@ -1120,14 +1087,6 @@ int conf_write_autoconf(int overwrite)
11201087
if (rename(".tmpconfig.h", name))
11211088
return 1;
11221089

1123-
name = getenv("KCONFIG_TRISTATE");
1124-
if (!name)
1125-
name = "include/config/tristate.conf";
1126-
if (make_parent_dir(name))
1127-
return 1;
1128-
if (rename(".tmpconfig_tristate", name))
1129-
return 1;
1130-
11311090
if (make_parent_dir(autoconf_name))
11321091
return 1;
11331092
/*

0 commit comments

Comments
 (0)