]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Replace usage of ar with stored library manifest files
authorMichael Pratt <mcpratt@pm.me>
Mon, 13 Jan 2025 23:56:38 +0000 (23:56 +0000)
committerMark Wielaard <mark@klomp.org>
Tue, 21 Jan 2025 17:57:34 +0000 (18:57 +0100)
The ar program is called to assemble a list of objects
within each archive to assist in building combined libraries,
however make already has this information
when processing the subdirectory for that respective library.
The list can be saved in a "manifest" file
instead of being generated whenever it is needed
for use with other subdirectories.

Even though the difference in time is insignificant,
a simple "echo" and "cat" is as much as 10 times faster
than a call to "ar t" for printing the archive members.

Since elfutils builds ar,
this also removes the awkward circular dependency
where an installation of ar is required
to build the libraries for ar.

Additionally, not every version of ar is equally portable,
as native versions of ar on macOS and other BSD-like distributions
may print out a special archive member like "__.SYMDEF"
which is not a compiled object but rather just metadata
from ranlib, leading to a build failure.

Avoid these limitations by removing usage of ar
and adding build and clean rules
for the usage of archive manifest files.

    * .gitignore: exclude ".manifest" file extension.
    * backends/Makefile.am: add manifest file build and clean rules.
    * debuginfod/Makefile.am: Likewise.
    * lib/Makefile.am: Likewise.
    * libasm/Makefile.am: Likewise.
    * libcpu/Makefile.am: Likewise.
    * libdw/Makefile.am: Likewise,
      and set object lists to manifest contents.
    * libdwelf/Makefile.am: Likewise.
    * libdwfl/Makefile.am: Likewise.
    * libebl/Makefile.am: Likewise.
    * libelf/Makefile.am: Likewise,
      and set object lists to manifest contents.
    * src/Makefile.am: Likewise.

Signed-off-by: Michael Pratt <mcpratt@pm.me>
12 files changed:
.gitignore
backends/Makefile.am
debuginfod/Makefile.am
lib/Makefile.am
libasm/Makefile.am
libcpu/Makefile.am
libdw/Makefile.am
libdwelf/Makefile.am
libdwfl/Makefile.am
libebl/Makefile.am
libelf/Makefile.am
src/Makefile.am

index 8bcd88d71515e16aae8b0b2257098d70cf8c60ac..b21d74901aadb7ded0c02fa63dcdf5e12b10f522 100644 (file)
@@ -2,6 +2,7 @@
 *.a
 *.gcda
 *.gcno
+*.manifest
 *.o
 *.orig
 *.os
index 347dad52a7134e02873356db81ac9537e1655d8e..540d0c6c0c32058d7fe9927985dd555e0ee8ca0c 100644 (file)
@@ -123,4 +123,10 @@ noinst_HEADERS = libebl_CPU.h common-reloc.c linux-core-note.c x86_corenote.c
 
 EXTRA_DIST = $(modules:=_reloc.def)
 
+EXTRA_libebl_backends_a_DEPENDENCIES = libebl_backends.manifest
+
+libebl_backends.manifest: $(libebl_backends_a_OBJECTS)
+       $(AM_V_GEN)echo $^ > $@
+
 MOSTLYCLEANFILES = $(am_libebl_backends_a_OBJECTS) $(am_libebl_backends_pic_a_OBJECTS)
+CLEANFILES = $(EXTRA_libebl_backends_a_DEPENDENCIES)
index 45b5339f488c4f8aec9e3f9181db260ded933983..4727e5fa2fc1b65a62257d6b1483a99f8823edc8 100644 (file)
@@ -126,8 +126,13 @@ endif
 
 EXTRA_DIST = libdebuginfod.map
 
+EXTRA_libdebuginfod_a_DEPENDENCIES = libdebuginfod.manifest
+
+libdebuginfod.manifest: $(libdebuginfod_a_OBJECTS)
+       $(AM_V_GEN)echo $^ > $@
+
 MOSTLYCLEANFILES = $(am_libdebuginfod_a_OBJECTS) $(am_libdebuginfod_pic_a_OBJECTS) $(LIBDEBUGINFOD_SONAME)
