public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "James Le Cuirot" <chewi@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-devel/binutils/, sys-devel/binutils/files/
Date: Mon,  5 Aug 2024 22:21:25 +0000 (UTC)	[thread overview]
Message-ID: <1722896423.5f9b32f028a31e544134077f5a3b6bd3d8c4230c.chewi@gentoo> (raw)

commit:     5f9b32f028a31e544134077f5a3b6bd3d8c4230c
Author:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
AuthorDate: Mon Aug  5 22:20:23 2024 +0000
Commit:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
CommitDate: Mon Aug  5 22:20:23 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5f9b32f0

sys-devel/binutils: Rebase cross/prefix linker patches for 2.43

Closes: https://bugs.gentoo.org/937381
Signed-off-by: James Le Cuirot <chewi <AT> gentoo.org>

 sys-devel/binutils/binutils-2.43.ebuild            |  4 +-
 sys-devel/binutils/binutils-9999.ebuild            |  4 +-
 .../files/binutils-2.43-linker-prefix.patch        | 53 ++++++++++++++++++++++
 .../files/binutils-2.43-linker-search-path.patch   | 43 ++++++++++++++++++
 4 files changed, 100 insertions(+), 4 deletions(-)

diff --git a/sys-devel/binutils/binutils-2.43.ebuild b/sys-devel/binutils/binutils-2.43.ebuild
index a3e7c641ce6b..9407ec3c37ef 100644
--- a/sys-devel/binutils/binutils-2.43.ebuild
+++ b/sys-devel/binutils/binutils-2.43.ebuild
@@ -131,8 +131,8 @@ src_prepare() {
 			# This is applied conditionally for now just out of caution.
 			# It should be okay on non-prefix systems though. See bug #892549.
 			if is_cross || use prefix; then
-				eapply "${FILESDIR}"/binutils-2.40-linker-search-path.patch \
-					   "${FILESDIR}"/binutils-2.41-linker-prefix.patch
+				eapply "${FILESDIR}"/binutils-2.43-linker-search-path.patch \
+					   "${FILESDIR}"/binutils-2.43-linker-prefix.patch
 			fi
 		fi
 	fi

diff --git a/sys-devel/binutils/binutils-9999.ebuild b/sys-devel/binutils/binutils-9999.ebuild
index c05f1529d8c1..44bb4c8c3e76 100644
--- a/sys-devel/binutils/binutils-9999.ebuild
+++ b/sys-devel/binutils/binutils-9999.ebuild
@@ -131,8 +131,8 @@ src_prepare() {
 			# This is applied conditionally for now just out of caution.
 			# It should be okay on non-prefix systems though. See bug #892549.
 			if is_cross || use prefix; then
-				eapply "${FILESDIR}"/binutils-2.40-linker-search-path.patch \
-					   "${FILESDIR}"/binutils-2.41-linker-prefix.patch
+				eapply "${FILESDIR}"/binutils-2.43-linker-search-path.patch \
+					   "${FILESDIR}"/binutils-2.43-linker-prefix.patch
 			fi
 		fi
 	fi

diff --git a/sys-devel/binutils/files/binutils-2.43-linker-prefix.patch b/sys-devel/binutils/files/binutils-2.43-linker-prefix.patch
new file mode 100644
index 000000000000..79b30657014b
--- /dev/null
+++ b/sys-devel/binutils/files/binutils-2.43-linker-prefix.patch
@@ -0,0 +1,53 @@
+https://bugs.gentoo.org/892549
+https://github.com/gentoo/binutils-gdb/pull/5
+
+From 302271b0baa52204fab58bd0b74e3919c0789f87 Mon Sep 17 00:00:00 2001
+From: James Le Cuirot <chewi@gentoo.org>
+Date: Sat, 23 Dec 2023 13:48:10 +0000
+Subject: [PATCH] ld: Allow a Gentoo-specific prefix to override the prefix
+ used by ld.bfd
+
+This prefix is only used to locate $prefix/etc/ld.so.conf, with $prefix
+usually being /usr. This file is important on Gentoo Prefix systems,
+where the /usr prefix is within another directory. The problem is that
+Gentoo already passes the same directory as the sysroot, and ld.bfd
+therefore looks for /myprefix/myprefix/usr/etc/ld.so.conf.
+
+The sysroot is dynamic, while the prefix is hardcoded. A hardcoded
+prefix that isn't just /usr is unhelpful, not just because of the
+doubled prefix issue above, but also because it prevents ld.bfd from
+working effectively outside its native environment. We will therefore
+hardcode it to just /usr.
+
+This change does not simply do that though and sets up a $gentoo_prefix
+variable instead, with $prefix as a fallback. This is necessary because
+Gentoo prefix-guest systems, which use the host's libc, do not apply a
+sysroot like RAP prefix systems do. In that case, we must preserve the
+existing behaviour. The binutils ebuild will be responsible for setting
+this variable appropriately.
+---
+ ld/emultempl/elf.em | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/ld/emultempl/elf.em b/ld/emultempl/elf.em
+index 863657e12f5..cf0204e9c76 100644
+--- a/ld/emultempl/elf.em
++++ b/ld/emultempl/elf.em
+@@ -142,7 +142,7 @@ gld${EMULATION_NAME}_before_plugin_all_symbols_read (void)
+   ldelf_before_plugin_all_symbols_read ($IS_LIBPATH, $IS_NATIVE,
+ 				        $IS_LINUX_TARGET,
+ 					$IS_FREEBSD_TARGET,
+-					$ELFSIZE, "$prefix");
++					$ELFSIZE, "${gentoo_prefix-${prefix}}");
+ }
+ 
+ /* This is called after all the input files have been opened.  */
+@@ -151,7 +151,7 @@ static void
+ gld${EMULATION_NAME}_after_open (void)
+ {
+   ldelf_after_open ($IS_LIBPATH, $IS_NATIVE,
+-		    $IS_LINUX_TARGET, $IS_FREEBSD_TARGET, $ELFSIZE, "$prefix");
++		    $IS_LINUX_TARGET, $IS_FREEBSD_TARGET, $ELFSIZE, "${gentoo_prefix-${prefix}}");
+ }
+ 
+ EOF

