LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] kbuild: collect minimum tool versions into scripts/min-tool-version.sh
@ 2021-03-11  9:46 Masahiro Yamada
  2021-03-11 10:18 ` Miguel Ojeda
  2021-03-12 11:10 ` Sedat Dilek
  0 siblings, 2 replies; 6+ messages in thread
From: Masahiro Yamada @ 2021-03-11  9:46 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Nicolas Pitre, Masahiro Yamada, Nathan Chancellor,
	Bernhard Rosenkränzer, Miguel Ojeda, Nick Desaulniers,
	Will Deacon, clang-built-linux, linux-kernel

The kernel build uses various tools, many of which are provided by the
same software suite, for example, LLVM and Binutils.

When you raise the minimum version of Clang/LLVM, you need to update
clang_min_version in scripts/cc-version.sh and also lld_min_version in
scripts/ld-version.sh.

Kbuild can handle CC=clang and LD=ld.lld independently, but it does not
make much sense to maintain their versions separately.

Let's make scripts/min-tool-version.sh a central place of minimum tool
versions so you do not need to touch multiple files.

This script prints the minimum version of the given tool.

  $ scripts/min-tool-version.sh gcc
  4.9.0
  $ scripts/min-tool-version.sh llvm
  10.0.1
  $ scripts/min-tool-version.sh binutils
  2.23.0
  $ scripts/min-tool-version.sh foo
  foo: unknown tool

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
---

 scripts/cc-version.sh       | 20 +++++---------------
 scripts/ld-version.sh       | 11 ++++-------
 scripts/min-tool-version.sh | 27 +++++++++++++++++++++++++++
 3 files changed, 36 insertions(+), 22 deletions(-)
 create mode 100755 scripts/min-tool-version.sh

diff --git a/scripts/cc-version.sh b/scripts/cc-version.sh
index 3f2ee885b116..f1952c522466 100755
--- a/scripts/cc-version.sh
+++ b/scripts/cc-version.sh
@@ -6,18 +6,6 @@
 
 set -e
 
-# When you raise the minimum compiler version, please update
-# Documentation/process/changes.rst as well.
-gcc_min_version=4.9.0
-clang_min_version=10.0.1
-icc_min_version=16.0.3 # temporary
-
-# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63293
-# https://lore.kernel.org/r/20210107111841.GN1551@shell.armlinux.org.uk
-if [ "$SRCARCH" = arm64 ]; then
-	gcc_min_version=5.1.0
-fi
-
 # Print the compiler name and some version components.
 get_compiler_info()
 {
@@ -48,18 +36,20 @@ set -- $(get_compiler_info "$@")
 
 name=$1
 
+min_tool_version=$(dirname $0)/min-tool-version.sh
+
 case "$name" in
 GCC)
 	version=$2.$3.$4
-	min_version=$gcc_min_version
+	min_version=$($min_tool_version gcc)
 	;;
 Clang)
 	version=$2.$3.$4
-	min_version=$clang_min_version
+	min_version=$($min_tool_version llvm)
 	;;
 ICC)
 	version=$(($2 / 100)).$(($2 % 100)).$3
-	min_version=$icc_min_version
+	min_version=$($min_tool_version icc)
 	;;
 *)
 	echo "$orig_args: unknown compiler" >&2
diff --git a/scripts/ld-version.sh b/scripts/ld-version.sh
index 30debf78aa09..5b9481e98b4f 100755
--- a/scripts/ld-version.sh
+++ b/scripts/ld-version.sh
@@ -6,11 +6,6 @@
 
 set -e
 
