Skip to content

Commit d5750cd

Browse files
nathanchancemasahir0y
authored andcommitted
kbuild: Disable CONFIG_LD_ORPHAN_WARN for ld.lld 10.0.1
ld.lld 10.0.1 spews a bunch of various warnings about .rela sections, along with a few others. Newer versions of ld.lld do not have these warnings. As a result, do not add '--orphan-handling=warn' to LDFLAGS_vmlinux if ld.lld's version is not new enough. Link: ClangBuiltLinux#1187 Link: ClangBuiltLinux#1193 Reported-by: Arvind Sankar <[email protected]> Reported-by: kernelci.org bot <[email protected]> Reported-by: Mark Brown <[email protected]> Reviewed-by: Kees Cook <[email protected]> Signed-off-by: Nathan Chancellor <[email protected]> Reviewed-by: Nick Desaulniers <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]>
1 parent 59612b2 commit d5750cd

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4274,6 +4274,7 @@ B: https://github.com/ClangBuiltLinux/linux/issues
42744274
C: irc://chat.freenode.net/clangbuiltlinux
42754275
F: Documentation/kbuild/llvm.rst
42764276
F: scripts/clang-tools/
4277+
F: scripts/lld-version.sh
42774278
K: \b(?i:clang|llvm)\b
42784279

42794280
CLEANCACHE API

init/Kconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ config CLANG_VERSION
4747
int
4848
default $(shell,$(srctree)/scripts/clang-version.sh $(CC))
4949

50+
config LLD_VERSION
51+
int
52+
default $(shell,$(srctree)/scripts/lld-version.sh $(LD))
53+
5054
config CC_CAN_LINK
5155
bool
5256
default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) $(CLANG_FLAGS) $(m64-flag)) if 64BIT
@@ -1351,6 +1355,7 @@ config LD_DEAD_CODE_DATA_ELIMINATION
13511355
config LD_ORPHAN_WARN
13521356
def_bool y
13531357
depends on ARCH_WANT_LD_ORPHAN_WARN
1358+
depends on !LD_IS_LLD || LLD_VERSION >= 110000
13541359
depends on $(ld-option,--orphan-handling=warn)
13551360

13561361
config SYSCTL

scripts/lld-version.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
# SPDX-License-Identifier: GPL-2.0
3+
#
4+
# Usage: $ ./scripts/lld-version.sh ld.lld
5+
#
6+
# Print the linker version of `ld.lld' in a 5 or 6-digit form
7+
# such as `100001' for ld.lld 10.0.1 etc.
8+
9+
linker_string="$($* --version)"
10+
11+
if ! ( echo $linker_string | grep -q LLD ); then
12+
echo 0
13+
exit 1
14+
fi
15+
16+
VERSION=$(echo $linker_string | cut -d ' ' -f 2)
17+
MAJOR=$(echo $VERSION | cut -d . -f 1)
18+
MINOR=$(echo $VERSION | cut -d . -f 2)
19+
PATCHLEVEL=$(echo $VERSION | cut -d . -f 3)
20+
printf "%d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL

0 commit comments

Comments
 (0)