Hi Tristan,

Thanks for the patch, some comments below.

> From 11f000782c16f05f81a15d4dba75deb082ab97e1 Mon Sep 17 00:00:00 2001
> From: Tristan Ross <tristan.r...@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.r...@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.r...@midstall.com>
> +
> +    * src/Makefile.am: Prevent collision between headers and
> +    binaries in libc++.
> +

This change can be dropped, we no longer update ChangeLogs.

>  2023-03-27  Di Chen  <dic...@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

DEFAULT_INCLUDES and AM_CPPFLAGS default to `-I. -I$(top_builddir)` and
`-I. -I$(srcdir) -I$(top_srcdir)/lib -I..` respectively.  So essentially
this change removes -I. and -I$(srcdir) from these variables.

I noticed that with this patch autoreconf now emits a warning:

src/Makefile.am:23: warning: AM_CPPFLAGS multiply defined [...]
config/eu.am:34: ... 'AM_CPPFLAGS' previously defined here
src/Makefile.am:19:   'config/eu.am' included from here

Is there a way to implement this change without triggering any
warnings during the build?

Aaron

Reply via email to