commit: c1514cd74c4735404fd2788fed5061e3802a7d14
parent db57e3849760fe7a9de6db220a11a4669db7edb1
Author: Michael Forney <mforney@mforney.org>
Date: Fri, 21 Feb 2020 12:53:37 -0800
binutils: Fix some portability issues
Diffstat:
6 files changed, 344 insertions(+), 1 deletion(-)
diff --git a/pkg/binutils/libiberty/config.h b/pkg/binutils/libiberty/config.h
@@ -58,6 +58,7 @@
#define HAVE_MMAP 1
/* #undef HAVE_ON_EXIT */
#define HAVE_PIPE2 1
+#define HAVE_POSIX_SPAWN 1
/* #undef HAVE_PROCESS_H */
#define HAVE_PSIGNAL 1
/* #undef HAVE_PSTAT_GETDYNAMIC */
@@ -75,6 +76,7 @@
#define HAVE_SNPRINTF 1
/* #undef HAVE_SPAWNVE */
/* #undef HAVE_SPAWNVPE */
+#define HAVE_SPAWN_H 1
#define HAVE_STDINT_H 1
#define HAVE_STDIO_EXT_H 1
#define HAVE_STDLIB_H 1
diff --git a/pkg/binutils/patch/0001-libiberty-Implement-pex_unix_exec_child-using-posix_.patch b/pkg/binutils/patch/0001-libiberty-Implement-pex_unix_exec_child-using-posix_.patch
@@ -0,0 +1,222 @@
+From b8be1a9aa4a1235d5ec969690d1d6ff93d08eaa2 Mon Sep 17 00:00:00 2001
+From: Michael Forney <mforney@mforney.org>
+Date: Wed, 17 Apr 2019 16:44:05 -0700
+Subject: [PATCH] libiberty: Implement pex_unix_exec_child using posix_spawn
+
+---
+ libiberty/config.in | 6 +++
+ libiberty/configure | 10 ++---
+ libiberty/configure.ac | 10 ++---
+ libiberty/pex-unix.c | 95 +++++++++++++++++++++++++++++++++++++++++-
+ 4 files changed, 110 insertions(+), 11 deletions(-)
+
+diff --git a/libiberty/config.in b/libiberty/config.in
+index f7052b5d95..ce79a9e77f 100644
+--- a/libiberty/config.in
++++ b/libiberty/config.in
+@@ -198,6 +198,9 @@
+ /* Define to 1 if you have the `pipe2' function. */
+ #undef HAVE_PIPE2
+
++/* Define to 1 if you have the `posix_spawn' function. */
++#undef HAVE_POSIX_SPAWN
++
+ /* Define to 1 if you have the <process.h> header file. */
+ #undef HAVE_PROCESS_H
+
+@@ -249,6 +252,9 @@
+ /* Define to 1 if you have the `spawnvpe' function. */
+ #undef HAVE_SPAWNVPE
+
++/* Define to 1 if you have the <spawn.h> header file. */
++#undef HAVE_SPAWN_H
++
+ /* Define to 1 if you have the <stdint.h> header file. */
+ #undef HAVE_STDINT_H
+
+diff --git a/libiberty/configure b/libiberty/configure
+index 7a34dabec3..ecac4db0fb 100755
+--- a/libiberty/configure
++++ b/libiberty/configure
+@@ -5288,7 +5288,7 @@ host_makefile_frag=${frag}
+ # It's OK to check for header files. Although the compiler may not be
+ # able to link anything, it had better be able to at least compile
+ # something.
+-for ac_header in sys/file.h sys/param.h limits.h stdlib.h malloc.h string.h unistd.h strings.h sys/time.h time.h sys/resource.h sys/stat.h sys/mman.h fcntl.h alloca.h sys/pstat.h sys/sysmp.h sys/sysinfo.h machine/hal_sysinfo.h sys/table.h sys/sysctl.h sys/systemcfg.h stdint.h stdio_ext.h process.h sys/prctl.h
++for ac_header in sys/file.h sys/param.h limits.h stdlib.h malloc.h string.h unistd.h strings.h sys/time.h time.h sys/resource.h sys/stat.h sys/mman.h fcntl.h alloca.h sys/pstat.h sys/sysmp.h sys/sysinfo.h machine/hal_sysinfo.h sys/table.h sys/sysctl.h sys/systemcfg.h stdint.h stdio_ext.h process.h sys/prctl.h spawn.h
+ do :
+ as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ ac_fn_c_check_header_preproc "$LINENO" "$ac_header" "$as_ac_Header"
+@@ -5797,9 +5797,9 @@ funcs="$funcs setproctitle"
+ vars="sys_errlist sys_nerr sys_siglist"
+
+ checkfuncs="__fsetlocking canonicalize_file_name dup3 getrlimit getrusage \
+- getsysinfo gettimeofday on_exit pipe2 psignal pstat_getdynamic pstat_getstatic \
+- realpath setrlimit sbrk spawnve spawnvpe strerror strsignal sysconf sysctl \
+- sysmp table times wait3 wait4"
++ getsysinfo gettimeofday on_exit pipe2 posix_spawn psignal pstat_getdynamic \
++ pstat_getstatic realpath setrlimit sbrk spawnve spawnvpe strerror strsignal \
++ sysconf sysctl sysmp table times wait3 wait4"
+
+ # These are neither executed nor required, but they help keep
+ # autoheader happy without adding a bunch of text to acconfig.h.
+@@ -5813,7 +5813,7 @@ if test "x" = "y"; then
+ index insque \
+ memchr memcmp memcpy memmem memmove memset mkstemps \
+ on_exit \
+- pipe2 psignal pstat_getdynamic pstat_getstatic putenv \
++ pipe2 posix_spawn psignal pstat_getdynamic pstat_getstatic putenv \
+ random realpath rename rindex \
+ sbrk setenv setproctitle setrlimit sigsetmask snprintf spawnve spawnvpe \
+ stpcpy stpncpy strcasecmp strchr strdup \
+diff --git a/libiberty/configure.ac b/libiberty/configure.ac
+index f1ce76010c..9220ae2837 100644
+--- a/libiberty/configure.ac
++++ b/libiberty/configure.ac
+@@ -267,7 +267,7 @@ AC_SUBST_FILE(host_makefile_frag)
+ # It's OK to check for header files. Although the compiler may not be
+ # able to link anything, it had better be able to at least compile
+ # something.
+-AC_CHECK_HEADERS(sys/file.h sys/param.h limits.h stdlib.h malloc.h string.h unistd.h strings.h sys/time.h time.h sys/resource.h sys/stat.h sys/mman.h fcntl.h alloca.h sys/pstat.h sys/sysmp.h sys/sysinfo.h machine/hal_sysinfo.h sys/table.h sys/sysctl.h sys/systemcfg.h stdint.h stdio_ext.h process.h sys/prctl.h)
++AC_CHECK_HEADERS(sys/file.h sys/param.h limits.h stdlib.h malloc.h string.h unistd.h strings.h sys/time.h time.h sys/resource.h sys/stat.h sys/mman.h fcntl.h alloca.h sys/pstat.h sys/sysmp.h sys/sysinfo.h machine/hal_sysinfo.h sys/table.h sys/sysctl.h sys/systemcfg.h stdint.h stdio_ext.h process.h sys/prctl.h spawn.h)
+ AC_HEADER_SYS_WAIT
+ AC_HEADER_TIME
+
+@@ -390,9 +390,9 @@ funcs="$funcs setproctitle"
+ vars="sys_errlist sys_nerr sys_siglist"
+
+ checkfuncs="__fsetlocking canonicalize_file_name dup3 getrlimit getrusage \
+- getsysinfo gettimeofday on_exit pipe2 psignal pstat_getdynamic pstat_getstatic \
+- realpath setrlimit sbrk spawnve spawnvpe strerror strsignal sysconf sysctl \
+- sysmp table times wait3 wait4"
++ getsysinfo gettimeofday on_exit pipe2 posix_spawn psignal pstat_getdynamic \
++ pstat_getstatic realpath setrlimit sbrk spawnve spawnvpe strerror strsignal \
++ sysconf sysctl sysmp table times wait3 wait4"
+
+ # These are neither executed nor required, but they help keep
+ # autoheader happy without adding a bunch of text to acconfig.h.
+@@ -406,7 +406,7 @@ if test "x" = "y"; then
+ index insque \
+ memchr memcmp memcpy memmem memmove memset mkstemps \
+ on_exit \
+- pipe2 psignal pstat_getdynamic pstat_getstatic putenv \
++ pipe2 posix_spawn psignal pstat_getdynamic pstat_getstatic putenv \
+ random realpath rename rindex \
+ sbrk setenv setproctitle setrlimit sigsetmask snprintf spawnve spawnvpe \
+ stpcpy stpncpy strcasecmp strchr strdup \
+diff --git a/libiberty/pex-unix.c b/libiberty/pex-unix.c
+index 684a49ace6..25823cedd6 100644
+--- a/libiberty/pex-unix.c
++++ b/libiberty/pex-unix.c
+@@ -58,6 +58,9 @@ extern int errno;
+ #ifdef HAVE_PROCESS_H
+ #include <process.h>
+ #endif
++#ifdef HAVE_SPAWN_H
++#include <spawn.h>
++#endif
+
+ #ifdef vfork /* Autoconf may define this to fork for us. */
+ # define VFORK_STRING "fork"
+@@ -366,7 +369,97 @@ pex_unix_close (struct pex_obj *obj ATTRIBUTE_UNUSED, int fd)
+
+ /* Execute a child. */
+
+-#if defined(HAVE_SPAWNVE) && defined(HAVE_SPAWNVPE)
++#if defined(HAVE_POSIX_SPAWN)
++/* Implementation of pex->exec_child using the posix_spawn operation. */
++
++static pid_t
++pex_unix_exec_child (struct pex_obj *obj, int flags, const char *executable,
++ char * const * argv, char * const * env,
++ int in, int out, int errdes,
++ int toclose, const char **errmsg, int *err)
++{
++ posix_spawn_file_actions_t file_actions;
++ pid_t pid;
++ int ret;
++
++ *errmsg = "posix_spawn";
++ ret = posix_spawn_file_actions_init (&file_actions);
++ if (ret != 0)
++ goto error;
++ if (in != STDIN_FILE_NO)
++ {
++ ret = posix_spawn_file_actions_adddup2 (&file_actions, in, STDIN_FILE_NO);
++ if (ret != 0)
++ goto error;
++ ret = posix_spawn_file_actions_addclose (&file_actions, in);
++ if (ret != 0)
++ goto error;
++ }
++ if (out != STDOUT_FILE_NO)
++ {
++ ret = posix_spawn_file_actions_adddup2 (&file_actions, out, STDOUT_FILE_NO);
++ if (ret != 0)
++ goto error;
++ ret = posix_spawn_file_actions_addclose (&file_actions, out);
++ if (ret != 0)
++ goto error;
++ }
++ if ((flags & PEX_STDERR_TO_STDOUT) != 0)
++ {
++ ret = posix_spawn_file_actions_adddup2 (&file_actions, STDOUT_FILE_NO, STDERR_FILE_NO);
++ if (ret != 0)
++ goto error;
++ }
++ else if (errdes != STDERR_FILE_NO)
++ {
++ ret = posix_spawn_file_actions_adddup2 (&file_actions, errdes, STDERR_FILE_NO);
++ if (ret != 0)
++ goto error;
++ ret = posix_spawn_file_actions_addclose (&file_actions, errdes);
++ if (ret != 0)
++ goto error;
++ }
++ if (toclose >= 0)
++ {
++ ret = posix_spawn_file_actions_addclose (&file_actions, toclose);
++ if (ret != 0)
++ goto error;
++ }
++ if (env == NULL)
++ env = environ;
++ if ((flags & PEX_SEARCH) != 0)
++ ret = posix_spawnp (&pid, executable, &file_actions, NULL, argv, env);
++ else
++ ret = posix_spawn (&pid, executable, &file_actions, NULL, argv, env);
++ if (ret != 0)
++ goto error;
++ posix_spawn_file_actions_destroy(&file_actions);
++
++ *errmsg = "close";
++ if (in != STDIN_FILE_NO && close (in) < 0)
++ {
++ ret = errno;
++ goto error;
++ }
++ if (out != STDOUT_FILE_NO && close (out) < 0)
++ {
++ ret = errno;
++ goto error;
++ }
++ if (errdes != STDERR_FILE_NO && close (errdes) < 0)
++ {
++ ret = errno;
++ goto error;
++ }
++
++ return pid;
++
++ error:
++ *err = ret;
++ return (pid_t) -1;
++}
++
++#elif defined(HAVE_SPAWNVE) && defined(HAVE_SPAWNVPE)
+ /* Implementation of pex->exec_child using the Cygwin spawn operation. */
+
+ /* Subroutine of pex_unix_exec_child. Move OLD_FD to a new file descriptor
+--
+2.25.1
+
diff --git a/pkg/binutils/patch/0002-bfd-Don-t-use-long-double-if-not-available.patch b/pkg/binutils/patch/0002-bfd-Don-t-use-long-double-if-not-available.patch
@@ -0,0 +1,48 @@
+From 7ae72f3ab19b802de9cc290d2f8aa0cb8bead54b Mon Sep 17 00:00:00 2001
+From: Michael Forney <mforney@mforney.org>
+Date: Sun, 19 May 2019 13:48:45 -0700
+Subject: [PATCH] bfd: Don't use long double if not available
+
+---
+ bfd/bfd.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/bfd/bfd.c b/bfd/bfd.c
+index b1050626b6..b3d0b67fac 100644
+--- a/bfd/bfd.c
++++ b/bfd/bfd.c
+@@ -854,7 +854,9 @@ union _bfd_doprnt_args
+ long l;
+ long long ll;
+ double d;
++#if defined (__GNUC__) || defined (HAVE_LONG_DOUBLE)
+ long double ld;
++#endif
+ void *p;
+ enum
+ {
+@@ -863,7 +865,9 @@ union _bfd_doprnt_args
+ Long,
+ LongLong,
+ Double,
++#if defined (__GNUC__) || defined (HAVE_LONG_DOUBLE)
+ LongDouble,
++#endif
+ Ptr
+ } type;
+ };
+@@ -1339,9 +1343,11 @@ error_handler_internal (const char *fmt, va_list ap)
+ case Double:
+ args[i].d = va_arg (ap, double);
+ break;
++#if defined (__GNUC__) || defined (HAVE_LONG_DOUBLE)
+ case LongDouble:
+ args[i].ld = va_arg (ap, long double);
+ break;
++#endif
+ case Ptr:
+ args[i].p = va_arg (ap, void *);
+ break;
+--
+2.25.1
+
diff --git a/pkg/binutils/patch/0003-libctf-Provide-fallback-definitions-for-attribute-ma.patch b/pkg/binutils/patch/0003-libctf-Provide-fallback-definitions-for-attribute-ma.patch
@@ -0,0 +1,44 @@
+From 503a200be10dbed6f057eb0a69e2c176ffec3fa5 Mon Sep 17 00:00:00 2001
+From: Michael Forney <mforney@mforney.org>
+Date: Tue, 19 Nov 2019 19:20:02 -0800
+Subject: [PATCH] libctf: Provide fallback definitions for attribute macros
+
+---
+ libctf/ChangeLog | 5 +++++
+ libctf/ctf-impl.h | 7 +++++++
+ 2 files changed, 12 insertions(+)
+
+diff --git a/libctf/ChangeLog b/libctf/ChangeLog
+index 93462c7e45..b472cf4d64 100644
+--- a/libctf/ChangeLog
++++ b/libctf/ChangeLog
+@@ -1,3 +1,8 @@
++2019-11-19 Michael Forney <mforney@mforney.org>
++
++ * ctf-impl.h: Provide fallback for _libctf_printflike_,
++ _libctf_unlikely_, _libctf_unused_, and _libctf_malloc_ macros.
++
+ 2020-02-01 Nick Clifton <nickc@redhat.com>
+
+ Binutils 2.34 release.
+diff --git a/libctf/ctf-impl.h b/libctf/ctf-impl.h
+index 267801d12d..dd9a4f1c7c 100644
+--- a/libctf/ctf-impl.h
++++ b/libctf/ctf-impl.h
+@@ -59,6 +59,13 @@ extern "C"
+ #define _libctf_unused_ __attribute__ ((__unused__))
+ #define _libctf_malloc_ __attribute__((__malloc__))
+
++#else
++
++#define _libctf_printflike_(string_index,first_to_check)
++#define _libctf_unlikely_(x) (x)
++#define _libctf_unused_
++#define _libctf_malloc_
++
+ #endif
+
+ /* libctf in-memory state. */
+--
+2.25.1
+
diff --git a/pkg/binutils/patch/0004-libctf-Remove-usage-of-__thread.patch b/pkg/binutils/patch/0004-libctf-Remove-usage-of-__thread.patch
@@ -0,0 +1,27 @@
+From b1d62f15c5a4b89df12aca33a58fe9405bf53a67 Mon Sep 17 00:00:00 2001
+From: Michael Forney <mforney@mforney.org>
+Date: Tue, 19 Nov 2019 19:33:01 -0800
+Subject: [PATCH] libctf: Remove usage of __thread
+
+We only use libctf for building single-threaded binutils, so __thread
+is not necessary.
+---
+ libctf/ctf-archive.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/libctf/ctf-archive.c b/libctf/ctf-archive.c
+index 73d772ffc3..4896aa721b 100644
+--- a/libctf/ctf-archive.c
++++ b/libctf/ctf-archive.c
+@@ -45,7 +45,7 @@ static int arc_mmap_writeout (int fd, void *header, size_t headersz,
+ static int arc_mmap_unmap (void *header, size_t headersz, const char **errmsg);
+
+ /* bsearch() internal state. */
+-static __thread char *search_nametbl;
++static char *search_nametbl;
+
+ /* Write out a CTF archive to the start of the file referenced by the passed-in
+ fd. The entries in CTF_FILES are referenced by name: the names are passed in
+--
+2.25.1
+
diff --git a/pkg/binutils/ver b/pkg/binutils/ver
@@ -1 +1 @@
-2.34 r0
+2.34 r1