From: Michael Pratt Date: Wed, 1 May 2024 19:21:38 +0000 (-0400) Subject: tools/elfutils: install a subset of the elfutils binaries X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=7822908bf313e1e0f1ae76d92588063160e94be2;p=openwrt%2Fstaging%2Flinusw.git tools/elfutils: install a subset of the elfutils binaries Install binaries that are not common with binutils instead of none at all. This adds a negligible time to the build. Building shared libraries is disabled, so the AM_LDFLAGS can be reset without the rpath-link option which is unrecognized by clang. Some of the binaries depend on functions that are defined using a "strong alias" instead of a normal definition, but this is disabled by our patches in order to work on macOS, so use the identical function directly instead. Add fnmatch from gnulib with GNU extensions which is needed for usage of the FNM_EXTMATCH flag. Handle a "Wunused-const-variable" error with the same preprocessor conditional used to include the function that the variable is used in. Ref: f64bd4b6c ("tools/elfutils: only build required components") Tested-by: Georgi Valkov # macOS Signed-off-by: Michael Pratt Link: https://github.com/openwrt/openwrt/pull/15368 Signed-off-by: Robert Marko --- diff --git a/tools/elfutils/Makefile b/tools/elfutils/Makefile index 466fc31271..b66d064e2b 100644 --- a/tools/elfutils/Makefile +++ b/tools/elfutils/Makefile @@ -17,6 +17,8 @@ PKG_CPE_ID:=cpe:/a:elfutils_project:elfutils PKG_FIXUP:=autoreconf PKG_INSTALL:=1 +PKG_PROGRAMS:=elflint findtextrel elfcmp unstrip stack elfcompress elfclassify srcfiles + PKG_SUBDIRS := \ libgnu \ config \ @@ -27,7 +29,8 @@ PKG_SUBDIRS := \ libebl \ libdwelf \ libdwfl \ - libdw + libdw \ + src PKG_GNULIB_BASE:=libgnu @@ -41,6 +44,7 @@ PKG_GNULIB_ARGS = \ PKG_GNULIB_MODS = \ argp \ + fnmatch-gnu \ fts \ obstack \ progname \ @@ -49,6 +53,10 @@ PKG_GNULIB_MODS = \ include $(INCLUDE_DIR)/host-build.mk +HOST_MAKE_FLAGS += \ + AM_LDFLAGS='$$$$(STACK_USAGE_NO_ERROR)' \ + bin_PROGRAMS='$(PKG_PROGRAMS)' EXEEXT= + ifeq ($(HOST_OS),Darwin) HOST_CFLAGS += -I/opt/homebrew/include endif diff --git a/tools/elfutils/patches/100-portability.patch b/tools/elfutils/patches/100-portability.patch index 6f7564731b..980b117f21 100644 --- a/tools/elfutils/patches/100-portability.patch +++ b/tools/elfutils/patches/100-portability.patch @@ -898,3 +898,46 @@ #include +--- a/libebl/eblopenbackend.c ++++ b/libebl/eblopenbackend.c +@@ -198,8 +198,6 @@ static bool default_object_note (const c + uint32_t descsz, const char *desc); + static bool default_debugscn_p (const char *name); + static bool default_copy_reloc_p (int reloc); +-static bool default_none_reloc_p (int reloc); +-static bool default_relative_reloc_p (int reloc); + static bool default_check_special_symbol (Elf *elf, + const GElf_Sym *sym, + const char *name, +@@ -251,8 +249,8 @@ fill_defaults (Ebl *result) + result->object_note = default_object_note; + result->debugscn_p = default_debugscn_p; + result->copy_reloc_p = default_copy_reloc_p; +- result->none_reloc_p = default_none_reloc_p; +- result->relative_reloc_p = default_relative_reloc_p; ++ result->none_reloc_p = default_copy_reloc_p; ++ result->relative_reloc_p = default_copy_reloc_p; + result->check_special_symbol = default_check_special_symbol; + result->data_marker_symbol = default_data_marker_symbol; + result->check_st_other_bits = default_check_st_other_bits; +@@ -634,8 +632,6 @@ default_copy_reloc_p (int reloc __attrib + { + return false; + } +-strong_alias (default_copy_reloc_p, default_none_reloc_p) +-strong_alias (default_copy_reloc_p, default_relative_reloc_p) + + static bool + default_check_special_symbol (Elf *elf __attribute__ ((unused)), +--- a/src/srcfiles.cxx ++++ b/src/srcfiles.cxx +@@ -78,7 +78,9 @@ ARGP_PROGRAM_VERSION_HOOK_DEF = print_ve + /* Bug report address. */ + ARGP_PROGRAM_BUG_ADDRESS_DEF = PACKAGE_BUGREPORT; + ++#ifdef HAVE_LIBARCHIVE + constexpr size_t BUFFER_SIZE = 8192; ++#endif + + /* Definitions of arguments for argp functions. */ + static const struct argp_option options[] =