mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: "Bernhard Rosenkränzer" <bero@lindev.ch>
Cc: linux-kernel@vger.kernel.org,
	Masahiro Yamada <masahiroy@kernel.org>,
	linux-kbuild@vger.kernel.org, clang-built-linux@googlegroups.com,
	Nick Desaulniers <ndesaulniers@google.com>
Subject: Re: [PATCH] Fix ld-version.sh script if LLD was built with LLD_VENDOR
Date: Tue, 2 Mar 2021 21:02:37 -0700	[thread overview]
Message-ID: <20210303040237.tvwo34j322tzqnwz@archlinux-ax161> (raw)
In-Reply-To: <20210302221211.1620858-1-bero@lindev.ch>

Hi Bernhard,

I have added the ClangBuiltLinux mailing list, kbuild mailing list, and
Masahiro and Nick to CC. Maybe ld-version.sh and cc-version.sh should be
added to a MAINTAINERS entry to make sure we get CC'd (I can send one
along tomorrow).

On Tue, Mar 02, 2021 at 11:12:11PM +0100, Bernhard Rosenkränzer wrote:
> If LLD was built with -DLLD_VENDOR="xyz", ld.lld --version output
> will prefix LLD_VENDOR. Since LLD_VENDOR can contain spaces, the
> LLD identifier isn't guaranteed to be $2 either.

TIL about LLD_VENDOR...

> Adjust the version checker to handle such versions of lld.
> 
> Signed-off-by: Bernhard Rosenkränzer <bero@lindev.ch>
> ---
>  scripts/ld-version.sh | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/scripts/ld-version.sh b/scripts/ld-version.sh
> index a463273509b5..4c042a306e22 100755
> --- a/scripts/ld-version.sh
> +++ b/scripts/ld-version.sh
> @@ -49,6 +49,18 @@ elif [ "$1" = LLD ]; then
>  	min_version=$lld_min_version
>  	name=LLD
>  	disp_name=LLD
> +elif echo "$@" |grep -q ' LLD '; then
> +	# if LLD was built with -DLLD_VENDOR="xyz", it ld.lld --version
> +	# says "xyz LLD [...]". Since LLD_VENDOR may contain spaces, we
> +	# don't know the exact position of "LLD" and the version info
> +	# at this point
> +	while [ "$1" != "LLD" ]; do
> +		shift
> +	done
> +	version=$2
> +	min_version=$lld_min_version
> +	name=LLD
> +	disp_name=LLD
>  else
>  	echo "$orig_args: unknown linker" >&2
>  	exit 1
> -- 
> 2.30.1
> 

I am not sure what a better fix would be of the top of my head but
wouldn't it be better to avoid the duplication? This diff below works
for me with or without LLD_VENDOR defined.

diff --git a/scripts/ld-version.sh b/scripts/ld-version.sh
index a463273509b5..84f9fc741f09 100755
--- a/scripts/ld-version.sh
+++ b/scripts/ld-version.sh
@@ -44,7 +44,10 @@ if [ "$1" = GNU -a "$2" = ld ]; then
 elif [ "$1" = GNU -a "$2" = gold ]; then
 	echo "gold linker is not supported as it is not capable of linking the kernel proper." >&2
 	exit 1
-elif [ "$1" = LLD ]; then
+elif echo "$*" | grep -q LLD; then
+	while [ "$1" != "LLD" ]; do
+		shift
+	done
 	version=$2
 	min_version=$lld_min_version
 	name=LLD

  reply	other threads:[~2021-03-03 11:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-02 22:12 Bernhard Rosenkränzer
2021-03-03  4:02 ` Nathan Chancellor [this message]
2021-03-03 11:38   ` Masahiro Yamada
2021-03-03 17:45     ` Nathan Chancellor
2021-03-04  3:34 ` Masahiro Yamada
2021-03-09 17:09   ` Masahiro Yamada
2021-03-09 17:31     ` Nathan Chancellor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210303040237.tvwo34j322tzqnwz@archlinux-ax161 \
    --to=nathan@kernel.org \
    --cc=bero@lindev.ch \
    --cc=clang-built-linux@googlegroups.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=ndesaulniers@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®