-CLEANFILES = libdebuginfod.so
+CLEANFILES = libdebuginfod.so $(EXTRA_libdebuginfod_a_DEPENDENCIES)
 
 # automake std-options override: arrange to pass LD_LIBRARY_PATH
 installcheck-binPROGRAMS: $(bin_PROGRAMS)
index 45b351c1717518d4dfc786e181b40f5e7f854252..bf5f9ee2058da2d580063368173091985f9597c9 100644 (file)
@@ -43,3 +43,10 @@ noinst_HEADERS = fixedsizehash.h libeu.h system.h dynamicsizehash.h list.h \
                 eu-search.h locks.h
 
 EXTRA_DIST = dynamicsizehash.c dynamicsizehash_concurrent.c
+
+EXTRA_libeu_a_DEPENDENCIES = libeu.manifest
+
+libeu.manifest: $(libeu_a_OBJECTS)
+       $(AM_V_GEN)echo $^ > $@
+
+CLEANFILES = $(EXTRA_libeu_a_DEPENDENCIES)
index 324fd095a7837c4f744c10daa2448dd73b8bebdf..969db9350613d8e1d6a6f20c265ca9a72d6cfd17 100644 (file)
@@ -87,5 +87,10 @@ noinst_HEADERS = libasmP.h symbolhash.h
 
 EXTRA_DIST = libasm.map
 
+EXTRA_libasm_a_DEPENDENCIES = libasm.manifest
+
+libasm.manifest: $(libasm_a_OBJECTS)
+       $(AM_V_GEN)echo $^ > $@
+
 MOSTLYCLEANFILES = $(am_libasm_a_OBJECTS) $(am_libasm_pic_a_OBJECTS) libasm.so.$(VERSION)
-CLEANFILES = libasm.so
+CLEANFILES = libasm.so $(EXTRA_libasm_a_DEPENDENCIES)
index 2e87021b49e3db61f628ae43a1d906db2bb95648..df16439c27b5335efc8a97b28c52e0ea214537f7 100644 (file)
@@ -103,6 +103,11 @@ bpf_disasm_CFLAGS = -Wno-format-nonliteral
 
 EXTRA_DIST = defs/i386
 
+EXTRA_libcpu_a_DEPENDENCIES = libcpu.manifest
+
+libcpu.manifest: $(libcpu_a_OBJECTS)
+       $(AM_V_GEN)echo $^ > $@
+
 MOSTLYCLEANFILES = $(am_libcpu_a_OBJECTS) $(am_libcpu_pic_a_OBJECTS) $(i386_gendis_OBJECTS)
-CLEANFILES = $(foreach P,i386 x86_64,$P_defs $P.mnemonics)
+CLEANFILES = $(foreach P,i386 x86_64,$P_defs $P.mnemonics) $(EXTRA_libcpu_a_DEPENDENCIES)
 MAINTAINERCLEANFILES = $(foreach P,i386 x86_64, $P_defs $P_dis.h $P_parse.h)
index 62f4359e4c0969644377de01709d31929f341a83..8cbe0f327a32694b55bb27b714f14514a8aac9ab 100644 (file)
@@ -132,19 +132,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))
 
 noinst_HEADERS = libdwP.h memory-access.h dwarf_abbrev_hash.h \
@@ -152,6 +152,11 @@ noinst_HEADERS = libdwP.h memory-access.h dwarf_abbrev_hash.h \
 
 EXTRA_DIST = libdw.map
 
+EXTRA_libdw_a_DEPENDENCIES = libdw.manifest
+
+libdw.manifest: $(libdw_a_OBJECTS)
+       $(AM_V_GEN)echo $^ > $@
+
 MOSTLYCLEANFILES = $(am_libdw_a_OBJECTS) $(am_libdw_pic_a_OBJECTS) libdw.so.$(VERSION)
-CLEANFILES = libdw.so
+CLEANFILES = libdw.so $(EXTRA_libdw_a_DEPENDENCIES)
 MAINTAINERCLEANFILES = $(srcdir)/known-dwarf.h
