From 6d3db46c8e331908775b0135dc7d2e5920bf6d90 Mon Sep 17 00:00:00 2001 From: Dan Rue Date: Mon, 20 May 2019 10:16:14 -0500 Subject: kbuild: teach kselftest-merge to find nested config files Current implementation of kselftest-merge only finds config files that are one level deep using `$(srctree)/tools/testing/selftests/*/config`. Often, config files are added in nested directories, and do not get picked up by kselftest-merge. Use `find` to catch all config files under `$(srctree)/tools/testing/selftests` instead. Signed-off-by: Dan Rue Signed-off-by: Masahiro Yamada --- Makefile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 004d67a4405f..d27e1326cc03 100644 --- a/Makefile +++ b/Makefile @@ -1228,9 +1228,8 @@ kselftest-clean: PHONY += kselftest-merge kselftest-merge: $(if $(wildcard $(objtree)/.config),, $(error No .config exists, config your kernel first!)) - $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh \ - -m $(objtree)/.config \ - $(srctree)/tools/testing/selftests/*/config + $(Q)find $(srctree)/tools/testing/selftests -name config | \ + xargs $(srctree)/scripts/kconfig/merge_config.sh -m $(objtree)/.config +$(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig # --------------------------------------------------------------------------- -- cgit From 8dde5715b280738505199023034397a15dc7bfbb Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sat, 25 May 2019 20:49:19 +0900 Subject: kconfig: tests: fix recursive inclusion unit test Adding SPDX license identifier is pretty safe; however, here is one exception. Since commit ec8f24b7faaf ("treewide: Add SPDX license identifier - Makefile/Kconfig"), "make testconfig" would not pass. When Kconfig detects a circular file inclusion, it displays error messages with a file name and a line number prefixed to each line. The unit test checks if Kconfig emits the error messages correctly (this also checks the line number correctness). Now that the test input has the SPDX license identifier at the very top, the line numbers in the expected stderr should be incremented by 1. Fixes: ec8f24b7faaf ("treewide: Add SPDX license identifier - Makefile/Kconfig") Signed-off-by: Masahiro Yamada --- scripts/kconfig/tests/err_recursive_inc/expected_stderr | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/kconfig/tests/err_recursive_inc/expected_stderr b/scripts/kconfig/tests/err_recursive_inc/expected_stderr index 6b582eee2176..b070a31fdfeb 100644 --- a/scripts/kconfig/tests/err_recursive_inc/expected_stderr +++ b/scripts/kconfig/tests/err_recursive_inc/expected_stderr @@ -1,6 +1,6 @@ Recursive inclusion detected. Inclusion path: current file : Kconfig.inc1 - included from: Kconfig.inc3:1 - included from: Kconfig.inc2:3 - included from: Kconfig.inc1:4 + included from: Kconfig.inc3:2 + included from: Kconfig.inc2:4 + included from: Kconfig.inc1:5 -- cgit From a6e0487709ded7cd1ba0c390d9771e5cb76a8453 Mon Sep 17 00:00:00 2001 From: Trevor Bourget Date: Mon, 27 May 2019 16:54:23 -0700 Subject: kbuild: tar-pkg: enable communication with jobserver The buildtar script might want to invoke a make, so tell the parent make to pass the jobserver token pipe to the subcommand by prefixing the command with a +. This addresses the issue seen here: /bin/sh ../scripts/package/buildtar tar-pkg make[3]: warning: jobserver unavailable: using -j1. Add '+' to parent make rule. See https://www.gnu.org/software/make/manual/html_node/Job-Slots.html for more information. Signed-off-by: Trevor Bourget Signed-off-by: Masahiro Yamada --- scripts/package/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/package/Makefile b/scripts/package/Makefile index 27b42d5b6c4f..ca7f46b562a4 100644 --- a/scripts/package/Makefile +++ b/scripts/package/Makefile @@ -104,7 +104,7 @@ clean-dirs += $(objtree)/snap/ # --------------------------------------------------------------------------- tar%pkg: FORCE $(MAKE) -f $(srctree)/Makefile - $(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@ + +$(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@ clean-dirs += $(objtree)/tar-install/ -- cgit From 4f45d62a52297b10ded963412a158685647ecdec Mon Sep 17 00:00:00 2001 From: "George G. Davis" Date: Mon, 3 Jun 2019 10:30:39 -0400 Subject: scripts/checkstack.pl: Fix arm64 wrong or unknown architecture The following error occurs for the `make ARCH=arm64 checkstack` case: aarch64-linux-gnu-objdump -d vmlinux $(find . -name '*.ko') | \ perl ./scripts/checkstack.pl arm64 wrong or unknown architecture "arm64" As suggested by Masahiro Yamada, fix the above error using regular expressions in the same way it was fixed for the `ARCH=x86` case via commit fda9f9903be6 ("scripts/checkstack.pl: automatically handle 32-bit and 64-bit mode for ARCH=x86"). Suggested-by: Masahiro Yamada Signed-off-by: George G. Davis Signed-off-by: Masahiro Yamada --- scripts/checkstack.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/checkstack.pl b/scripts/checkstack.pl index 122aef5e4e14..371bd17a4983 100755 --- a/scripts/checkstack.pl +++ b/scripts/checkstack.pl @@ -46,7 +46,7 @@ my (@stack, $re, $dre, $x, $xs, $funcre); $x = "[0-9a-f]"; # hex character $xs = "[0-9a-f ]"; # hex character or space $funcre = qr/^$x* <(.*)>:$/; - if ($arch eq 'aarch64') { + if ($arch =~ '^(aarch|arm)64$') { #ffffffc0006325cc: a9bb7bfd stp x29, x30, [sp, #-80]! #a110: d11643ff sub sp, sp, #0x590 $re = qr/^.*stp.*sp, \#-([0-9]{1,8})\]\!/o; -- cgit From 913ab9780fc021298949cc5514d6255a008e69f9 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 6 Jun 2019 13:13:58 +0900 Subject: kbuild: use more portable 'command -v' for cc-cross-prefix To print the pathname that will be used by shell in the current environment, 'command -v' is a standardized way. [1] 'which' is also often used in scripts, but it is less portable. When I worked on commit bd55f96fa9fc ("kbuild: refactor cc-cross-prefix implementation"), I was eager to use 'command -v' but it did not work. (The reason is explained below.) I kept 'which' as before but got rid of '> /dev/null 2>&1' as I thought it was no longer needed. Sorry, I was wrong. It works well on my Ubuntu machine, but Alexey Brodkin reports noisy warnings on CentOS7 when 'which' fails to find the given command in the PATH environment. $ which foo which: no foo in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin) Given that behavior of 'which' depends on system (and it may not be installed by default), I want to try 'command -v' once again. The specification [1] clearly describes the behavior of 'command -v' when the given command is not found: Otherwise, no output shall be written and the exit status shall reflect that the name was not found. However, we need a little magic to use 'command -v' from Make. $(shell ...) passes the argument to a subshell for execution, and returns the standard output of the command. Here is a trick. GNU Make may optimize this by executing the command directly instead of forking a subshell, if no shell special characters are found in the command and omitting the subshell will not change the behavior. In this case, no shell special character is used. So, Make will try to run it directly. However, 'command' is a shell-builtin command, then Make would fail to find it in the PATH environment: $ make ARCH=m68k defconfig make: command: Command not found make: command: Command not found make: command: Command not found In fact, Make has a table of shell-builtin commands because it must ask the shell to execute them. Until recently, 'command' was missing in the table. This issue was fixed by the following commit: | commit 1af314465e5dfe3e8baa839a32a72e83c04f26ef | Author: Paul Smith | Date: Sun Nov 12 18:10:28 2017 -0500 | | * job.c: Add "command" as a known shell built-in. | | This is not a POSIX shell built-in but it's common in UNIX shells. | Reported by Nick Bowler . Because the latest release is GNU Make 4.2.1 in 2016, this commit is not included in any released versions. (But some distributions may have back-ported it.) We need to trick Make to spawn a subshell. There are various ways to do so: 1) Use a shell special character '~' as dummy $(shell : ~; command -v $(c)gcc) 2) Use a variable reference that always expands to the empty string (suggested by David Laight) $(shell command$${x:+} -v $(c)gcc) 3) Use redirect $(shell command -v $(c)gcc 2>/dev/null) I chose 3) to not confuse people. The stderr would not be polluted anyway, but it will provide extra safety, and is easy to understand. Tested on Make 3.81, 3.82, 4.0, 4.1, 4.2, 4.2.1 [1] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/command.html Fixes: bd55f96fa9fc ("kbuild: refactor cc-cross-prefix implementation") Cc: linux-stable # 5.1 Reported-by: Alexey Brodkin Signed-off-by: Masahiro Yamada Tested-by: Alexey Brodkin --- scripts/Kbuild.include | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 85d758233483..f641bb0aa63f 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -74,8 +74,13 @@ endef # Usage: CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu- m68k-linux-) # Return first where a gcc is found in PATH. # If no gcc found in PATH with listed prefixes return nothing +# +# Note: '2>/dev/null' is here to force Make to invoke a shell. Otherwise, it +# would try to directly execute the shell builtin 'command'. This workaround +# should be kept for a long time since this issue was fixed only after the +# GNU Make 4.2.1 release. cc-cross-prefix = $(firstword $(foreach c, $(filter-out -%, $(1)), \ - $(if $(shell which $(c)gcc), $(c)))) + $(if $(shell command -v $(c)gcc 2>/dev/null), $(c)))) # output directory for tests below TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/) -- cgit