-# When you raise the minimum linker version, please update
-# Documentation/process/changes.rst as well.
-bfd_min_version=2.23.0
-lld_min_version=10.0.1
-
 # Convert the version string x.y.z to a canonical 5 or 6-digit form.
 get_canonical_version()
 {
@@ -35,10 +30,12 @@ set -- $("$@" --version)
 IFS=' '
 set -- $1
 
+min_tool_version=$(dirname $0)/min-tool-version.sh
+
 if [ "$1" = GNU -a "$2" = ld ]; then
 	shift $(($# - 1))
 	version=$1
-	min_version=$bfd_min_version
+	min_version=$($min_tool_version binutils)
 	name=BFD
 	disp_name="GNU ld"
 elif [ "$1" = GNU -a "$2" = gold ]; then
@@ -51,7 +48,7 @@ else
 
 	if [ "$1" = LLD ]; then
 		version=$2
-		min_version=$lld_min_version
+		min_version=$($min_tool_version llvm)
 		name=LLD
 		disp_name=LLD
 	else
diff --git a/scripts/min-tool-version.sh b/scripts/min-tool-version.sh
new file mode 100755
index 000000000000..37c438d766d7
--- /dev/null
+++ b/scripts/min-tool-version.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Print the minimum supported version of the given tool.
+
+set -e
+
+# When you raise the minimum version, please update
+# Documentation/process/changes.rst as well.
+min_gcc_version=4.9.0
+min_llvm_version=10.0.1
+min_icc_version=16.0.3 # temporary
+min_binutils_version=2.23.0
+
+# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63293
+# https://lore.kernel.org/r/20210107111841.GN1551@shell.armlinux.org.uk
+if [ "$SRCARCH" = arm64 ]; then
+	min_gcc_version=5.1.0
+fi
+
+eval min_version="\$min_${1}_version"
+if [ -z "$min_version" ]; then
+	echo "$1: unknown tool" >&2
+	exit 1
+fi
+
+echo "$min_version"
-- 
2.27.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] kbuild: collect minimum tool versions into scripts/min-tool-version.sh
  2021-03-11  9:46 [PATCH] kbuild: collect minimum tool versions into scripts/min-tool-version.sh Masahiro Yamada
@ 2021-03-11 10:18 ` Miguel Ojeda
  2021-03-11 10:33   ` Masahiro Yamada
  2021-03-12  1:19   ` Nicolas Pitre
  2021-03-12 11:10 ` Sedat Dilek
  1 sibling, 2 replies; 6+ messages in thread
From: Miguel Ojeda @ 2021-03-11 10:18 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Linux Kbuild mailing list, Nicolas Pitre, Nathan Chancellor,
	Bernhard Rosenkränzer, Miguel Ojeda, Nick Desaulniers,
	Will Deacon, clang-built-linux, linux-kernel

On Thu, Mar 11, 2021 at 10:47 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> +# When you raise the minimum version, please update
> +# Documentation/process/changes.rst as well.
> +min_gcc_version=4.9.0
> +min_llvm_version=10.0.1
> +min_icc_version=16.0.3 # temporary
> +min_binutils_version=2.23.0

+1 to creating a central place for all minimum versions.

    Acked-by: Miguel Ojeda <ojeda@kernel.org>

I wonder if you considered creating a folder with files like
`scripts/min_versions/gcc` containing the version string. That would
make it easier for reading from other languages or even importing them
dynamically into the documentation, thus removing even more
duplication.

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] kbuild: collect minimum tool versions into scripts/min-tool-version.sh
  2021-03-11 10:18 ` Miguel Ojeda
@ 2021-03-11 10:33   ` Masahiro Yamada
  2021-03-11 11:15     ` Miguel Ojeda
  2021-03-12  1:19   ` Nicolas Pitre
  1 sibling, 1 reply; 6+ messages in thread
From: Masahiro Yamada @ 2021-03-11 10:33 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Linux Kbuild mailing list, Nicolas Pitre, Nathan Chancellor,
	Bernhard Rosenkränzer, Miguel Ojeda, Nick Desaulniers,
	Will Deacon, clang-built-linux, linux-kernel

On Thu, Mar 11, 2021 at 7:18 PM Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
>
> On Thu, Mar 11, 2021 at 10:47 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
> >
> > +# When you raise the minimum version, please update
> > +# Documentation/process/changes.rst as well.
> > +min_gcc_version=4.9.0
> > +min_llvm_version=10.0.1
> > +min_icc_version=16.0.3 # temporary
> > +min_binutils_version=2.23.0
>
> +1 to creating a central place for all minimum versions.
>
>     Acked-by: Miguel Ojeda <ojeda@kernel.org>
>
> I wonder if you considered creating a folder with files like
> `scripts/min_versions/gcc` containing the version string. That would
> make it easier for reading from other languages or even importing them
> dynamically into the documentation, thus removing even more
> duplication.
>
> Cheers,
> Miguel


Hmm, that is a simple, clean idea.
Then, we can simply read out the file

$ cat scripts/min_versions/gcc
4.9.0

I do not know how to handle
per-arch versions in this case.




Or, we might need to stick to shell-scripting
to handle this.

scripts/min_versions/gcc
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-only
if [ "$SRCARCH" = arm64 ]; then
       echo 5.1.0
else
       echo 4.9.0
fi


-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] kbuild: collect minimum tool versions into scripts/min-tool-version.sh
  2021-03-11 10:33   ` Masahiro Yamada
@ 2021-03-11 11:15     ` Miguel Ojeda
  0 siblings, 0 replies; 6+ messages in thread
From: Miguel Ojeda @ 2021-03-11 11:15 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Linux Kbuild mailing list, Nicolas Pitre, Nathan Chancellor,
	Bernhard Rosenkränzer, Miguel Ojeda, Nick Desaulniers,
	Will Deacon, clang-built-linux, linux-kernel