index 30abdf81673cf6ae9c193950b8a6668321581eeb..5fb57379898e5316ec06c8f258e0f70a2f71471e 100644 (file)
@@ -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)
+       $(AM_V_GEN)echo $^ > $@
+
 MOSTLYCLEANFILES = $(am_libdwelf_a_OBJECTS) $(am_libdwelf_pic_a_OBJECTS)
+CLEANFILES = $(EXTRA_libdwelf_a_DEPENDENCIES)
index 171bb368be5c2160a4c3af2f7561bb262d7ea7d0..b30b86f0523c069e624c2d63ea1be76469d7fad7 100644 (file)
@@ -94,4 +94,10 @@ am_libdwfl_pic_a_OBJECTS = $(libdwfl_a_SOURCES:.c=.os)
 
 noinst_HEADERS = libdwflP.h
 
+EXTRA_libdwfl_a_DEPENDENCIES = libdwfl.manifest
+
+libdwfl.manifest: $(libdwfl_a_OBJECTS)
+       $(AM_V_GEN)echo $^ > $@
+
 MOSTLYCLEANFILES = $(am_libdwfl_a_OBJECTS) $(am_libdwfl_pic_a_OBJECTS)
+CLEANFILES = $(EXTRA_libdwfl_a_DEPENDENCIES)
index e94eaa7fbb7af49fc521274b302fe63139684db8..ea092b5a03c79d577171887be58eb8f65dff7fc3 100644 (file)
@@ -61,4 +61,10 @@ am_libebl_pic_a_OBJECTS = $(libebl_a_SOURCES:.c=.os)
 
 noinst_HEADERS = libebl.h libeblP.h ebl-hooks.h
 
+EXTRA_libebl_a_DEPENDENCIES = libebl.manifest
+
+libebl.manifest: $(libebl_a_OBJECTS)
+       $(AM_V_GEN)echo $^ > $@
+
 MOSTLYCLEANFILES = $(am_libebl_a_OBJECTS) $(am_libebl_pic_a_OBJECTS)
+CLEANFILES = $(EXTRA_libebl_a_DEPENDENCIES)
index e91bcd6e9ba1733d615e7c6affc06540f7017815..05484c12c0a08cc981f0b4c4ee618869adbf434f 100644 (file)
@@ -122,7 +122,7 @@ libelf.so: $(srcdir)/libelf.map $(libelf_so_LIBS) $(libelf_so_DEPS)
        @$(textrel_check)
        $(AM_V_at)ln -fs $@ $@.$(VERSION)
 
-libeu_objects = $(shell $(AR) t ../lib/libeu.a)
+libeu_objects = $(shell cat ../lib/libeu.manifest)
 libelf_a_LIBADD = $(addprefix ../lib/,$(libeu_objects))
 
 install: install-am libelf.so
@@ -138,5 +138,10 @@ uninstall: uninstall-am
 
 EXTRA_DIST = libelf.map
 
+EXTRA_libelf_a_DEPENDENCIES = libelf.manifest
+
+libelf.manifest: $(libelf_a_OBJECTS)
+       $(AM_V_GEN)echo $^ > $@
+
 MOSTLYCLEANFILES = $(am_libelf_a_OBJECTS) $(am_libelf_pic_a_OBJECTS) libelf.so.$(VERSION)
-CLEANFILES = libelf.so
+CLEANFILES = libelf.so $(EXTRA_libelf_a_DEPENDENCIES)
index 97a0c61aac59874ea4fe39848fe72dcef0b56248..ed245fc17e395a7288f806a5edf2aa54d1c7a3da 100644 (file)
@@ -43,8 +43,13 @@ bin_SCRIPTS = make-debug-archive
 
 EXTRA_DIST = arlib.h debugpred.h make-debug-archive.in
 
+EXTRA_libar_a_DEPENDENCIES = libar.manifest
+
+libar.manifest: $(libar_a_OBJECTS)
+       $(AM_V_GEN)echo $^ > $@
+
 MOSTLYCLEANFILES = *.gconv
-CLEANFILES = $(bin_SCRIPTS)
+CLEANFILES = $(bin_SCRIPTS) $(EXTRA_libar_a_DEPENDENCIES)
 
 if BUILD_STATIC
 libasm = ../libasm/libasm.a