>From 11f000782c16f05f81a15d4dba75deb082ab97e1 Mon Sep 17 00:00:00 2001
From: Tristan Ross <tristan.ross@midstall.com>
Date: Tue, 30 Jul 2024 21:03:03 -0700
Subject: [PATCH] Prevent binaries in src from colliding with libc++ headers

Discovered with Nix and LLVM 17. Headers inside of libc++ can easily
collide with binaries being linked in src. This results in clang trying
to include a binary as a header.

Signed-off-by: Tristan Ross <tristan.ross@midstall.com>
---
 ChangeLog       | 5 +++++
 src/Makefile.am | 4 +++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 6aed95b6..5ba0680e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2024-07-30  Tristan Ross  <tristan.ross@midstall.com>
+
+	* src/Makefile.am: Prevent collision between headers and
+	binaries in libc++.
+
 2023-03-27  Di Chen  <dichen@redhat.com>
 
 	* NEWS: Support readelf -Ds for using dynamic segment to
diff --git a/src/Makefile.am b/src/Makefile.am
index 1d592d4d..8e182c4f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -19,7 +19,9 @@
 include $(top_srcdir)/config/eu.am
 DEFS += $(YYDEBUG) -DDEBUGPRED=@DEBUGPRED@ \
 	-DSRCDIR=\"$(shell cd $(srcdir);pwd)\" -DOBJDIR=\"$(shell pwd)\"
-AM_CPPFLAGS += -I$(srcdir)/../libelf -I$(srcdir)/../libebl \
+DEFAULT_INCLUDES = -I$(top_builddir)
+AM_CPPFLAGS = -I$(top_srcdir)/lib -I.. \
+			-I$(srcdir)/../libelf -I$(srcdir)/../libebl \
 	    -I$(srcdir)/../libdw -I$(srcdir)/../libdwelf \
 	    -I$(srcdir)/../libdwfl -I$(srcdir)/../libasm -I../debuginfod
 
-- 
2.44.1

