Don't attempt to call getrlimit or getrusage.
They are stubbed out in Fuchsia and generate distracting warnings
when they are invoked.
Change-Id: I1e18623beb48b9435ed266d591e9c20e463fbe81
diff --git a/patches/binutils-patch.txt b/patches/binutils-patch.txt
index 8394575..64fa5d9 100644
--- a/patches/binutils-patch.txt
+++ b/patches/binutils-patch.txt
@@ -93,6 +93,46 @@
}
// Print the SECTIONS clause to F for debugging.
+diff -rdcp --unidirectional-new-file binutils-2.27-fsf/bfd/cache.c binutils-2.27/bfd/cache.c
+*** binutils-2.27-fsf/bfd/cache.c 2017-02-21 15:59:58.416850264 -0800
+--- binutils-2.27/bfd/cache.c 2017-02-21 15:53:16.650326182 -0800
+*************** bfd_cache_max_open (void)
+*** 93,99 ****
+ this limitation. */
+ max = 16;
+ #else
+! #ifdef HAVE_GETRLIMIT
+ struct rlimit rlim;
+
+ if (getrlimit (RLIMIT_NOFILE, &rlim) == 0
+--- 93,100 ----
+ this limitation. */
+ max = 16;
+ #else
+! /* Fuchsia: Remove when getrlimit() has been implemented. */
+! #if !defined(__Fuchsia__) && defined(HAVE_GETRLIMIT)
+ struct rlimit rlim;
+
+ if (getrlimit (RLIMIT_NOFILE, &rlim) == 0
+*************** bfd_cache_max_open (void)
+*** 101,107 ****
+ max = rlim.rlim_cur / 8;
+ else
+ #endif
+! #ifdef _SC_OPEN_MAX
+ max = sysconf (_SC_OPEN_MAX) / 8;
+ #else
+ max = 10;
+--- 102,110 ----
+ max = rlim.rlim_cur / 8;
+ else
+ #endif
+! /* Fuchsia: Remove when sysconf(_SC_OPEN_MAX) has been implemented
+! (it currently relies on unimplemented getrlimit()). */
+! #if !defined(__Fuchsia__) && defined(_SC_OPEN_MAX)
+ max = sysconf (_SC_OPEN_MAX) / 8;
+ #else
+ max = 10;
diff -rdcp --unidirectional-new-file binutils-2.27-fsf/bfd/config.bfd binutils-2.27/bfd/config.bfd
*** binutils-2.27-fsf/bfd/config.bfd 2016-11-23 08:59:58.370833363 -0800
--- binutils-2.27/bfd/config.bfd 2016-11-16 08:49:21.135106894 -0800
@@ -486,6 +526,68 @@
earmelfb_linux.c: $(srcdir)/emulparams/armelfb_linux.sh \
$(srcdir)/emulparams/armelf_linux.sh \
$(ELF_DEPS) $(srcdir)/emultempl/armelf.em \
+diff -rdcp --unidirectional-new-file binutils-2.27-fsf/libiberty/getruntime.c binutils-2.27/libiberty/getruntime.c
+*** binutils-2.27-fsf/libiberty/getruntime.c 2017-02-21 14:59:51.026603203 -0800
+--- binutils-2.27/libiberty/getruntime.c 2017-02-21 14:53:58.899960741 -0800
+*************** process started.
+*** 96,102 ****
+ long
+ get_run_time (void)
+ {
+! #if defined (HAVE_GETRUSAGE) && defined (HAVE_SYS_RESOURCE_H)
+ struct rusage rusage;
+
+ getrusage (RUSAGE_SELF, &rusage);
+--- 96,104 ----
+ long
+ get_run_time (void)
+ {
+! /* Fuchsia: Remove when getrusage() has been implemented. */
+! #if !defined(__Fuchsia__) && \
+! defined (HAVE_GETRUSAGE) && defined (HAVE_SYS_RESOURCE_H)
+ struct rusage rusage;
+
+ getrusage (RUSAGE_SELF, &rusage);
+diff -rdcp --unidirectional-new-file binutils-2.27-fsf/libiberty/pex-unix.c binutils-2.27/libiberty/pex-unix.c
+*** binutils-2.27-fsf/libiberty/pex-unix.c 2017-02-21 14:59:51.082602987 -0800
+--- binutils-2.27/libiberty/pex-unix.c 2017-02-21 14:33:47.408601885 -0800
+*************** Boston, MA 02110-1301, USA. */
+*** 28,33 ****
+--- 28,39 ----
+ #include <stdio.h>
+ #include <signal.h>
+ #include <errno.h>
++
++ /* Fuchsia: remove when getrusage() has been implemented. */
++ #ifdef __Fuchsia__
++ #undef HAVE_GETRUSAGE
++ #endif
++
+ #ifdef NEED_DECLARATION_ERRNO
+ extern int errno;
+ #endif
+diff -rdcp --unidirectional-new-file binutils-2.27-fsf/libiberty/stack-limit.c binutils-2.27/libiberty/stack-limit.c
+*** binutils-2.27-fsf/libiberty/stack-limit.c 2017-02-21 14:59:51.046603126 -0800
+--- binutils-2.27/libiberty/stack-limit.c 2017-02-21 14:52:31.212300050 -0800
+*************** Attempt to increase stack size limit to
+*** 46,52 ****
+ void
+ stack_limit_increase (unsigned long pref ATTRIBUTE_UNUSED)
+ {
+! #if defined(HAVE_SETRLIMIT) && defined(HAVE_GETRLIMIT) \
+ && defined(RLIMIT_STACK) && defined(RLIM_INFINITY)
+ struct rlimit rlim;
+ if (getrlimit (RLIMIT_STACK, &rlim) == 0
+--- 46,54 ----
+ void
+ stack_limit_increase (unsigned long pref ATTRIBUTE_UNUSED)
+ {
+! /* Fuchsia: remove when getrlimit() has been implemented. */
+! #if !defined(__Fuchsia__) && \
+! defined(HAVE_SETRLIMIT) && defined(HAVE_GETRLIMIT) \
+ && defined(RLIMIT_STACK) && defined(RLIM_INFINITY)
+ struct rlimit rlim;
+ if (getrlimit (RLIMIT_STACK, &rlim) == 0
diff -rdcp --unidirectional-new-file binutils-2.27-fsf/Makefile.in binutils-2.27/Makefile.in
*** binutils-2.27-fsf/Makefile.in 2016-11-23 09:00:02.962814897 -0800
--- binutils-2.27/Makefile.in 2016-11-17 14:27:46.861334193 -0800