Skip to content

Commit

Permalink
binutils: Add 2.42 release
Browse files Browse the repository at this point in the history
Add the new release and rebase the local patches. Add a new patch which
resolves a build issue on macOS.

https://sourceware.org/pipermail/binutils/2024-January/132213.html

Signed-off-by: Chris Packham <judge.packham@gmail.com>
Signed-off-by: Bryan Hundven <bryanhundven@gmail.com>
  • Loading branch information
cpackham committed Mar 12, 2024
1 parent c64500d commit ecc5e41
Show file tree
Hide file tree
Showing 11 changed files with 663 additions and 0 deletions.
32 changes: 32 additions & 0 deletions packages/binutils/2.42/0000-sh-conf.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
From feb95096c21b037cf8fe3a6abc54e88853f29f64 Mon Sep 17 00:00:00 2001
From: Chris Packham <judge.packham@gmail.com>
Date: Mon, 8 Aug 2022 20:31:10 +1200
Subject: [PATCH] sh conf

---
configure | 2 +-
configure.ac | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

--- a/configure
+++ b/configure
@@ -4042,7 +4042,7 @@
nvptx*-*-*)
noconfigdirs="$noconfigdirs target-libssp target-libstdc++-v3 target-libobjc"
;;
- sh-*-*)
+ sh*-*-*)
case "${target}" in
sh*-*-elf)
;;
--- a/configure.ac
+++ b/configure.ac
@@ -1269,7 +1269,7 @@
nvptx*-*-*)
noconfigdirs="$noconfigdirs target-libssp target-libstdc++-v3 target-libobjc"
;;
- sh-*-*)
+ sh*-*-*)
case "${target}" in
sh*-*-elf)
;;
29 changes: 29 additions & 0 deletions packages/binutils/2.42/0001-check_ldrunpath_length.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
From db50df5d5a92328f2804e4e466e8e5f6e42ea1a4 Mon Sep 17 00:00:00 2001
From: Chris Packham <judge.packham@gmail.com>
Date: Mon, 8 Aug 2022 20:36:31 +1200
Subject: [PATCH] check_ldrunpath_length

---
ld/ldelf.c | 4 ++++
1 file changed, 4 insertions(+)

--- a/ld/ldelf.c
+++ b/ld/ldelf.c
@@ -1130,6 +1130,8 @@
&& command_line.rpath == NULL)
{
path = (const char *) getenv ("LD_RUN_PATH");
+ if (path && *path == '\0')
+ path = NULL;
if (path
&& ldelf_search_needed (path, &n, force,
is_linux, elfsize))
@@ -1805,6 +1807,8 @@
rpath = command_line.rpath;
if (rpath == NULL)
rpath = (const char *) getenv ("LD_RUN_PATH");
+ if (rpath && *rpath == '\0')
+ rpath = NULL;

for (abfd = link_info.input_bfds; abfd; abfd = abfd->link.next)
if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
From ea2133b62542ca5c66027e9703ce1f90822e7e43 Mon Sep 17 00:00:00 2001
From: Chris Packham <judge.packham@gmail.com>
Date: Mon, 8 Aug 2022 20:37:03 +1200
Subject: [PATCH] MinGW w64 winpthreads doesn't have
pthread_mutexattr_settype

---
gold/gold-threads.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

--- a/gold/gold-threads.cc
+++ b/gold/gold-threads.cc
@@ -101,7 +101,7 @@
int err = pthread_mutexattr_init(&attr);
if (err != 0)
gold_fatal(_("pthead_mutexattr_init failed: %s"), strerror(err));
-#ifdef PTHREAD_MUTEX_ADAPTIVE_NP
+#if defined(PTHREAD_MUTEX_ADAPTIVE_NP) && !defined(_WIN32)
err = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ADAPTIVE_NP);
if (err != 0)
gold_fatal(_("pthread_mutexattr_settype failed: %s"), strerror(err));
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
From d82ca73b6cdac3168494e8e288463b1f5d54d1bc Mon Sep 17 00:00:00 2001
From: Chris Packham <judge.packham@gmail.com>
Date: Mon, 8 Aug 2022 20:37:24 +1200
Subject: [PATCH] Don't link to libfl as it's unnecessary

