Hi Mark,

On Tue, Jul 21, 2026 at 5:24 PM Mark Wielaard <[email protected]> wrote:
>
> We build almost everything twice, with and without -fpic. The first
> as normal .o files, the second as .os files. We then use the .os pic
> objects to create the shared libraries.
>
> This doesn't work well when using -gsplit-dwarf because the object
> files have the same base name. So both the file.o and file.os will
> have the same file.dwo file generated. Which means the split dwarf
> .dwo file is only valid for the last build object file. This breaks
> various self tests when building with CFLAGS="-g -O2 -gsplit-dwarf".
>
> Work around this by renaming the base object file name for the pic
> objects by adding an _.
>
>         * config/eu.am: Replace %.os rule to %_.os.
>         * backends/Makefile.am (am_libebl_backends_pic_a_OBJECTS):
>         Replace .c SOURCES with _.os OBJECTS.
>         * debuginfod/Makefile.am (am_libdebuginfod_pic_a_OBJECTS):
>         Likewise.
>         * libasm/Makefile.am (am_libasm_pic_a_OBJECTS): Likewise.
>         * libcpu/Makefile.am (am_libcpu_pic_a_OBJECTS): Likewise.
>         * libdw/Makefile.am (am_libdw_pic_a_OBJECTS): Likewise.
>         * libdwelf/Makefile.am (am_libdwelf_pic_a_OBJECTS): Likewise.
>         * libdwfl/Makefile.am (am_libdwfl_pic_a_OBJECTS): Likewise.
>         * libdwfl_stacktrace/Makefile.am
>         (am_libdwfl_stacktrace_pic_a_OBJECTS): Likewise.
>         * libebl/Makefile.am (am_libebl_pic_a_OBJECTS): Likewise.
>         * libelf/Makefile.am (am_libelf_pic_a_OBJECTS): Likewise.
>
> Signed-off-by: Mark Wielaard <[email protected]>

LGTM.

Aaron

