public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: Mike Gilbert <floppym@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Subject: [gentoo-dev] [PATCH] toolchain-funcs.eclass: tc-ld-force-bfd: unset LD before calling tc-getLD
Date: Thu,  2 Nov 2023 11:34:46 -0400	[thread overview]
Message-ID: <20231102153446.13056-1-floppym@gentoo.org> (raw)

The previous logic would fail with common values of LD set by the user:

LD="ld.lld" -> LD="ld.lld.bfd"
LD="ld.gold" -> LD="ld.gold.bfd"
LD="mold" -> LD="mold.bfd"

It makes more sense to ignore the user's LD setting and use the default
value given by tc-getLD.

If the user doesn't have binutils installed, the "type -P" check will still
fail and LD will be unaltered.

Closes: https://github.com/gentoo/gentoo/pull/33650
Signed-off-by: Mike Gilbert <floppym@gentoo.org>
---
 eclass/toolchain-funcs.eclass | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
index 4559894ca04a..8fef764ad597 100644
--- a/eclass/toolchain-funcs.eclass
+++ b/eclass/toolchain-funcs.eclass
@@ -534,10 +534,9 @@ tc-ld-force-bfd() {
 	ewarn "Forcing usage of the BFD linker"
 
 	# Set up LD to point directly to bfd if it's available.
-	local ld=$(tc-getLD "$@")
-	# We need to extract the first word in case there are flags appended
-	# to its value (like multilib), bug #545218.
-	local bfd_ld="${ld%% *}.bfd"
+	# Unset LD first so we get the default value from tc-getLD.
+	local ld=$(unset LD; tc-getLD "$@")
+	local bfd_ld="${ld}.bfd"
 	local path_ld=$(type -P "${bfd_ld}" 2>/dev/null)
 	[[ -e ${path_ld} ]] && export LD=${bfd_ld}
 
-- 
2.42.0



                 reply	other threads:[~2023-11-02 15:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20231102153446.13056-1-floppym@gentoo.org \
    --to=floppym@gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /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