Skip to content

Commit 4dcc9a8

Browse files
keesmasahir0y
authored andcommitted
kbuild: mkcompile_h: Include $LD version in /proc/version
When doing Clang builds of the kernel, it is possible to link with either ld.bfd (binutils) or ld.lld (LLVM), but it is not possible to discover this from a running kernel. Add the "$LD -v" output to /proc/version. Signed-off-by: Kees Cook <[email protected]> Reviewed-by: Nick Desaulniers <[email protected]> Tested-by: Nick Desaulniers <[email protected]> Reviewed-by: Nathan Chancellor <[email protected]> Tested-by: Nathan Chancellor <[email protected]> Reviewed-by: Fangrui Song <[email protected]> Reviewed-by: Sedat Dilek <[email protected]> Tested-by: Sedat Dilek <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]>
1 parent 60969f0 commit 4dcc9a8

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

init/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ include/generated/compile.h: FORCE
3535
@$($(quiet)chk_compile.h)
3636
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkcompile_h $@ \
3737
"$(UTS_MACHINE)" "$(CONFIG_SMP)" "$(CONFIG_PREEMPT)" \
38-
"$(CONFIG_PREEMPT_RT)" "$(CC) $(KBUILD_CFLAGS)"
38+
"$(CONFIG_PREEMPT_RT)" "$(CC) $(KBUILD_CFLAGS)" "$(LD)"

scripts/mkcompile_h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ SMP=$3
77
PREEMPT=$4
88
PREEMPT_RT=$5
99
CC=$6
10+
LD=$7
1011

1112
vecho() { [ "${quiet}" = "silent_" ] || echo "$@" ; }
1213

@@ -61,7 +62,10 @@ UTS_VERSION="$(echo $UTS_VERSION $CONFIG_FLAGS $TIMESTAMP | cut -b -$UTS_LEN)"
6162
printf '#define LINUX_COMPILE_BY "%s"\n' "$LINUX_COMPILE_BY"
6263
echo \#define LINUX_COMPILE_HOST \"$LINUX_COMPILE_HOST\"
6364

64-
echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | grep ' version ' | sed 's/[[:space:]]*$//'`\"
65+
CC_VERSION=$($CC -v 2>&1 | grep ' version ' | sed 's/[[:space:]]*$//')
66+
LD_VERSION=$($LD -v | head -n1 | sed 's/(compatible with [^)]*)//' \
67+
| sed 's/[[:space:]]*$//')
68+
printf '#define LINUX_COMPILER "%s"\n' "$CC_VERSION, $LD_VERSION"
6569
} > .tmpcompile
6670

6771
# Only replace the real compile.h if the new one is different,

0 commit comments

Comments
 (0)