---
binutils/configure | 3 +++
binutils/configure.ac | 3 +++
gas/configure | 3 +++
gas/configure.ac | 3 +++
ld/configure | 3 +++
ld/configure.ac | 3 +++
6 files changed, 18 insertions(+)

--- a/binutils/configure
+++ b/binutils/configure
@@ -12306,6 +12306,7 @@
done
test -n "$YACC" || YACC="yacc"

+save_LIBS=$LIBS
for ac_prog in flex lex
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
@@ -12469,6 +12470,8 @@
if test "$LEX" = :; then
LEX=${am_missing_run}flex
fi
+LIBS=$save_LIBS
+LEXLIB=

ALL_LINGUAS="bg ca da es fi fr hr id it ja pt ro ru rw sk sr sv tr uk vi zh_CN zh_TW"

--- a/binutils/configure.ac
+++ b/binutils/configure.ac
@@ -152,7 +152,10 @@
fi

AC_PROG_YACC
+save_LIBS=$LIBS
AM_PROG_LEX
+LIBS=$save_LIBS
+LEXLIB=

ALL_LINGUAS="bg ca da es fi fr hr id it ja pt ro ru rw sk sr sv tr uk vi zh_CN zh_TW"
ZW_GNU_GETTEXT_SISTER_DIR
--- a/gas/configure
+++ b/gas/configure
@@ -13054,6 +13054,7 @@
done
test -n "$YACC" || YACC="yacc"

+save_LIBS=$LIBS
for ac_prog in flex lex
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
@@ -13217,6 +13218,8 @@
if test "$LEX" = :; then
LEX=${am_missing_run}flex
fi
+LIBS=$save_LIBS
+LEXLIB=

ALL_LINGUAS="es fi fr id ja ru rw sv tr uk zh_CN"

--- a/gas/configure.ac
+++ b/gas/configure.ac
@@ -959,7 +959,10 @@
AC_DEFINE_UNQUOTED(TARGET_OS, "${target_os}", [Target OS.])

AC_PROG_YACC
+save_LIBS=$LIBS
AM_PROG_LEX
+LIBS=$save_LIBS
+LEXLIB=

ALL_LINGUAS="es fi fr id ja ru rw sv tr uk zh_CN"
ZW_GNU_GETTEXT_SISTER_DIR
--- a/ld/configure
+++ b/ld/configure
@@ -18474,6 +18474,7 @@
done
test -n "$YACC" || YACC="yacc"

+save_LIBS=$LIBS
for ac_prog in flex lex
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
@@ -18637,6 +18638,8 @@
if test "$LEX" = :; then
LEX=${am_missing_run}flex
fi
+LIBS=$save_LIBS
+LEXLIB=


{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5
--- a/ld/configure.ac
+++ b/ld/configure.ac
@@ -375,7 +375,10 @@
AC_EXEEXT

AC_PROG_YACC
+save_LIBS=$LIBS
AM_PROG_LEX
+LIBS=$save_LIBS
+LEXLIB=

AM_MAINTAINER_MODE
AM_CONDITIONAL(GENINSRC_NEVER, false)
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
From bfe2ccf8b3bc264068d03d333f2d4222ebb62f1a Mon Sep 17 00:00:00 2001
From: Chris Packham <judge.packham@gmail.com>
Date: Mon, 8 Aug 2022 20:37:47 +1200
Subject: [PATCH] Darwin gold binary cc include string not cstring

---
gold/binary.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

--- a/gold/binary.cc
+++ b/gold/binary.cc
@@ -23,7 +23,7 @@
#include "gold.h"

#include <cerrno>
-#include <cstring>
+#include <string>

#include "elfcpp.h"
#include "stringpool.h"
70 changes: 70 additions & 0 deletions packages/binutils/2.42/0005-Fix-darwin-build.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
From c0e2c435788e702e35c1e00b66cbb99c157e51a4 Mon Sep 17 00:00:00 2001
From: Andrew Hsieh <andrewhsieh@google.com>
Date: Wed, 18 Mar 2015 10:57:24 +0800
Subject: [PATCH] Fix darwin build

1. In Drawin PTHREAD_ONCE_INIT is {0x30B1BCBA, {0}} and the GCC < 4.4
doesn't support ended initializer list
2. wcsncasecmp doesn't exist in MacSDK10.6.x

Change-Id: I69204a72f853f5263dffedc448379d75ed4eca2e
---
bfd/peXXigen.c | 22 ++++++++++++++++++++++
gold/gold-threads.cc | 15 ++++++++++++---
2 files changed, 34 insertions(+), 3 deletions(-)

--- a/bfd/peXXigen.c
+++ b/bfd/peXXigen.c
@@ -3665,6 +3665,28 @@
}
#endif /* not Cygwin/Mingw */

