Skip to content

Commit 0e40da3

Browse files
committed
Merge tag 'kbuild-fixes-v5.1' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
Pull Kbuild fixes from Masahiro Yamada: - Remove harmful -Oz option of Clang - Get back the original behavior (no recursion for in-tree build) for GNU Make 4.x - Some minor fixes for coccinelle patches - Do not overwrite .gitignore in the output directory in case it is version-controlled - Fix missed record-mcount bug for dynamic ftrace - Fix endianness bug in modversions for relative CRC - Cater to '^H' key code in Kconfig ncurses programs * tag 'kbuild-fixes-v5.1' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: kconfig/[mn]conf: handle backspace (^H) key kbuild: modversions: Fix relative CRC byte order interpretation scripts: coccinelle: Fix description of badty.cocci kbuild: strip whitespace in cmd_record_mcount findstring kbuild: do not overwrite .gitignore in output directory kbuild: skip parsing pre sub-make code for recursion coccinelle: put_device: reduce false positives kbuild: skip sub-make for in-tree build with GNU Make 4.x Revert "kbuild: use -Oz instead of -Os when using clang"
2 parents ffb8e45 + 9c38f1f commit 0e40da3

File tree

8 files changed

+33
-30
lines changed

8 files changed

+33
-30
lines changed

Makefile

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,12 @@ _all:
3131
# descending is started. They are now explicitly listed as the
3232
# prepare rule.
3333

34-
# Ugly workaround for Debian make-kpkg:
35-
# make-kpkg directly includes the top Makefile of Linux kernel. In such a case,
36-
# skip sub-make to support debian_* targets in ruleset/kernel_version.mk, but
37-
# displays warning to discourage such abusage.
38-
ifneq ($(word 2, $(MAKEFILE_LIST)),)
39-
$(warning Do not include top Makefile of Linux Kernel)
40-
sub-make-done := 1
41-
MAKEFLAGS += -rR
42-
endif
43-
44-
ifneq ($(sub-make-done),1)
34+
ifneq ($(sub_make_done),1)
4535

4636
# Do not use make's built-in rules and variables
4737
# (this increases performance and avoids hard-to-debug behaviour)
4838
MAKEFLAGS += -rR
4939

50-
# 'MAKEFLAGS += -rR' does not become immediately effective for old
51-
# GNU Make versions. Cancel implicit rules for this Makefile.
52-
$(lastword $(MAKEFILE_LIST)): ;
53-
5440
# Avoid funny character set dependencies
5541
unexport LC_ALL
5642
LC_COLLATE=C
@@ -153,26 +139,42 @@ $(if $(KBUILD_OUTPUT),, \
153139
# 'sub-make' below.
154140
MAKEFLAGS += --include-dir=$(CURDIR)
155141

142+
need-sub-make := 1
156143
else
157144

158145
# Do not print "Entering directory ..." at all for in-tree build.
159146
MAKEFLAGS += --no-print-directory
160147

161148
endif # ifneq ($(KBUILD_OUTPUT),)
162149

150+
ifneq ($(filter 3.%,$(MAKE_VERSION)),)
151+
# 'MAKEFLAGS += -rR' does not immediately become effective for GNU Make 3.x
152+
# We need to invoke sub-make to avoid implicit rules in the top Makefile.
153+
need-sub-make := 1
154+
# Cancel implicit rules for this Makefile.
155+
$(lastword $(MAKEFILE_LIST)): ;
156+
endif
157+
158+
export sub_make_done := 1
159+
160+
ifeq ($(need-sub-make),1)
161+
163162
PHONY += $(MAKECMDGOALS) sub-make
164163

165164
$(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make
166165
@:
167166

168167
# Invoke a second make in the output directory, passing relevant variables
169168
sub-make:
170-
$(Q)$(MAKE) sub-make-done=1 \
169+
$(Q)$(MAKE) \
171170
$(if $(KBUILD_OUTPUT),-C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR)) \
172171
-f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS))
173172

174-
else # sub-make-done
173+
endif # need-sub-make
174+
endif # sub_make_done
175+
175176
# We process the rest of the Makefile if this is the final invocation of make
177+
ifeq ($(need-sub-make),)
176178