On Thu, Mar 11, 2021 at 11:34 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> Hmm, that is a simple, clean idea.
> Then, we can simply read out the file
>
> $ cat scripts/min_versions/gcc
> 4.9.0

Exactly!

> I do not know how to handle
> per-arch versions in this case.

Perhaps we should just push for 5.1.0 everywhere ;-P

Otherwise, we could still have `min-tool-versions.sh` with something like:

    $ cat scripts/min_versions/gcc
    4.9.0
    $ cat scripts/min_versions/gcc_arm64
    5.1.0
    $ cat scripts/min-tool-versions.sh
    if min_versions/$tool_$arch exists
        print that one
    else
        print the default one: min_versions/$tool

i.e. having the plain files allow us to extend the cases without
listing them explicitly in the script, plus it is anyway useful to
separate data from code :-)

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] kbuild: collect minimum tool versions into scripts/min-tool-version.sh
  2021-03-11 10:18 ` Miguel Ojeda
  2021-03-11 10:33   ` Masahiro Yamada
@ 2021-03-12  1:19   ` Nicolas Pitre
  1 sibling, 0 replies; 6+ messages in thread
From: Nicolas Pitre @ 2021-03-12  1:19 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Masahiro Yamada, Linux Kbuild mailing list, Nathan Chancellor,
	Bernhard Rosenkränzer, Miguel Ojeda, Nick Desaulniers,
	Will Deacon, clang-built-linux, linux-kernel

On Thu, 11 Mar 2021, Miguel Ojeda wrote:

> On Thu, Mar 11, 2021 at 10:47 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
> >
> > +# When you raise the minimum version, please update
> > +# Documentation/process/changes.rst as well.
> > +min_gcc_version=4.9.0
> > +min_llvm_version=10.0.1
> > +min_icc_version=16.0.3 # temporary
> > +min_binutils_version=2.23.0
> 
> +1 to creating a central place for all minimum versions.
> 
>     Acked-by: Miguel Ojeda <ojeda@kernel.org>
> 
> I wonder if you considered creating a folder with files like
> `scripts/min_versions/gcc` containing the version string. That would
> make it easier for reading from other languages or even importing them
> dynamically into the documentation, thus removing even more
> duplication.

Alternatively, the documentation could be the actual reference and the 
script would parse the documentation to get those values out.


Nicolas

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] kbuild: collect minimum tool versions into scripts/min-tool-version.sh
  2021-03-11  9:46 [PATCH] kbuild: collect minimum tool versions into scripts/min-tool-version.sh Masahiro Yamada
  2021-03-11 10:18 ` Miguel Ojeda
