Skip to content

Commit f11c061

Browse files
t-8chopsiff
authored andcommitted
kbuild: userprogs: use correct linker when mixing clang and GNU ld
commit 936599ca514973d44a766b7376c6bbdc96b6a8cc upstream. The userprogs infrastructure does not expect clang being used with GNU ld and in that case uses /usr/bin/ld for linking, not the configured $(LD). This fallback is problematic as it will break when cross-compiling. Mixing clang and GNU ld is used for example when building for SPARC64, as ld.lld is not sufficient; see Documentation/kbuild/llvm.rst. Relax the check around --ld-path so it gets used for all linkers. Fixes: dfc1b16 ("kbuild: userprogs: use correct lld when linking through clang") Cc: [email protected] Signed-off-by: Thomas Weißschuh <[email protected]> Reviewed-by: Nathan Chancellor <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]> [nathan: Work around wrapping '--ld-path' in cc-option in older stable branches due to older minimum LLVM version] Signed-off-by: Nathan Chancellor <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> (cherry picked from commit 0ed2068de1f9afdde56436af91aba8cbb77c2741)
1 parent b3127a7 commit f11c061

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,7 @@ KBUILD_USERCFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CPPFLAGS) $(KBUILD
10711071
KBUILD_USERLDFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS))
10721072

10731073
# userspace programs are linked via the compiler, use the correct linker
1074-
ifeq ($(CONFIG_CC_IS_CLANG)$(CONFIG_LD_IS_LLD),yy)
1074+
ifdef CONFIG_CC_IS_CLANG
10751075
KBUILD_USERLDFLAGS += $(call cc-option, --ld-path=$(LD))
10761076
endif
10771077

0 commit comments

Comments
 (0)