diff --git a/sys-devel/binutils/files/binutils-2.43-linker-search-path.patch b/sys-devel/binutils/files/binutils-2.43-linker-search-path.patch
new file mode 100644
index 000000000000..1dcb5e68702d
--- /dev/null
+++ b/sys-devel/binutils/files/binutils-2.43-linker-search-path.patch
@@ -0,0 +1,43 @@
+https://bugs.gentoo.org/892549
+https://github.com/gentoo/binutils-gdb/pull/5
+
+From 470487917306e169fc3ca983c2edf2370b211861 Mon Sep 17 00:00:00 2001
+From: James Le Cuirot <chewi@gentoo.org>
+Date: Sat, 11 Feb 2023 15:15:20 +0000
+Subject: [PATCH] ldelf.c: Always consider -L arguments when handling DT_NEEDED
+
+This is for consistency with other linkers, including gold. Without
+this, we typically rely on ld.so.conf to find libraries such as
+libstdc++.so.6, while other linkers do not use this file at all.
+---
+ ld/ldelf.c | 10 +++-------
+ 1 file changed, 3 insertions(+), 7 deletions(-)
+
+diff --git a/ld/ldelf.c b/ld/ldelf.c
+index 09691609fc0..11edff8c8ec 100644
+--- a/ld/ldelf.c
++++ b/ld/ldelf.c
+@@ -1093,8 +1093,8 @@ ldelf_handle_dt_needed (struct elf_link_hash_table *htab,
+ 	 linker will search.  That means that we want to use
+ 	 rpath_link, rpath, then the environment variable
+ 	 LD_LIBRARY_PATH (native only), then the DT_RPATH/DT_RUNPATH
+-	 entries (native only), then the linker script LIB_SEARCH_DIRS.
+-	 We do not search using the -L arguments.
++	 entries (native only), then the linker script LIB_SEARCH_DIRS,
++	 then the -L arguments.
+ 
+ 	 We search twice.  The first time, we skip objects which may
+ 	 introduce version mismatches.  The second time, we force
+@@ -1168,11 +1168,7 @@ ldelf_handle_dt_needed (struct elf_link_hash_table *htab,
+ 	  len = strlen (l->name);
+ 	  for (search = search_head; search != NULL; search = search->next)
+ 	    {
+-	      char *filename;
+-
+-	      if (search->source != search_dir_linker_script)
+-		continue;
+-	      filename = (char *) xmalloc (strlen (search->name) + len + 2);
++	      char *filename = (char *) xmalloc (strlen (search->name) + len + 2);
+ 	      sprintf (filename, "%s/%s", search->name, l->name);
+ 	      nn.name = filename;
+ 	      if (ldelf_try_needed (&nn, force, is_linux))


             reply	other threads:[~2024-08-05 22:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-05 22:21 James Le Cuirot [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-01-06 11:48 [gentoo-commits] repo/gentoo:master commit in: sys-devel/binutils/, sys-devel/binutils/files/ James Le Cuirot
2023-10-01 14:09 James Le Cuirot
2021-05-15 22:31 Georgy Yakovlev
2021-04-20  8:08 Sergei Trofimovich
2020-05-01 21:44 Sergei Trofimovich
2017-11-03 21:08 Andreas Hüttel

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=1722896423.5f9b32f028a31e544134077f5a3b6bd3d8c4230c.chewi@gentoo \
    --to=chewi@gentoo.org \
    --cc=gentoo-commits@lists.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