> ---
>  backends/Makefile.am           | 2 +-
>  config/eu.am                   | 2 +-
>  debuginfod/Makefile.am         | 2 +-
>  libasm/Makefile.am             | 2 +-
>  libcpu/Makefile.am             | 2 +-
>  libdw/Makefile.am              | 2 +-
>  libdwelf/Makefile.am           | 2 +-
>  libdwfl/Makefile.am            | 2 +-
>  libdwfl_stacktrace/Makefile.am | 2 +-
>  libebl/Makefile.am             | 2 +-
>  libelf/Makefile.am             | 2 +-
>  11 files changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/backends/Makefile.am b/backends/Makefile.am
> index 318acef8aa1b..d7dfc7bcf9b8 100644
> --- a/backends/Makefile.am
> +++ b/backends/Makefile.am
> @@ -117,7 +117,7 @@ libebl_backends_a_SOURCES = $(i386_SRCS) $(sh_SRCS) 
> $(x86_64_SRCS) \
>                             $(hexagon_SRCS)
>
>  libebl_backends_pic_a_SOURCES =
> -am_libebl_backends_pic_a_OBJECTS = $(libebl_backends_a_SOURCES:.c=.os)
> +am_libebl_backends_pic_a_OBJECTS = $(libebl_backends_a_SOURCES:.c=_.os)
>
>  noinst_HEADERS = libebl_CPU.h libebl_PERF_FLAGS.h common-reloc.c \
>             linux-core-note.c x86_corenote.c \
> diff --git a/config/eu.am b/config/eu.am
> index 07573e1d16a8..5b64783cd88a 100644
> --- a/config/eu.am
> +++ b/config/eu.am
> @@ -159,7 +159,7 @@ DEFS.os += -DSYMBOL_VERSIONING
>  else
>  endif
>
> -%.os: %.c %.o
> +%_.os: %.c %.o
>  if AMDEP
>         $(AM_V_CC)if $(COMPILE.os) -c -o $@ $(fpic_CFLAGS) $(DEFS.os) -MT $@ 
> -MD -MP \
>           -MF "$(DEPDIR)/$*.Tpo" `test -f '$<' || echo '$(srcdir)/'`$<; \
> diff --git a/debuginfod/Makefile.am b/debuginfod/Makefile.am
> index 4727e5fa2fc1..a184f23b9454 100644
> --- a/debuginfod/Makefile.am
> +++ b/debuginfod/Makefile.am
> @@ -82,7 +82,7 @@ endif
>
>  libdebuginfod_a_SOURCES = debuginfod-client.c
>  libdebuginfod_pic_a_SOURCES = debuginfod-client.c
> -am_libdebuginfod_pic_a_OBJECTS = $(libdebuginfod_a_SOURCES:.c=.os)
> +am_libdebuginfod_pic_a_OBJECTS = $(libdebuginfod_a_SOURCES:.c=_.os)
>
>  if DUMMY_LIBDEBUGINFOD
>  AM_CPPFLAGS += -Wno-unused-parameter
> diff --git a/libasm/Makefile.am b/libasm/Makefile.am
> index 969db9350613..38de52cd02bc 100644
> --- a/libasm/Makefile.am
> +++ b/libasm/Makefile.am
> @@ -52,7 +52,7 @@ libasm_a_SOURCES = asm_begin.c asm_abort.c asm_end.c 
> asm_error.c \
>                    symbolhash.c
>
>  libasm_pic_a_SOURCES =
> -am_libasm_pic_a_OBJECTS = $(libasm_a_SOURCES:.c=.os)
> +am_libasm_pic_a_OBJECTS = $(libasm_a_SOURCES:.c=_.os)
>
>  libasm_so_DEPS = ../lib/libeu.a ../libebl/libebl_pic.a ../libelf/libelf.so 
> ../libdw/libdw.so
>  libasm_so_LDLIBS = $(libasm_so_DEPS)
> diff --git a/libcpu/Makefile.am b/libcpu/Makefile.am
> index df16439c27b5..296878793853 100644
> --- a/libcpu/Makefile.am
> +++ b/libcpu/Makefile.am
> @@ -45,7 +45,7 @@ noinst_HEADERS = i386_dis.h i386_mne.h x86_64_dis.h
>  libcpu_a_SOURCES = i386_disasm.c x86_64_disasm.c bpf_disasm.c riscv_disasm.c
>
>  libcpu_pic_a_SOURCES =
> -am_libcpu_pic_a_OBJECTS = $(libcpu_a_SOURCES:.c=.os)
> +am_libcpu_pic_a_OBJECTS = $(libcpu_a_SOURCES:.c=_.os)
>
>  i386_gendis_SOURCES = i386_gendis.c i386_lex.l i386_parse.y
>
> diff --git a/libdw/Makefile.am b/libdw/Makefile.am
> index c98fe31fc0f8..8ca5aba48c33 100644
> --- a/libdw/Makefile.am
> +++ b/libdw/Makefile.am
> @@ -103,7 +103,7 @@ $(srcdir)/known-dwarf.h: 
> $(top_srcdir)/config/known-dwarf.awk $(srcdir)/dwarf.h
>  endif
>
>  libdw_pic_a_SOURCES =
> -am_libdw_pic_a_OBJECTS = $(libdw_a_SOURCES:.c=.os)
> +am_libdw_pic_a_OBJECTS = $(libdw_a_SOURCES:.c=_.os)
>
>  libdw_so_LIBS = ../libebl/libebl_pic.a ../backends/libebl_backends_pic.a \
>                 ../libcpu/libcpu_pic.a libdw_pic.a ../libdwelf/libdwelf_pic.a 
> \
> diff --git a/libdwelf/Makefile.am b/libdwelf/Makefile.am
> index 9df21ca21fed..5d3577201bed 100644
> --- a/libdwelf/Makefile.am
> +++ b/libdwelf/Makefile.am
> @@ -53,7 +53,7 @@ libebl = ../libebl/libebl.a
>  libeu = ../lib/libeu.a
>
>  libdwelf_pic_a_SOURCES =
> -am_libdwelf_pic_a_OBJECTS = $(libdwelf_a_SOURCES:.c=.os)
> +am_libdwelf_pic_a_OBJECTS = $(libdwelf_a_SOURCES:.c=_.os)
>
>  EXTRA_libdwelf_a_DEPENDENCIES = libdwelf.manifest
>
> diff --git a/libdwfl/Makefile.am b/libdwfl/Makefile.am
> index 6ad5ba109b6b..04c610950d16 100644
> --- a/libdwfl/Makefile.am
> +++ b/libdwfl/Makefile.am
> @@ -91,7 +91,7 @@ libebl = ../libebl/libebl.a
>  libeu = ../lib/libeu.a
>
>  libdwfl_pic_a_SOURCES =
> -am_libdwfl_pic_a_OBJECTS = $(libdwfl_a_SOURCES:.c=.os)
> +am_libdwfl_pic_a_OBJECTS = $(libdwfl_a_SOURCES:.c=_.os)
>
>  noinst_HEADERS = libdwflP.h
>
> diff --git a/libdwfl_stacktrace/Makefile.am b/libdwfl_stacktrace/Makefile.am
> index b92421291acb..93d0b545cae2 100644
> --- a/libdwfl_stacktrace/Makefile.am
> +++ b/libdwfl_stacktrace/Makefile.am
> @@ -54,7 +54,7 @@ libebl = ../libebl/libebl.a
>  libeu = ../lib/libeu.a
>
>  libdwfl_stacktrace_pic_a_SOURCES =
> -am_libdwfl_stacktrace_pic_a_OBJECTS = $(libdwfl_stacktrace_a_SOURCES:.c=.os)
> +am_libdwfl_stacktrace_pic_a_OBJECTS = $(libdwfl_stacktrace_a_SOURCES:.c=_.os)
>
>  noinst_HEADERS = libdwfl_stacktraceP.h \
>                  dwflst_tracker_elftab.h dwflst_tracker_dwfltab.h
> diff --git a/libebl/Makefile.am b/libebl/Makefile.am
> index 3df12ce269d6..05e9538b91b8 100644
> --- a/libebl/Makefile.am
> +++ b/libebl/Makefile.am
> @@ -57,7 +57,7 @@ libebl_a_SOURCES = eblopenbackend.c eblclosebackend.c 
> eblreloctypename.c \
>                    ebl_data_marker_symbol.c
>
>  libebl_pic_a_SOURCES =
> -am_libebl_pic_a_OBJECTS = $(libebl_a_SOURCES:.c=.os)
> +am_libebl_pic_a_OBJECTS = $(libebl_a_SOURCES:.c=_.os)
>
>  noinst_HEADERS = libebl.h libeblP.h ebl-hooks.h
>
> diff --git a/libelf/Makefile.am b/libelf/Makefile.am
> index cc539c8dab3c..af37c940556c 100644
> --- a/libelf/Makefile.am
> +++ b/libelf/Makefile.am
> @@ -104,7 +104,7 @@ libelf_a_SOURCES = elf_version.c elf_hash.c elf_error.c 
> elf_fill.c \
>                    elf_compress.c elf_compress_gnu.c
>
>  libelf_pic_a_SOURCES =
> -am_libelf_pic_a_OBJECTS = $(libelf_a_SOURCES:.c=.os)
> +am_libelf_pic_a_OBJECTS = $(libelf_a_SOURCES:.c=_.os)
>
>  libelf_so_DEPS = ../lib/libeu.a
>  libelf_so_LDLIBS = $(libelf_so_DEPS) -lz $(zstd_LIBS)
> --
> 2.55.0
>

Reply via email to