* [PATCH] kbuild: compile_h: fix compiler version detection with clang
@ 2020-05-14 22:19 Yuxuan Shui
2020-05-14 23:25 ` Nick Desaulniers
2020-05-15 0:42 ` Masahiro Yamada
0 siblings, 2 replies; 3+ messages in thread
From: Yuxuan Shui @ 2020-05-14 22:19 UTC (permalink / raw)
To: linux-kernel; +Cc: masahiroy, michal.lkml, linux-kbuild, clang-built-linux
[-- Attachment #1: Type: text/plain, Size: 1141 bytes --]
In some setup clang will print a line about CUDA version it detects,
like this:
Found CUDA installation: /opt/cuda, version 10.1
So grepping ' version ' matches 2 lines, and results in a broken string in
compiler.h, which doesn't compile.
This commit adds a "head -n1" to fix this problem.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
---
scripts/mkcompile_h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/mkcompile_h b/scripts/mkcompile_h
index 5b80a4699740..8e6b4fc6fdd9 100755
--- a/scripts/mkcompile_h
+++ b/scripts/mkcompile_h
@@ -62,7 +62,7 @@ UTS_VERSION="$(echo $UTS_VERSION $CONFIG_FLAGS $TIMESTAMP | cut -b -$UTS_LEN)"
printf '#define LINUX_COMPILE_BY "%s"\n' "$LINUX_COMPILE_BY"
echo \#define LINUX_COMPILE_HOST \"$LINUX_COMPILE_HOST\"
- CC_VERSION=$($CC -v 2>&1 | grep ' version ' | sed 's/[[:space:]]*$//')
+ CC_VERSION=$($CC -v 2>&1 | grep ' version ' | head -n1 | sed 's/[[:space:]]*$//')
LD_VERSION=$($LD -v | head -n1 | sed 's/(compatible with [^)]*)//' \
| sed 's/[[:space:]]*$//')
printf '#define LINUX_COMPILER "%s"\n' "$CC_VERSION, $LD_VERSION"
--
2.26.2
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] kbuild: compile_h: fix compiler version detection with clang
2020-05-14 22:19 [PATCH] kbuild: compile_h: fix compiler version detection with clang Yuxuan Shui
@ 2020-05-14 23:25 ` Nick Desaulniers
2020-05-15 0:42 ` Masahiro Yamada
1 sibling, 0 replies; 3+ messages in thread
From: Nick Desaulniers @ 2020-05-14 23:25 UTC (permalink / raw)
To: Yuxuan Shui
Cc: LKML, Masahiro Yamada, Michal Marek, Linux Kbuild mailing list,
clang-built-linux
On Thu, May 14, 2020 at 3:43 PM Yuxuan Shui <yshuiv7@gmail.com> wrote:
>
>
> In some setup clang will print a line about CUDA version it detects,
> like this:
>
> Found CUDA installation: /opt/cuda, version 10.1
>
> So grepping ' version ' matches 2 lines, and results in a broken string in
> compiler.h, which doesn't compile.
>
> This commit adds a "head -n1" to fix this problem.
>
> Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
Hi Yuxuan, thanks for the patch!
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Might be worthwhile for Masahiro to add
Cc: stable@vger.kernel.org
if/when picked up?
> ---
> scripts/mkcompile_h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/mkcompile_h b/scripts/mkcompile_h
> index 5b80a4699740..8e6b4fc6fdd9 100755
> --- a/scripts/mkcompile_h
> +++ b/scripts/mkcompile_h
> @@ -62,7 +62,7 @@ UTS_VERSION="$(echo $UTS_VERSION $CONFIG_FLAGS $TIMESTAMP | cut -b -$UTS_LEN)"
> printf '#define LINUX_COMPILE_BY "%s"\n' "$LINUX_COMPILE_BY"
> echo \#define LINUX_COMPILE_HOST \"$LINUX_COMPILE_HOST\"
>
> - CC_VERSION=$($CC -v 2>&1 | grep ' version ' | sed 's/[[:space:]]*$//')
> + CC_VERSION=$($CC -v 2>&1 | grep ' version ' | head -n1 | sed 's/[[:space:]]*$//')
> LD_VERSION=$($LD -v | head -n1 | sed 's/(compatible with [^)]*)//' \
> | sed 's/[[:space:]]*$//')
> printf '#define LINUX_COMPILER "%s"\n' "$CC_VERSION, $LD_VERSION"
> --
> 2.26.2
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] kbuild: compile_h: fix compiler version detection with clang
2020-05-14 22:19 [PATCH] kbuild: compile_h: fix compiler version detection with clang Yuxuan Shui
2020-05-14 23:25 ` Nick Desaulniers
@ 2020-05-15 0:42 ` Masahiro Yamada
1 sibling, 0 replies; 3+ messages in thread
From: Masahiro Yamada @ 2020-05-15 0:42 UTC (permalink / raw)
To: Yuxuan Shui
Cc: Linux Kernel Mailing List, Michal Marek,
Linux Kbuild mailing list, clang-built-linux
On Fri, May 15, 2020 at 7:43 AM Yuxuan Shui <yshuiv7@gmail.com> wrote:
>
>
> In some setup clang will print a line about CUDA version it detects,
> like this:
>
> Found CUDA installation: /opt/cuda, version 10.1
>
> So grepping ' version ' matches 2 lines, and results in a broken string in
> compiler.h, which doesn't compile.
>
> This commit adds a "head -n1" to fix this problem.
>
> Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
I do not know what to do about this.
This problem had already been fixed by a different
patch, which is queued up in linux-next.
9a950154668729a472d17b8e307d92e7c60f45f7
This patch
https://patchwork.kernel.org/patch/11505803/
So, the future releases will be OK.
For back-porting to the stable kernel,
your one-liner fixup is simpler.
> ---
> scripts/mkcompile_h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/mkcompile_h b/scripts/mkcompile_h
> index 5b80a4699740..8e6b4fc6fdd9 100755
> --- a/scripts/mkcompile_h
> +++ b/scripts/mkcompile_h
> @@ -62,7 +62,7 @@ UTS_VERSION="$(echo $UTS_VERSION $CONFIG_FLAGS $TIMESTAMP | cut -b -$UTS_LEN)"
> printf '#define LINUX_COMPILE_BY "%s"\n' "$LINUX_COMPILE_BY"
> echo \#define LINUX_COMPILE_HOST \"$LINUX_COMPILE_HOST\"
>
> - CC_VERSION=$($CC -v 2>&1 | grep ' version ' | sed 's/[[:space:]]*$//')
> + CC_VERSION=$($CC -v 2>&1 | grep ' version ' | head -n1 | sed 's/[[:space:]]*$//')
> LD_VERSION=$($LD -v | head -n1 | sed 's/(compatible with [^)]*)//' \
> | sed 's/[[:space:]]*$//')
> printf '#define LINUX_COMPILER "%s"\n' "$CC_VERSION, $LD_VERSION"
> --
> 2.26.2
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-05-15 0:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-14 22:19 [PATCH] kbuild: compile_h: fix compiler version detection with clang Yuxuan Shui
2020-05-14 23:25 ` Nick Desaulniers
2020-05-15 0:42 ` Masahiro Yamada
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).