BACKPORT: FROMGIT: 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 <keescook@chromium.org> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> Tested-by: Nick Desaulniers <ndesaulniers@google.com> Reviewed-by: Nathan Chancellor <natechancellor@gmail.com> Tested-by: Nathan Chancellor <natechancellor@gmail.com> Reviewed-by: Fangrui Song <maskray@google.com> Reviewed-by: Sedat Dilek <sedat.dilek@gmail.com> Tested-by: Sedat Dilek <sedat.dilek@gmail.com> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Bug: 153484457 (cherry picked from commit 6f04f056df3c https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git for-next) [nd: commit 4b950bb9ac0c ("Kbuild: Handle PREEMPT_RT for version string and magic") missing in 4.14, first landed in 5.4-rc1. commit b79c6aa6a1f1 ("kbuild: remove unnecessary in-subshell execution") missing in 4.14, first landed in 5.1-rc1. ] Change-Id: Ifa5a98fe159392862e8d07a733c0f141fa9c7715 Signed-off-by: Nick Desaulniers <ndesaulniers@google.com> Signed-off-by: Danny Lin <danny@kdrag0n.dev>
This commit is contained in:
parent
c178081cc5
commit
9c537aaffc
2 changed files with 11 additions and 5 deletions
|
@ -37,5 +37,6 @@ $(obj)/version.o: include/generated/compile.h
|
|||
silent_chk_compile.h = :
|
||||
include/generated/compile.h: FORCE
|
||||
@$($(quiet)chk_compile.h)
|
||||
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkcompile_h $@ \
|
||||
"$(UTS_MACHINE)" "$(CONFIG_SMP)" "$(CONFIG_PREEMPT)" "$(CC) $(KBUILD_CFLAGS)"
|
||||
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkcompile_h $@ \
|
||||
"$(UTS_MACHINE)" "$(CONFIG_SMP)" "$(CONFIG_PREEMPT)" \
|
||||
"$(CC) $(KBUILD_CFLAGS)" "$(LD)"
|
||||
|
|
|
@ -5,6 +5,7 @@ ARCH=$2
|
|||
SMP=$3
|
||||
PREEMPT=$4
|
||||
CC=$5
|
||||
LD=$6
|
||||
|
||||
vecho() { [ "${quiet}" = "silent_" ] || echo "$@" ; }
|
||||
|
||||
|
@ -77,10 +78,14 @@ UTS_TRUNCATE="cut -b -$UTS_LEN"
|
|||
echo \#define LINUX_COMPILE_HOST \"`echo $LINUX_COMPILE_HOST | $UTS_TRUNCATE`\"
|
||||
|
||||
if [ -z "$KBUILD_COMPILER_STRING" ]; then
|
||||
echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | grep ' version ' | sed 's/[[:space:]]*$//'`\"
|
||||
CC_VERSION=$($CC -v 2>&1 | grep ' version ' | sed 's/[[:space:]]*$//')
|
||||
else
|
||||
echo \#define LINUX_COMPILER \"$KBUILD_COMPILER_STRING\"
|
||||
fi;
|
||||
CC_VERSION="$KBUILD_COMPILER_STRING"
|
||||
fi
|
||||
|
||||
LD_VERSION=$($LD -v | head -n1 | sed 's/(compatible with [^)]*)//' \
|
||||
| sed 's/[[:space:]]*$//')
|
||||
printf '#define LINUX_COMPILER "%s"\n' "$CC_VERSION, $LD_VERSION"
|
||||
) > .tmpcompile
|
||||
|
||||
# Only replace the real compile.h if the new one is different,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue