summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorNathan Chancellor <nathan@kernel.org>2021-04-22 13:19:14 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-01-27 09:04:13 +0100
commit8ebd2cc3056fbb75c05751a09525e76d0cfb53e0 (patch)
treeb24feae6aeb444bbf714c57268997364205002d0 /Makefile
parentce519606009045d6d8e04cd033dfa2f0c63aa57e (diff)
downloadlinux-stable-8ebd2cc3056fbb75c05751a09525e76d0cfb53e0.tar.gz
linux-stable-8ebd2cc3056fbb75c05751a09525e76d0cfb53e0.tar.bz2
linux-stable-8ebd2cc3056fbb75c05751a09525e76d0cfb53e0.zip
kbuild: Add $(KBUILD_HOSTLDFLAGS) to 'has_libelf' test
commit f634ca650f724347892068489c7920631a3aac6a upstream. Normally, invocations of $(HOSTCC) include $(KBUILD_HOSTLDFLAGS), which in turn includes $(HOSTLDFLAGS), which allows users to pass in their own flags when linking. However, the 'has_libelf' test does not, meaning that if a user requests a specific linker via HOSTLDFLAGS=-fuse-ld=..., it is not respected and the build might error. For example, if a user building with clang wants to use all of the LLVM tools without any GNU tools, they might remove all of the GNU tools from their system or PATH then build with $ make HOSTLDFLAGS=-fuse-ld=lld LLVM=1 LLVM_IAS=1 which says use all of the LLVM tools, the integrated assembler, and ld.lld for linking host executables. Without this change, the build will error because $(HOSTCC) uses its default linker, rather than the one requested via -fuse-ld=..., which is GNU ld in clang's case in a default configuration. error: Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel make[1]: *** [Makefile:1260: prepare-objtool] Error 1 Add $(KBUILD_HOSTLDFLAGS) to the 'has_libelf' test so that the linker choice is respected. Link: https://github.com/ClangBuiltLinux/linux/issues/479 Signed-off-by: Nathan Chancellor <nathan@kernel.org> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Signed-off-by: Paul Barker <paul.barker@sancloud.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile2
1 files changed, 1 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 891dcd4eadc5..1bb456993c9e 100644
--- a/Makefile
+++ b/Makefile
@@ -972,7 +972,7 @@ HOST_LIBELF_LIBS = $(shell pkg-config libelf --libs 2>/dev/null || echo -lelf)
ifdef CONFIG_STACK_VALIDATION
has_libelf := $(call try-run,\
- echo "int main() {}" | $(HOSTCC) -xc -o /dev/null $(HOST_LIBELF_LIBS) -,1,0)
+ echo "int main() {}" | $(HOSTCC) $(KBUILD_HOSTLDFLAGS) -xc -o /dev/null $(HOST_LIBELF_LIBS) -,1,0)
ifeq ($(has_libelf),1)
objtool_target := tools/objtool FORCE
else