Commit Graph

18 Commits

Author SHA1 Message Date
Robert Marko 00ff73ec6e tools/elfutils: remove dirname
In the 0.191 update dirname was used instead of <libgen.h> to fix the
poisoned basename error:
/usr/include/libgen.h:35:9: error: attempt to use poisoned "basename"
       35 | #define basename        __xpg_basename

However, doing this has lead to libelf.a pulling in xmalloc, xstrdup and
friends and statically linking them thus leading to a symbol name conflict
with FRR host build and anything else that links against libelf and uses
xmalloc and friends.

Well, it turns out that upstream has added a helper[1] for basename so it
can compile with musl 1.2.5 which dropped the basename declaration, but it
also means that we must NOT include <libgen.h> and that poisoned error is
intentional and added to prevent duplicate basename definitions.
This also means that for macOS we dont need to do any additional header
inclusions as the new helper takes care of basename.

So, to fix the symbol conflict we can simply drop the <dirname.h> inclusion
and build from elfutils.

Tested on Fedora 40 as well as macOS 14.4.1.

[1] https://sourceware.org/git/?p=elfutils.git;a=commit;h=a2194f6b305bf0d0b9dd49dccd0a5c21994c8eea

Fixes: #24030
Fixes: b6f025b424 ("tools/elfutils: update to 1.91")

Link: https://github.com/openwrt/openwrt/pull/15337
Signed-off-by: Robert Marko <robimarko@gmail.com>
2024-04-30 13:37:59 +02:00
Michael Pratt 1991bfb814 tools/elfutils: refresh portability patch for macOS
Quilt refresh combined two sets of changes to the same file.

The switch from using libgen.h to dirname.h because of function poisoning
from gnulib's import of basename() was added as a new patch hunk instead
of an edit to the original one.

The original patch hunk was to fix build errors on an earlier version of
elfutils before the "dirname" module was being imported to fix further
build errors with the 0.191 version.

Tested-by: Georgi Valkov <gvalkov@gmail.com> # MacOS
Signed-off-by: Michael Pratt <mcpratt@pm.me>
Signed-off-by: Tony Ambardar <itugrok@yahoo.com>
2024-04-25 21:33:51 +02:00
Michael Pratt ddb7177c57 tools/elfutils: remove no-op copy of tdestroy()
A false tdestroy() function was added in order to make elfutils build on
macOS again. A previous commit added declarations for a real version of
tdestroy() into gnulib, which is already imported, as well as the
preprocessor flags and the triggers for the Makefile.am conditional in
order to include the source to be built.

Tested-by: Georgi Valkov <gvalkov@gmail.com> # MacOS
Signed-off-by: Michael Pratt <mcpratt@pm.me>
Signed-off-by: Tony Ambardar <itugrok@yahoo.com>
2024-04-25 21:33:51 +02:00
Michael Pratt 20ed56ec8b tools/elfutils: use locally declared static reallocarray()
On macOS, stdlib.h in the standard include paths does not provide
reallocarray() while both elfutils and gnulib do, however they are
declared differently, leading to an error:

  ./system.h:101:1: error: static declaration of 'reallocarray' follows non-static declaration
  reallocarray (void *ptr, size_t nmemb, size_t size)

A normal "configure && make" build cycle results in both declarations
being enabled as a result of both elfutils and gnulib having completely
separate configure checks where gnulib uses an internal placeholder symbol
HAVE_REALLOCARRAY, and elfutils uses a standard autoconf macro
HAVE_DECL_REALLOCARRAY.

Fix this by excluding the import of the reallocarray module which causes
gnulib checks in the configure stage to not even consider whether to
declare reallocarray later on, so the decision is only between the
standard include stdlib.h and the elfutils header.

Tested-by: Georgi Valkov <gvalkov@gmail.com> # MacOS
Signed-off-by: Michael Pratt <mcpratt@pm.me>
Signed-off-by: Tony Ambardar <itugrok@yahoo.com>
2024-04-25 21:33:51 +02:00
Michael Pratt 43be319823 tools/elfutils: organize gnulib import build stage
Organize the Makefile lines involved in gnulib importing and its
workarounds. It improves readability and keeps git history organized.

Tested-by: Georgi Valkov <gvalkov@gmail.com> # MacOS
Signed-off-by: Michael Pratt <mcpratt@pm.me>
Signed-off-by: Tony Ambardar <itugrok@yahoo.com>
2024-04-25 21:33:51 +02:00
Michael Pratt 7a4df7825e tools/elfutils: override SUBDIRS variable of Makefile
Instead of editing the SUBDIRS variable with a patch, it can be overriden
at the end of the command line when invoking Make.

