[openwrt/openwrt] tools/elfutils: replace dependency hack with upstream include path fix

LEDE Commits lede-commits at lists.infradead.org
Sat Jul 26 05:38:49 PDT 2025


robimarko pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/8f920d2f94b0878e9b4291ffa18cfc9e02828f77

commit 8f920d2f94b0878e9b4291ffa18cfc9e02828f77
Author: Michael Pratt <mcpratt at pm.me>
AuthorDate: Sun Oct 20 07:49:50 2024 -0400

    tools/elfutils: replace dependency hack with upstream include path fix
    
    In order to solve the problem of the possibility that
    the "stack" binary is incorrectly included as a header
    while the compiler looks for the standard C++ header "stack",
    a workaround forcing a dependency between building "stack"
    and the C++ program was introduced.
    
    This upstream fix uses the compiler "-iquote" option
    in order to avoid looking for standard headers
    in the current working directory
    and blocks the default inclusion of "-I ."
    to the compiler flags.
    
    The upstream fix happens to be incomplete,
    so add an extra patch to fix an additional instance
    and then remove the workaround.
    
    Also, adjust the way DEFAULT_INCLUDES is overridden
    in the build Makefile by using the "-iquote" option
    in the same manner in order to remove all instances
    of the default inclusion for the current directory.
    
    Tested-by: Georgi Valkov <gvalkov at gmail.com> # macOS
    Signed-off-by: Michael Pratt <mcpratt at pm.me>
    Link: https://github.com/openwrt/openwrt/pull/16522
    Signed-off-by: Robert Marko <robimarko at gmail.com>
---
 tools/elfutils/Makefile                            |  2 +-
 .../patches/000-backport-iquote-include.patch      | 37 ++++++++++++++++++++++
 .../patches/001-fix-backport-iquote-include.patch  | 12 +++++++
 tools/elfutils/patches/100-portability.patch       | 10 ------
 4 files changed, 50 insertions(+), 11 deletions(-)

diff --git a/tools/elfutils/Makefile b/tools/elfutils/Makefile
index ae829cd340..6aa23bfbc5 100644
--- a/tools/elfutils/Makefile
+++ b/tools/elfutils/Makefile
@@ -55,7 +55,7 @@ export $(PKG_GNULIB_BASE)_fallocate-posix=$(HOST_BUILD_DIR)/$(PKG_GNULIB_BASE)/$
 export $(PKG_GNULIB_BASE)_tsearch=$(HOST_BUILD_DIR)/$(PKG_GNULIB_BASE)/$(PKG_GNULIB_BASE)_la-tsearch.o
 
 HOST_MAKE_FLAGS += \
-	DEFAULT_INCLUDES='-I. -I$$$$(top_builddir) -I$$$$(top_srcdir)/$(PKG_GNULIB_BASE)' \
+	DEFAULT_INCLUDES='-iquote . -I$$$$(top_builddir) -I$$$$(top_srcdir)/$(PKG_GNULIB_BASE)' \
 	AM_LDFLAGS='$$$$(STACK_USAGE_NO_ERROR)' \
 	LIBS+='$$$$(if $$$$(findstring $(lastword $(PKG_SUBDIRS)),$$$$(subdir)), $$$$($(PKG_GNULIB_BASE)))' \
 	LIBS+='$$$$(wildcard $$$$($(PKG_GNULIB_BASE)_fallocate-posix))' \
