[openwrt/openwrt] tools/elfutils: use locally declared static reallocarray()

LEDE Commits lede-commits at lists.infradead.org
Thu Apr 25 14:10:36 PDT 2024


robimarko pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/20ed56ec8b80936132d3dd66e3a7b82dd1d2ed89

commit 20ed56ec8b80936132d3dd66e3a7b82dd1d2ed89
Author: Michael Pratt <mcpratt at pm.me>
AuthorDate: Sun Apr 7 23:28:51 2024 -0400

    tools/elfutils: use locally declared static reallocarray()
    
    On macOS, stdlib.h in the standard include paths does not provide
    reallocarray() while both elfutils and gnulib do, however they are
    declared differently, leading to an error:
    
      ./system.h:101:1: error: static declaration of 'reallocarray' follows non-static declaration
      reallocarray (void *ptr, size_t nmemb, size_t size)
    
    A normal "configure && make" build cycle results in both declarations
    being enabled as a result of both elfutils and gnulib having completely
    separate configure checks where gnulib uses an internal placeholder symbol
    HAVE_REALLOCARRAY, and elfutils uses a standard autoconf macro
    HAVE_DECL_REALLOCARRAY.
    
    Fix this by excluding the import of the reallocarray module which causes
    gnulib checks in the configure stage to not even consider whether to
    declare reallocarray later on, so the decision is only between the
    standard include stdlib.h and the elfutils header.
    
    Tested-by: Georgi Valkov <gvalkov at gmail.com> # MacOS
    Signed-off-by: Michael Pratt <mcpratt at pm.me>
    Signed-off-by: Tony Ambardar <itugrok at yahoo.com>
---
 tools/elfutils/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/elfutils/Makefile b/tools/elfutils/Makefile
index c7d94d2a47..140250801c 100644
--- a/tools/elfutils/Makefile
+++ b/tools/elfutils/Makefile
@@ -36,6 +36,7 @@ PKG_GNULIB_ARGS = \
 	--local-dir=$(STAGING_DIR_HOST)/share/gnulib \
 	--source-base=$(PKG_GNULIB_BASE) \
 	--libtool \
+	--avoid=reallocarray \
 	--import
 
 PKG_GNULIB_MODS = \




More information about the lede-commits mailing list