This tool has a series of recursive Makefiles in each subdirectory,
therefore SUBDIRS is set to a pattern of Make functions so that the result
is variable depending on the current subdirectory that Make is being
invoked in.

It's not necessary to have gnulib-cache.m4 in EXTRA_DIST since we don't
need to re-import after packaging this in the SDK, so get rid of the
entire patch hunk for ./Makefile.am

Tested-by: Georgi Valkov <gvalkov@gmail.com> # MacOS
Signed-off-by: Michael Pratt <mcpratt@pm.me>
Signed-off-by: Tony Ambardar <itugrok@yahoo.com>
2024-04-25 21:33:51 +02:00
Tony Ambardar b6f025b424 tools/elfutils: update to 1.91
Release Notes:
https://sourceware.org/pipermail/elfutils-devel/2024q1/006876.html

Manually refresh:
- 100-portability.patch

Change:
- replace libgen.h with gnulib "dirname" module for compilation errors:
    In file included from ./../libdw/libdwP.h:38,
                     from eblobjnote.c:42:
    /usr/include/libgen.h:35:9: error: attempt to use poisoned "basename"
       35 | #define basename        __xpg_basename
          |         ^

Tested-by: Georgi Valkov <gvalkov@gmail.com> # MacOS
Co-Developed-by: Nick Hainke <vincent@systemli.org>
Signed-off-by: Nick Hainke <vincent@systemli.org>
Signed-off-by: Tony Ambardar <itugrok@yahoo.com>
2024-04-25 21:33:51 +02:00
Felix Fietkau f95a8f8769 tools/elfutils: fix missing _ in auxv info alias
Fixes dwarves compile issue

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2023-11-01 19:20:35 +01:00
Felix Fietkau 17a5f1c81f tools/elfutils: disable bzlib support
It is not needed

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2023-11-01 18:37:50 +01:00
Felix Fietkau 5364163e77 tools/elfutils: add -fPIC to fix linker errors (#13841)
Resolves issues with building PIE binaries that link against libdw or libelf

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2023-11-01 17:45:25 +01:00
Felix Fietkau 5331e85d96 elfutils: fix build and enable on non-linux systems
Use gnulib for compatibility

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2023-10-29 15:56:46 +01:00
Nick Hainke 34f7b2120c tools/elfutils: update to 1.89
Release Notes:
https://sourceware.org/pipermail/elfutils-devel/2023q1/006023.html

Signed-off-by: Nick Hainke <vincent@systemli.org>
2023-03-12 13:53:49 +01:00
Nick Hainke e0e7e349fa tools/elfutils: update to 1.88
Release Notes:
https://sourceware.org/pipermail/elfutils-devel/2022q4/005561.html

Signed-off-by: Nick Hainke <vincent@systemli.org>
2022-11-05 14:07:46 +00:00
Rosen Penev a63805b25f
tools: add Host/Uninstall where possible
This cleans staging_dir when calling tool/x/clean.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2022-10-20 00:33:22 +02:00
Hauke Mehrtens 3efe595df9 tools: elfutils: Update to version 0.187
Update to most recent version of elfutils and sync with version from
package folder.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
2022-08-13 14:05:29 +02:00
Stijn Tintel 6eec1a5225 tools/elfutils: drop HOST_BUILD_DEPENDS
This is only effective for host build of normal packages, not tools.

Fixes: ad79b92719 ("elfutils: move host build to tools")
Reported-by: Rosen Penev <rosenp@gmail.com>
Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
2022-05-19 02:37:25 +03:00
Stijn Tintel f64bd4b6ce tools/elfutils: only build required components
Building all of the components results in strip being installed in
staging_dir/host/bin. This strip binary will take precedence over
binutils strip that is installed in the toolchain directory.

This will not work on host systems that do not have libdw installed, as
we do not set HOST_LDFLAGS to override rpath to staging_dir/host/lib.
However, rather than overriding rpath, we should just avoid using
elfutils strip entirely.

Override the SUBDIRS variable in the Makefile to only build and install
the libraries we require for dwarves and frr.

Fixes the following build failure in toolchain/gdb:
strip: error while loading shared libraries: libdw.so.1: cannot open shared object file: No such file or directory

Fixes: ad79b92719 ("elfutils: move host build to tools")
Reported-by: Dominick Grift <dominick.grift@defensec.nl>
Reported-by: Lucian Cristian <lucian.cristian@gmail.com>
Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
2022-05-19 02:36:48 +03:00
Stijn Tintel ad79b92719 elfutils: move host build to tools
The upcoming dwarves host package requires elfutils. As dependencies for
tools must exist in tools, we need to move elfutils host build there.

As there is at least one package that depends on this, and there is no
proper way to create such dependency in the build system, build it
unconditionally when not building on macOS.

Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
2022-05-18 13:32:06 +03:00