+#if defined __APPLE__ && __DARWIN_C_LEVEL < 200809L
+/* wcsncasecmp isn't always defined in Mac SDK */
+static int
+wcsncasecmp(const wchar_t *s1, const wchar_t *s2, size_t n)
+{
+ wchar_t c1, c2;
+
+ if (n == 0)
+ return (0);
+ for (; *s1; s1++, s2++)
+ {
+ c1 = towlower(*s1);
+ c2 = towlower(*s2);
+ if (c1 != c2)
+ return ((int)c1 - c2);
+ if (--n == 0)
+ return (0);
+ }
+ return (-*s2);
+}
+#endif
+
/* Perform a comparison of two entries. */
static signed int
rsrc_cmp (bool is_name, rsrc_entry * a, rsrc_entry * b)
--- a/gold/gold-threads.cc
+++ b/gold/gold-threads.cc
@@ -284,9 +284,18 @@
class Once_initialize
{
public:
- Once_initialize()
- : once_(PTHREAD_ONCE_INIT)
- { }
+ Once_initialize()
+#if !defined(__APPLE__)
+ : once_(PTHREAD_ONCE_INIT)
+ { }
+#else
+// In Drawin PTHREAD_ONCE_INIT is {0x30B1BCBA, {0}} and the GCC < 4.4 doesn't support
+// extended initializer list as above */
+ {
+ pthread_once_t once_2 = PTHREAD_ONCE_INIT;
+ once_ = once_2;
+ }
+#endif

// Return a pointer to the pthread_once_t variable.
pthread_once_t*
45 changes: 45 additions & 0 deletions packages/binutils/2.42/0006-sysroot.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
From 3f902fa5e378510db27583dd6900fd5326d35f9e Mon Sep 17 00:00:00 2001
From: Sven Rebhan <odinshorse@googlemail.com>
Date: Mon, 8 Aug 2022 20:46:29 +1200
Subject: [PATCH] sysroot

Always try to prepend the sysroot prefix to absolute filenames first.

http://bugs.gentoo.org/275666
http://sourceware.org/bugzilla/show_bug.cgi?id=10340

Signed-off-by: Sven Rebhan <odinshorse@googlemail.com>
---
ld/ldfile.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

--- a/ld/ldfile.c
+++ b/ld/ldfile.c
@@ -554,18 +554,25 @@
directory first. */
if (!entry->flags.maybe_archive)
{
- if (entry->flags.sysrooted && IS_ABSOLUTE_PATH (entry->filename))
+ /* For absolute pathnames, try to always open the file in the
+ sysroot first. If this fails, try to open the file at the
+ given location. */
+ entry->flags.sysrooted = is_sysrooted_pathname (entry->filename);
+ if (!entry->flags.sysrooted && IS_ABSOLUTE_PATH (entry->filename)
+ && ld_sysroot)
{
char *name = concat (ld_sysroot, entry->filename,
(const char *) NULL);
if (ldfile_try_open_bfd (name, entry))
{
entry->filename = name;
+ entry->flags.sysrooted = true;
return true;
}
free (name);
}
- else if (ldfile_try_open_bfd (entry->filename, entry))
+
+ if (ldfile_try_open_bfd (entry->filename, entry))
return true;

if (IS_ABSOLUTE_PATH (entry->filename))
Loading

0 comments on commit ecc5e41

Please sign in to comment.