@ 2021-03-12 11:10 ` Sedat Dilek
  1 sibling, 0 replies; 6+ messages in thread
From: Sedat Dilek @ 2021-03-12 11:10 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kbuild, Nicolas Pitre, Nathan Chancellor,
	Bernhard Rosenkränzer, Miguel Ojeda, Nick Desaulniers,
	Will Deacon, Clang-Built-Linux ML, linux-kernel

On Thu, Mar 11, 2021 at 10:47 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> The kernel build uses various tools, many of which are provided by the
> same software suite, for example, LLVM and Binutils.
>
> When you raise the minimum version of Clang/LLVM, you need to update
> clang_min_version in scripts/cc-version.sh and also lld_min_version in
> scripts/ld-version.sh.
>
> Kbuild can handle CC=clang and LD=ld.lld independently, but it does not
> make much sense to maintain their versions separately.
>
> Let's make scripts/min-tool-version.sh a central place of minimum tool
> versions so you do not need to touch multiple files.
>
> This script prints the minimum version of the given tool.
>
>   $ scripts/min-tool-version.sh gcc
>   4.9.0
>   $ scripts/min-tool-version.sh llvm
>   10.0.1
>   $ scripts/min-tool-version.sh binutils
>   2.23.0
>   $ scripts/min-tool-version.sh foo
>   foo: unknown tool
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> Reviewed-by: Nathan Chancellor <nathan@kernel.org>

The idea with creating gcc, llvm, binutils etc. files containing the
minimum version-string sounds good to me.

This version here tested on Debian/testing AMD64.

Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # LLVM/Clang v12.0.0-rc3

- Sedat -

> ---
>
>  scripts/cc-version.sh       | 20 +++++---------------
>  scripts/ld-version.sh       | 11 ++++-------
>  scripts/min-tool-version.sh | 27 +++++++++++++++++++++++++++
>  3 files changed, 36 insertions(+), 22 deletions(-)
>  create mode 100755 scripts/min-tool-version.sh
>
> diff --git a/scripts/cc-version.sh b/scripts/cc-version.sh
> index 3f2ee885b116..f1952c522466 100755
> --- a/scripts/cc-version.sh
> +++ b/scripts/cc-version.sh
> @@ -6,18 +6,6 @@
>
>  set -e
>
> -# When you raise the minimum compiler version, please update
> -# Documentation/process/changes.rst as well.
> -gcc_min_version=4.9.0
> -clang_min_version=10.0.1
> -icc_min_version=16.0.3 # temporary
> -
> -# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63293
> -# https://lore.kernel.org/r/20210107111841.GN1551@shell.armlinux.org.uk
> -if [ "$SRCARCH" = arm64 ]; then
> -       gcc_min_version=5.1.0
> -fi
> -
>  # Print the compiler name and some version components.
>  get_compiler_info()
>  {
> @@ -48,18 +36,20 @@ set -- $(get_compiler_info "$@")
>
>  name=$1
>
> +min_tool_version=$(dirname $0)/min-tool-version.sh
> +
>  case "$name" in
>  GCC)
>         version=$2.$3.$4
> -       min_version=$gcc_min_version
> +       min_version=$($min_tool_version gcc)
>         ;;
>  Clang)
>         version=$2.$3.$4
> -       min_version=$clang_min_version
> +       min_version=$($min_tool_version llvm)
>         ;;
>  ICC)
>         version=$(($2 / 100)).$(($2 % 100)).$3
> -       min_version=$icc_min_version
> +       min_version=$($min_tool_version icc)
>         ;;
>  *)
>         echo "$orig_args: unknown compiler" >&2
> diff --git a/scripts/ld-version.sh b/scripts/ld-version.sh
> index 30debf78aa09..5b9481e98b4f 100755
> --- a/scripts/ld-version.sh
> +++ b/scripts/ld-version.sh
> @@ -6,11 +6,6 @@
>
>  set -e
>
> -# When you raise the minimum linker version, please update
> -# Documentation/process/changes.rst as well.
> -bfd_min_version=2.23.0
> -lld_min_version=10.0.1
> -
>  # Convert the version string x.y.z to a canonical 5 or 6-digit form.
>  get_canonical_version()
>  {
> @@ -35,10 +30,12 @@ set -- $("$@" --version)
>  IFS=' '
>  set -- $1
>
> +min_tool_version=$(dirname $0)/min-tool-version.sh
> +
>  if [ "$1" = GNU -a "$2" = ld ]; then
>         shift $(($# - 1))
>         version=$1
> -       min_version=$bfd_min_version
> +       min_version=$($min_tool_version binutils)
>         name=BFD
>         disp_name="GNU ld"
>  elif [ "$1" = GNU -a "$2" = gold ]; then
> @@ -51,7 +48,7 @@ else
>
>         if [ "$1" = LLD ]; then
>                 version=$2
> -               min_version=$lld_min_version
> +               min_version=$($min_tool_version llvm)
>                 name=LLD
>                 disp_name=LLD
>         else
> diff --git a/scripts/min-tool-version.sh b/scripts/min-tool-version.sh
> new file mode 100755
> index 000000000000..37c438d766d7
> --- /dev/null
> +++ b/scripts/min-tool-version.sh
> @@ -0,0 +1,27 @@
> +#!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0-only
> +#
> +# Print the minimum supported version of the given tool.
> +
> +set -e
> +
> +# When you raise the minimum version, please update
> +# Documentation/process/changes.rst as well.
> +min_gcc_version=4.9.0
> +min_llvm_version=10.0.1
> +min_icc_version=16.0.3 # temporary
> +min_binutils_version=2.23.0
> +
> +# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63293
> +# https://lore.kernel.org/r/20210107111841.GN1551@shell.armlinux.org.uk
> +if [ "$SRCARCH" = arm64 ]; then
> +       min_gcc_version=5.1.0
> +fi
> +
> +eval min_version="\$min_${1}_version"
> +if [ -z "$min_version" ]; then
> +       echo "$1: unknown tool" >&2
> +       exit 1
> +fi
> +
> +echo "$min_version"
> --
> 2.27.0
>
> --
> You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-linux+unsubscribe@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/20210311094624.923913-1-masahiroy%40kernel.org.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-03-12 11:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-11  9:46 [PATCH] kbuild: collect minimum tool versions into scripts/min-tool-version.sh Masahiro Yamada
2021-03-11 10:18 ` Miguel Ojeda
2021-03-11 10:33   ` Masahiro Yamada
2021-03-11 11:15     ` Miguel Ojeda
2021-03-12  1:19   ` Nicolas Pitre
2021-03-12 11:10 ` Sedat Dilek

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).