From: Greg Kroah-Hartman Date: Tue, 11 Dec 2018 15:16:36 +0000 (+0100) Subject: 4.9-stable patches X-Git-Tag: v4.19.9~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=43d5840fcdb71fb9f407dafc14cee64892e649ac;p=thirdparty%2Fkernel%2Fstable-queue.git 4.9-stable patches added patches: kbuild-allow-to-use-gcc-toolchain-not-in-clang-search-path.patch kbuild-fix-linker-feature-test-macros-when-cross-compiling-with-clang.patch --- diff --git a/queue-4.9/kbuild-allow-to-use-gcc-toolchain-not-in-clang-search-path.patch b/queue-4.9/kbuild-allow-to-use-gcc-toolchain-not-in-clang-search-path.patch new file mode 100644 index 00000000000..ea11cc12f18 --- /dev/null +++ b/queue-4.9/kbuild-allow-to-use-gcc-toolchain-not-in-clang-search-path.patch @@ -0,0 +1,56 @@ +From foo@baz Tue Dec 11 16:07:42 CET 2018 +From: Stefan Agner +Date: Wed, 5 Dec 2018 16:45:26 -0800 +Subject: kbuild: allow to use GCC toolchain not in Clang search path + +From: Stefan Agner + +(commit ef8c4ed9db80261f397f0c0bf723684601ae3b52 upstream) + +When using a GCC cross toolchain which is not in a compiled in +Clang search path, Clang reverts to the system assembler and +linker. This leads to assembler or linker errors, depending on +which tool is first used for a given architecture. + +It seems that Clang is not searching $PATH for a matching +assembler or linker. + +Make sure that Clang picks up the correct assembler or linker by +passing the cross compilers bin directory as search path. + +This allows to use Clang provided by distributions with GCC +toolchains not in /usr/bin. + +Link: https://github.com/ClangBuiltLinux/linux/issues/78 +Signed-off-by: Stefan Agner +Reviewed-and-tested-by: Nick Desaulniers +Signed-off-by: Masahiro Yamada +[ND: adjusted to context, due to adjusting the context of my previous +backport of upstream's ae6b289a3789] +Signed-off-by: Nick Desaulniers +Signed-off-by: Greg Kroah-Hartman +--- + Makefile | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +--- a/Makefile ++++ b/Makefile +@@ -512,13 +512,15 @@ endif + ifeq ($(cc-name),clang) + ifneq ($(CROSS_COMPILE),) + CLANG_TARGET := -target $(notdir $(CROSS_COMPILE:%-=%)) +-GCC_TOOLCHAIN := $(realpath $(dir $(shell which $(LD)))/..) ++GCC_TOOLCHAIN_DIR := $(dir $(shell which $(LD))) ++CLANG_PREFIX := --prefix=$(GCC_TOOLCHAIN_DIR) ++GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..) + endif + ifneq ($(GCC_TOOLCHAIN),) + CLANG_GCC_TC := -gcc-toolchain $(GCC_TOOLCHAIN) + endif +-KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) +-KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) ++KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX) ++KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX) + KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,) + KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable) + KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier) diff --git a/queue-4.9/kbuild-fix-linker-feature-test-macros-when-cross-compiling-with-clang.patch b/queue-4.9/kbuild-fix-linker-feature-test-macros-when-cross-compiling-with-clang.patch new file mode 100644 index 00000000000..68950f7f5c4 --- /dev/null +++ b/queue-4.9/kbuild-fix-linker-feature-test-macros-when-cross-compiling-with-clang.patch @@ -0,0 +1,70 @@ +From foo@baz Tue Dec 11 16:07:42 CET 2018 +From: Nick Desaulniers +Date: Tue, 4 Dec 2018 15:39:42 -0800 +Subject: kbuild: fix linker feature test macros when cross compiling with Clang + +From: Nick Desaulniers + +(commit 86a9df597cdd564d2d29c65897bcad42519e3678 upstream) + +I was not seeing my linker flags getting added when using ld-option when +cross compiling with Clang. Upon investigation, this seems to be due to +a difference in how GCC vs Clang handle cross compilation. + +GCC is configured at build time to support one backend, that is implicit +when compiling. Clang is explicit via the use of `-target ` and +ships with all supported backends by default. + +GNU Make feature test macros that compile then link will always fail +when cross compiling with Clang unless Clang's triple is passed along to +the compiler. For example: + +$ clang -x c /dev/null -c -o temp.o +$ aarch64-linux-android/bin/ld -E temp.o +aarch64-linux-android/bin/ld: +unknown architecture of input file `temp.o' is incompatible with +aarch64 output +aarch64-linux-android/bin/ld: +warning: cannot find entry symbol _start; defaulting to +0000000000400078 +$ echo $? +1 + +$ clang -target aarch64-linux-android- -x c /dev/null -c -o temp.o +$ aarch64-linux-android/bin/ld -E temp.o +aarch64-linux-android/bin/ld: +warning: cannot find entry symbol _start; defaulting to 00000000004002e4 +$ echo $? +0 + +This causes conditional checks that invoke $(CC) without the target +triple, then $(LD) on the result, to always fail. + +Suggested-by: Masahiro Yamada +Signed-off-by: Nick Desaulniers +Reviewed-by: Matthias Kaehlcke +Signed-off-by: Masahiro Yamada +[ND: readjusted for context] +Signed-off-by: Greg Kroah-Hartman +--- + scripts/Kbuild.include | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +--- a/scripts/Kbuild.include ++++ b/scripts/Kbuild.include +@@ -162,12 +162,13 @@ cc-ifversion = $(shell [ $(cc-version) $ + # cc-ldoption + # Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both) + cc-ldoption = $(call try-run,\ +- $(CC) $(1) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2)) ++ $(CC) $(1) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2)) + + # ld-option + # Usage: LDFLAGS += $(call ld-option, -X) + ld-option = $(call try-run,\ +- $(CC) -x c /dev/null -c -o "$$TMPO" ; $(LD) $(1) "$$TMPO" -o "$$TMP",$(1),$(2)) ++ $(CC) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -x c /dev/null -c -o "$$TMPO"; \ ++ $(LD) $(LDFLAGS) $(1) "$$TMPO" -o "$$TMP",$(1),$(2)) + + # ar-option + # Usage: KBUILD_ARFLAGS := $(call ar-option,D) diff --git a/queue-4.9/series b/queue-4.9/series index b55d917f839..7c8179e9dff 100644 --- a/queue-4.9/series +++ b/queue-4.9/series @@ -47,3 +47,5 @@ mac80211-clear-beacon_int-in-ieee80211_do_stop.patch mac80211-ignore-tx-status-for-ps-stations-in-ieee80211_tx_status_ext.patch mac80211-fix-reordering-of-buffered-broadcast-packets.patch mac80211-ignore-nullfunc-frames-in-the-duplicate-detection.patch +kbuild-fix-linker-feature-test-macros-when-cross-compiling-with-clang.patch +kbuild-allow-to-use-gcc-toolchain-not-in-clang-search-path.patch