openwrt/tools/elfutils/patches/110-objects-manifest.patch
Michael Pratt 52a5344501 tools/elfutils: split upstreamable parts of portability patch
The addition of LT_INIT as well as the adjustment of
the BUILD_STATIC and addition of the BUILD_SHARED conditionals
and their usage to block building of shared objects
and adjust the variables for building static libraries
is potentially upstream-friendly.

The use of a manifest file to keep a list
of the objects in each library instead of calling ar
is also potentially upstream-friendly.

Separate these changes from the macOS-specific hacks.

Signed-off-by: Michael Pratt <mcpratt@pm.me>
Link: https://github.com/openwrt/openwrt/pull/15690
Signed-off-by: Robert Marko <robimarko@gmail.com>
2024-06-19 11:22:13 +02:00

162 lines
5.3 KiB
Diff

--- a/libdw/Makefile.am
+++ b/libdw/Makefile.am
@@ -137,19 +137,19 @@ uninstall: uninstall-am
rm -f $(DESTDIR)$(libdir)/libdw.so
rmdir --ignore-fail-on-non-empty $(DESTDIR)$(includedir)/elfutils
-libdwfl_objects = $(shell $(AR) t ../libdwfl/libdwfl.a)
+libdwfl_objects = $(shell cat ../libdwfl/libdwfl.manifest)
libdw_a_LIBADD = $(addprefix ../libdwfl/,$(libdwfl_objects))
-libdwelf_objects = $(shell $(AR) t ../libdwelf/libdwelf.a)
+libdwelf_objects = $(shell cat ../libdwelf/libdwelf.manifest)
libdw_a_LIBADD += $(addprefix ../libdwelf/,$(libdwelf_objects))
-libebl_objects = $(shell $(AR) t ../libebl/libebl.a)
+libebl_objects = $(shell cat ../libebl/libebl.manifest)
libdw_a_LIBADD += $(addprefix ../libebl/,$(libebl_objects))
-backends_objects = $(shell $(AR) t ../backends/libebl_backends.a)
+backends_objects = $(shell cat ../backends/libebl_backends.manifest)
libdw_a_LIBADD += $(addprefix ../backends/,$(backends_objects))
-libcpu_objects = $(shell $(AR) t ../libcpu/libcpu.a)
+libcpu_objects = $(shell cat ../libcpu/libcpu.manifest)
libdw_a_LIBADD += $(addprefix ../libcpu/,$(libcpu_objects))
if !BUILD_SHARED
@@ -161,4 +161,9 @@ noinst_HEADERS = libdwP.h memory-access.
EXTRA_DIST = libdw.map
-MOSTLYCLEANFILES = $(am_libdw_pic_a_OBJECTS) libdw.so libdw.so.$(VERSION)
+EXTRA_libdw_a_DEPENDENCIES = libdw.manifest
+
+libdw.manifest: $(libdw_a_OBJECTS)
+ echo $^ > $@
+
+MOSTLYCLEANFILES = $(am_libdw_pic_a_OBJECTS) $(EXTRA_libdw_a_DEPENDENCIES) libdw.so libdw.so.$(VERSION)
--- a/libdwfl/Makefile.am
+++ b/libdwfl/Makefile.am
@@ -93,4 +93,10 @@ am_libdwfl_pic_a_OBJECTS = $(libdwfl_a_S
noinst_HEADERS = libdwflP.h
+EXTRA_libdwfl_a_DEPENDENCIES = libdwfl.manifest
+
+libdwfl.manifest: $(libdwfl_a_OBJECTS)
+ echo $^ > $@
+
+MOSTLYCLEANFILES = $(EXTRA_libdwfl_a_DEPENDENCIES)
CLEANFILES += $(am_libdwfl_pic_a_OBJECTS)
--- a/libdwelf/Makefile.am
+++ b/libdwelf/Makefile.am
@@ -54,4 +54,10 @@ libeu = ../lib/libeu.a
libdwelf_pic_a_SOURCES =
am_libdwelf_pic_a_OBJECTS = $(libdwelf_a_SOURCES:.c=.os)
+EXTRA_libdwelf_a_DEPENDENCIES = libdwelf.manifest
+
+libdwelf.manifest: $(libdwelf_a_OBJECTS)
+ echo $^ > $@
+
+MOSTLYCLEANFILES = $(EXTRA_libdwelf_a_DEPENDENCIES)
CLEANFILES += $(am_libdwelf_pic_a_OBJECTS)
--- a/libebl/Makefile.am
+++ b/libebl/Makefile.am
@@ -61,4 +61,9 @@ am_libebl_pic_a_OBJECTS = $(libebl_a_SOU
noinst_HEADERS = libebl.h libeblP.h ebl-hooks.h
-MOSTLYCLEANFILES = $(am_libebl_pic_a_OBJECTS)
+EXTRA_libebl_a_DEPENDENCIES = libebl.manifest
+
+libebl.manifest: $(libebl_a_OBJECTS)
+ echo $^ > $@
+
+MOSTLYCLEANFILES = $(am_libebl_pic_a_OBJECTS) $(EXTRA_libebl_a_DEPENDENCIES)
--- a/backends/Makefile.am
+++ b/backends/Makefile.am
@@ -119,4 +119,9 @@ am_libebl_backends_pic_a_OBJECTS = $(lib
noinst_HEADERS = libebl_CPU.h common-reloc.c linux-core-note.c x86_corenote.c
EXTRA_DIST = $(modules:=_reloc.def)
-MOSTLYCLEANFILES = $(am_libebl_backends_pic_a_OBJECTS)
+EXTRA_libebl_backends_a_DEPENDENCIES = libebl_backends.manifest
+
+libebl_backends.manifest: $(libebl_backends_a_OBJECTS)
+ echo $^ > $@
+
+MOSTLYCLEANFILES = $(am_libebl_backends_pic_a_OBJECTS) $(EXTRA_libebl_backends_a_DEPENDENCIES)
--- a/libcpu/Makefile.am
+++ b/libcpu/Makefile.am
@@ -101,6 +101,11 @@ bpf_disasm_CFLAGS = -Wno-format-nonliter
EXTRA_DIST = defs/i386
-MOSTLYCLEANFILES = $(am_libcpu_pic_a_OBJECTS)
+EXTRA_libcpu_a_DEPENDENCIES = libcpu.manifest
+
+libcpu.manifest: $(libcpu_a_OBJECTS)
+ echo $^ > $@
+
+MOSTLYCLEANFILES = $(am_libcpu_pic_a_OBJECTS) $(EXTRA_libcpu_a_DEPENDENCIES)
CLEANFILES += $(foreach P,i386 x86_64,$P_defs $P.mnemonics)
MAINTAINERCLEANFILES = $(foreach P,i386 x86_64, $P_dis.h)
--- a/libelf/Makefile.am
+++ b/libelf/Makefile.am
@@ -142,4 +142,10 @@ uninstall: uninstall-am
EXTRA_DIST = libelf.map
+EXTRA_libelf_a_DEPENDENCIES = libelf.manifest
+
+libelf.manifest: $(libelf_a_OBJECTS)
+ echo $^ > $@
+
+MOSTLYCLEANFILES = $(EXTRA_libelf_a_DEPENDENCIES)
CLEANFILES += $(am_libelf_pic_a_OBJECTS) libelf.so libelf.so.$(VERSION)
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -41,3 +41,10 @@ noinst_HEADERS = fixedsizehash.h libeu.h
eu-config.h color.h printversion.h bpf.h \
atomics.h stdatomic-fbsd.h dynamicsizehash_concurrent.h
EXTRA_DIST = dynamicsizehash.c dynamicsizehash_concurrent.c
+
+EXTRA_libeu_a_DEPENDENCIES = libeu.manifest
+
+libeu.manifest: $(libeu_a_OBJECTS)
+ echo $^ > $@
+
+MOSTLYCLEANFILES = $(EXTRA_libeu_a_DEPENDENCIES)
--- a/libasm/Makefile.am
+++ b/libasm/Makefile.am
@@ -93,4 +93,10 @@ uninstall: uninstall-am
noinst_HEADERS = libasmP.h symbolhash.h
EXTRA_DIST = libasm.map
+EXTRA_libasm_a_DEPENDENCIES = libasm.manifest
+
+libasm.manifest: $(libasm_a_OBJECTS)
+ echo $^ > $@
+
+MOSTLYCLEANFILES = $(EXTRA_libasm_a_DEPENDENCIES)
CLEANFILES += $(am_libasm_pic_a_OBJECTS) libasm.so libasm.so.$(VERSION)
--- a/debuginfod/Makefile.am
+++ b/debuginfod/Makefile.am
@@ -132,7 +132,13 @@ uninstall: uninstall-am
endif
EXTRA_DIST = libdebuginfod.map
-MOSTLYCLEANFILES = $(am_libdebuginfod_pic_a_OBJECTS) $(LIBDEBUGINFOD_SONAME)
+
+EXTRA_libdebuginfod_a_DEPENDENCIES = libdebuginfod.manifest
+
+libdebuginfod.manifest: $(libdebuginfod_a_OBJECTS)
+ echo $^ > $@
+
+MOSTLYCLEANFILES = $(am_libdebuginfod_pic_a_OBJECTS) $(LIBDEBUGINFOD_SONAME) $(EXTRA_libdebuginfod_a_DEPENDENCIES)
CLEANFILES += $(am_libdebuginfod_pic_a_OBJECTS) libdebuginfod.so
# automake std-options override: arrange to pass LD_LIBRARY_PATH