diff --git a/tools/elfutils/patches/000-backport-iquote-include.patch b/tools/elfutils/patches/000-backport-iquote-include.patch
new file mode 100644
index 0000000000..2c7657fc8c
--- /dev/null
+++ b/tools/elfutils/patches/000-backport-iquote-include.patch
@@ -0,0 +1,37 @@
+From b426c4db31e7c80d4262abdd845d2ece0c9a841c Mon Sep 17 00:00:00 2001
+From: Alfred Wingate <parona at protonmail.com>
+Date: Wed, 14 Aug 2024 12:14:38 -0400
+Subject: [PATCH] Avoid overriding libcxx system header
+
+Replace -I with -iquote to avoid overriding stack system header from libcxx-18
+with the previously built stack binary. Override DEFAULT_INLCUDES because m4
+adds -I. by default.
+
+Signed-off-by: Aaron Merey <amerey at redhat.com>
+---
+ config/eu.am    | 2 +-
+ src/Makefile.am | 2 ++
+ 2 files changed, 3 insertions(+), 1 deletion(-)
+
+--- a/config/eu.am
++++ b/config/eu.am
+@@ -31,7 +31,7 @@
+ ##
+ 
+ DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H -DLOCALEDIR='"${localedir}"'
+-AM_CPPFLAGS = -I. -I$(srcdir) -I$(top_srcdir)/lib -I..
++AM_CPPFLAGS = -iquote . -I$(srcdir) -I$(top_srcdir)/lib -I..
+ 
+ # Drop the 'u' flag that automake adds by default. It is incompatible
+ # with deterministic archives.
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -19,6 +19,8 @@
+ include $(top_srcdir)/config/eu.am
+ DEFS += $(YYDEBUG) -DDEBUGPRED=@DEBUGPRED@ \
+ 	-DSRCDIR=\"$(shell cd $(srcdir);pwd)\" -DOBJDIR=\"$(shell pwd)\"
++
++DEFAULT_INCLUDES =
+ AM_CPPFLAGS += -I$(srcdir)/../libelf -I$(srcdir)/../libebl \
+ 	    -I$(srcdir)/../libdw -I$(srcdir)/../libdwelf \
+ 	    -I$(srcdir)/../libdwfl -I$(srcdir)/../libasm -I../debuginfod
diff --git a/tools/elfutils/patches/001-fix-backport-iquote-include.patch b/tools/elfutils/patches/001-fix-backport-iquote-include.patch
new file mode 100644
index 0000000000..62ed84dd27
--- /dev/null
+++ b/tools/elfutils/patches/001-fix-backport-iquote-include.patch
@@ -0,0 +1,12 @@
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -21,7 +21,8 @@ DEFS += $(YYDEBUG) -DDEBUGPRED=@DEBUGPRE
+ 	-DSRCDIR=\"$(shell cd $(srcdir);pwd)\" -DOBJDIR=\"$(shell pwd)\"
+ 
+ DEFAULT_INCLUDES =
+-AM_CPPFLAGS += -I$(srcdir)/../libelf -I$(srcdir)/../libebl \
++AM_CPPFLAGS = -iquote . -iquote $(srcdir) -I$(top_srcdir)/lib \
++	    -I$(srcdir)/../libelf -I$(srcdir)/../libebl \
+ 	    -I$(srcdir)/../libdw -I$(srcdir)/../libdwelf \
+ 	    -I$(srcdir)/../libdwfl -I$(srcdir)/../libasm -I../debuginfod
+ 
diff --git a/tools/elfutils/patches/100-portability.patch b/tools/elfutils/patches/100-portability.patch
index 2cc8a4c56e..be97f95faa 100644
--- a/tools/elfutils/patches/100-portability.patch
+++ b/tools/elfutils/patches/100-portability.patch
@@ -288,13 +288,3 @@
  
  /* Definitions of arguments for argp functions.  */
  static const struct argp_option options[] =
---- a/src/Makefile.am
-+++ b/src/Makefile.am
-@@ -92,6 +92,7 @@ strings_LDADD = $(libelf) $(libeu) $(arg
- ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(obstack_LIBS)
- unstrip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
- stack_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) $(demanglelib)
-+EXTRA_stack_DEPENDENCIES = $(if $(findstring srcfiles,$(bin_PROGRAMS)),$(srcfiles_OBJECTS))
- elfcompress_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
- elfclassify_LDADD = $(libelf) $(libdw) $(libeu) $(argp_LDADD)
- srcfiles_SOURCES = srcfiles.cxx




More information about the lede-commits mailing list