177179
# Do not print "Entering directory ...",
178180
# but we want to display it when entering to the output directory
@@ -497,7 +499,8 @@ outputmakefile:
497499
ifneq ($(KBUILD_SRC),)
498500
$(Q)ln -fsn $(srctree) source
499501
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile $(srctree)
500-
$(Q){ echo "# this is build directory, ignore it"; echo "*"; } > .gitignore
502+
$(Q)test -e .gitignore || \
503+
{ echo "# this is build directory, ignore it"; echo "*"; } > .gitignore
501504
endif
502505

503506
ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),)
@@ -677,7 +680,7 @@ KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
677680
KBUILD_CFLAGS += $(call cc-disable-warning, int-in-bool-context)
678681

679682
ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
680-
KBUILD_CFLAGS += $(call cc-option,-Oz,-Os)
683+
KBUILD_CFLAGS += -Os
681684
else
682685
KBUILD_CFLAGS += -O2
683686
endif
@@ -1757,7 +1760,7 @@ existing-targets := $(wildcard $(sort $(targets)))
17571760

17581761
endif # ifeq ($(config-targets),1)
17591762
endif # ifeq ($(mixed-targets),1)
1760-
endif # sub-make-done
1763+
endif # need-sub-make
17611764

17621765
PHONY += FORCE
17631766
FORCE:

scripts/Makefile.build

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,8 @@ sub_cmd_record_mcount = perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \
199199
"$(if $(part-of-module),1,0)" "$(@)";
200200
recordmcount_source := $(srctree)/scripts/recordmcount.pl
201201
endif # BUILD_C_RECORDMCOUNT
202-
cmd_record_mcount = \
203-
if [ "$(findstring $(CC_FLAGS_FTRACE),$(_c_flags))" = \
204-
"$(CC_FLAGS_FTRACE)" ]; then \
205-
$(sub_cmd_record_mcount) \
206-
fi
202+
cmd_record_mcount = $(if $(findstring $(strip $(CC_FLAGS_FTRACE)),$(_c_flags)), \
203+
$(sub_cmd_record_mcount))
207204
endif # CC_USING_RECORD_MCOUNT
208205
endif # CONFIG_FTRACE_MCOUNT_RECORD
209206

scripts/coccinelle/free/put_device.cocci

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ if (id == NULL || ...) { ... return ...; }
3232
( id
3333
| (T2)dev_get_drvdata(&id->dev)
3434
| (T3)platform_get_drvdata(id)
35+
| &id->dev
3536
);
3637
| return@p2 ...;
3738
)

scripts/coccinelle/misc/badty.cocci

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/// Use ARRAY_SIZE instead of dividing sizeof array with sizeof an element
1+
/// Correct the size argument to alloc functions
22
///
33
//# This makes an effort to find cases where the argument to sizeof is wrong
44
//# in memory allocation functions by checking the type of the allocated memory

scripts/kconfig/lxdialog/inputbox.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
113113
case KEY_DOWN:
114114
break;
115115
case KEY_BACKSPACE:
116-
case 127:
116+
case 8: /* ^H */
117+
case 127: /* ^? */
117118
if (pos) {
118119
wattrset(dialog, dlg.inputbox.atr);
119120
if (input_x == 0) {

scripts/kconfig/nconf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,7 @@ static int do_match(int key, struct match_state *state, int *ans)
10481048
state->match_direction = FIND_NEXT_MATCH_UP;
10491049
*ans = get_mext_match(state->pattern,
10501050
state->match_direction);
1051-
} else if (key == KEY_BACKSPACE || key == 127) {
1051+
} else if (key == KEY_BACKSPACE || key == 8 || key == 127) {
10521052
state->pattern[strlen(state->pattern)-1] = '\0';
10531053
adj_match_dir(&state->match_direction);
10541054
} else

scripts/kconfig/nconf.gui.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,8 @@ int dialog_inputbox(WINDOW *main_window,
439439
case KEY_F(F_EXIT):
440440
case KEY_F(F_BACK):
441441
break;
442-
case 127:
442+
case 8: /* ^H */
443+
case 127: /* ^? */
443444
case KEY_BACKSPACE:
444445
if (cursor_position > 0) {
445446
memmove(&result[cursor_position-1],

scripts/mod/modpost.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info,
639639
info->sechdrs[sym->st_shndx].sh_offset -
640640
(info->hdr->e_type != ET_REL ?
641641
info->sechdrs[sym->st_shndx].sh_addr : 0);
642-
crc = *crcp;
642+
crc = TO_NATIVE(*crcp);
643643
}
644644
sym_update_crc(symname + strlen("__crc_"), mod, crc,
645645
export);

0 commit comments

Comments
 (0)