1
0
mirror of https://git.openwrt.org/openwrt/openwrt.git synced 2024-10-18 13:29:16 +02:00
Commit Graph

2137 Commits

Author SHA1 Message Date
Thomas Weißschuh
17099f2760 tools: util-linux: update to v2.40.1
Release Notes:
	https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/v2.40/v2.40-ReleaseNotes
	https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/v2.40/v2.40.1-ReleaseNotes

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2024-06-20 14:06:41 +02:00
Michael Pratt
c24c3da00b tools/coreutils: ignore gnulib changes to fcntl.h
As a side-effect to adding a gnulib module for posix_fallocate(),
there are changes to the input file for fcntl.h which
are not handled here since autoreconf is not ran.

Skip updating the fcntl.h header from gnulib
and use the version shipped with the release.

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
Michael Pratt
f560588b05 tools/elfutils: add more pkg-config library info
In order for linking the static libraries from elfutils to work,
other libraries need to be included to handle the references
to functions made in the library's objects that are not included
as they would already be if the library was a shared object instead.

A shared object library stores this list of libraries when it was made,
so that the dynamic linker can refer to that list at runtime,
but a static library has no such functionality so the list of libraries
for missing functions must be included at link time.

This information was already added to the pc file for libelf
using the definitions in src/Makefile.am,
so extend this to the rest of the pc files in the project.

For situations where the libraries may be used
without pkg-config setting the flags and library list,
this patch and the pc files can serve as a quick reference.

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
Michael Pratt
e4fb7c9544 tools/elfutils: use weak alias over no alias for macOS
Clang has support for weak aliases
despite no support for strong aliases,
but it only works with the #pragma directive.

Implementing weak aliases instead of none
is likely a more upstream-friendly solution
for supporting building on other platforms.

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
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
Michael Pratt
9670a38d08 tools/elfutils: use conditional to block build of shared objects
Add a potentially upstream-friendly conditional
using the libtool configure variable "enable_shared"
in order to block building and installing of shared objects
and adjust the build of static libraries
instead of directly patching lines in or out.

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
Michael Pratt
954179e412 tools/elfutils: do not use ar to list library objects
The use of ar to list the archive members in a library
in order to include them in another library is not portable.

On BSD and macOS, ar will also list
the special archive member "__.SYMDEF"
which is not a compiled object, rather it is
part of the metadata prepended to the library by ranlib.

Fix this by writing the list of unique objects used
to create the library into a separate "manifest" file
when the library is created, which will be read later
when the Makefiles of other subdirectories are ran.

Extend this to all other libraries whether or not they are linked
to another library for a shared object that is installed
so that it is possible for any of the libraries
to be statically built with more objects.

The use of the wildcard function to ignore the
special archive members which are only metadata
is no longer needed to prevent build errors.

Not using the wildcard function is preferred,
since errors should be caught during the build
instead of when linking something else or at runtime.

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
Michael Pratt
8ce3873a28 tools/elfutils: do not use libtool for all subdirectories
Importing gnulib in order to have a local portable library
to link against for missing functions currently requires
using libtool to produce the libgnu.la library.

Ideally, linking would be simple if the rest of the libraries
built by elfutils were also built using libtool, as linking
them together would not require any manipulations of library paths.

However, upstream elfutils does not support building the libraries
statically with libtool, so using libtool comes at the cost
of creating a huge patch to introduce that functionality.

For building on macOS, it turns out that libgnu.la is only needed
for building the binaries, and that just one or two objects from libgnu
are needed to build the libraries, so in this case, it would be simple
to add the specific non-libtool-wrapped library and objects
to the link paths as needed, rather than use libtool to link
the libtool wrappers, which greatly reduces the need to patch.

Not using libtool also makes the original Makefile definitions for LIBADD
once again be the right ones to use. However, to be portable,
for libdw the wildcard function needs to be used in order to exclude
special archive members like "__.SYMDEF" which are not compiled objects
because some BSD-like versions of ar include that metadata in the list,
or because the library included may have objects from another subdirectory.
Also, the rest of the subdirectories have custom "LDLIBS" variables
meant for building shared objects only, so define the LIBADD variables
with objects from those existing definitions so that when building only
the static versions of the libraries, those objects can still be included.

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
Michael Pratt
c07a234164 tools/elfutils: use gnulib module for posix_fallocate()
The version of posix_fallocate() patched into elfutils
for macOS using code from Mozilla is now patched into gnulib.

Import the fallocate-posix module and always link
the corresponding object to libraries whenever it is built.

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
Michael Pratt
f07621e10b tools/gnulib: add fallocate-posix module
Add a module to gnulib to support posix_fallocate()
for macOS and other systems that are missing it.

Apple-specific code is sourced from Mozilla,
and the rest from glibc, both licensed under LGPL.

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
Michael Pratt
447093ffde tools/elfutils: simplify portability patch
Several changes to the elfutils source files
made during the process of figuring out how to
successfully build elfutils on macOS
turn out to not be necessary to do so,
and were most likely leftover bits during testing.

Remove the line changes that are not needed
and add some line changes to adapt to sources as is:

 - Remove now unnecessary bump to autoconf version prereq
 - AC_CONFIG_MACRO_DIRS is not necessary to define
   as ACLOCAL_AMFLAGS is already defined in Makefiles
 - let libtool "enable_static" variable also decide the value
   of the local conditional BUILD_STATIC
 - override configure variables instead of removing
   checks for libraries or additions to LDFLAGS
 - only exclude "hidden" attribute for macOS instead of deleting
 - preserve original list of sources to build for libelf
 - use openwrt Makefile to add gnulib headers
 - use openwrt Makefile to add LIBADD variables
 - remove deletion of variables and rules for shared objects
 - prefer recursively expanded variables over muliple renames
   each time that a word is added to its value
 - remove changes to subdirectories that are not built
   and remove changes to target files of those subdirectories
 - prefer basic text rename over variables in cases where
   there would be no line number difference
 - give LT_INIT forced default values that match upstream
 - move gl_EARLY and gl_INIT down relative to compiler checks
 - reorganize some line changes to save some lines

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
Michael Pratt
e6d106284e tools/gnulib: ignore AC_PREREQ error if actual version passes
The gnulib-tool script is written to have a fatal error
whenever the minimum required version of autoconf
for the project that gnulib is being imported into
as defined in configure.ac was less than
the minimum required version required by gnulib.

However, none of this matters if the version of autoconf
that we use is newer than both requirements.

Instead, use functions from the bootstrap script
to check for the version of autoconf being used
and print a warning whenever this case occurs.

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
Michael Pratt
efdd65cb87 tools/gnulib: allow forced exclusion of functions after configure
Overriding variables used in both the macros and the headers
like setting REPLACE_FCNTL to 0 while invoking Make causes the
function aliases like rpl_fcntl() to not be defined,
however the object may still be built with the fnctl() function.

Usually this is enough for building while avoiding
the need to link the resulting libgnu library
to every single other build target for a project
in order to include the gnulib copy of the function,
because in these cases we don't care which version
of the function is used.

However for functions like fcntl() this doesn't work
as it is designed to use either the alias or standard declaration
from gnulib headers in order to be
a wrapper for the native host copy of fcntl()
by containing recursive calls to fcntl() within itself
after undefining the gnulib function declaration.

Overriding the variables used by the header when invoking Make
causes the header's declarations to be blocked,
and this results in the gnulib version of fcntl()
to call itself recursively and indefinitely
leading to segmentation faults.

Fix this by using macros defined with those variables
in order to exclude the function during preprocessing.

While at it, do the same for reallocarray()
so that the configure option --avoid=reallocarray
and Make variable REPLACE_REALLOCARRAY set to 0
would have a similar effect.

In the future this patch can be expanded to include
more functions and some version of this may be upstreamable.

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
Christian Marangi
368441254e
tools/fakeroot: update to 1.33
fakeroot (1.33-1) unstable; urgency=medium

  * New upstream version.
    - Patch from Samuel Thibault to add renameat2 support.
      closes: #1061257.

 -- Clint Adams <clint@debian.org>  Sun, 21 Jan 2024 11:56:06 -0500

fakeroot (1.32.2-1) unstable; urgency=medium

  * New upstream version.
    - Romanian man page translation from Remus-Gabriel Chelu.
      closes: #1055386.
    - patch from Rudi Heitbaum to add missing wrapped.h dependency.
      closes: #1041674.

 -- Clint Adams <clint@debian.org>  Mon, 06 Nov 2023 07:15:47 -0500

fakeroot (1.32.1-1) unstable; urgency=medium

  * New upstream version.
  * Updated German translation from Chris Leick.  closes: #1032206.
  * Patch from John Paul Adrian Glaubitz to add build profile to
    allow bootstrapping.  closes: #1040828.

 -- Clint Adams <clint@debian.org>  Wed, 12 Jul 2023 09:59:17 -0400

fakeroot (1.32-1) unstable; urgency=medium

  * New upstream version.

 -- Clint Adams <clint@debian.org>  Mon, 10 Jul 2023 09:14:43 -0400

fakeroot (1.31-1) unstable; urgency=medium

  * New upstream version.
    - patch from Johannes Schauer Marin Rodrigues to not use
      temporary file in chown test.  closes: #1026132.

 -- Clint Adams <clint@debian.org>  Mon, 06 Feb 2023 10:12:11 -0500

fakeroot (1.30.1-1) unstable; urgency=medium

  * New upstream version.
    - fixes and extends time64 support to fstatat64.
      closes: #1023286.

 -- Clint Adams <clint@debian.org>  Thu, 03 Nov 2022 15:04:55 -0400

fakeroot (1.30-1) unstable; urgency=medium

  * New upstream version.
    - tries to cope with time64 on 32-bit architectures.
      closes: #1023286.
  * Drop kludge for glibc 2.33.

 -- Clint Adams <clint@debian.org>  Wed, 02 Nov 2022 20:17:56 -0400

Link: https://github.com/openwrt/openwrt/pull/15746
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
2024-06-18 23:02:17 +02:00
Robert Marko
fcdc7da31c
tools: tar: update to 1.35
Instead of backporting select 1.35 fixes to make tar work for us, lets
update to 1.35 now that we have identified the upstream fix for macOS.

Signed-off-by: Robert Marko <robimarko@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/15743
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
2024-06-18 19:49:54 +02:00
Rosen Penev
253d777c96 tools/sparse: fix compilation with GCC14
Upstream backport.

Get rid of PKG_RELEASE as it's irrelevant to tools.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2024-06-16 22:40:42 +02:00
Nick Hainke
7a9b1f7f25 tools/pkgconf: update to 2.2.0
Changelog:
06120a8769/NEWS

Signed-off-by: Nick Hainke <vincent@systemli.org>
2024-06-14 15:27:39 +02:00
Tony Ambardar
546559587f
tools/dwarves: update to v1.27
Update to the latest upstream version and add a patch that enables pahole
reproducible builds if SOURCE_DATE_EPOCH is defined in the environment.

This patch helps avoid BTF-related module loading problems with packages
built separately from the kernel such as mac80211 or kselftests-bpf, e.g.:

    [   16.858856] BPF:      type_id=1185 bits_offset=0
    [   16.859099] BPF:
    [   16.859199] BPF: Invalid name
    [   16.859352] BPF:
    [   16.859612] failed to validate module [cfg80211] BTF: -22
    [   17.015178] PPP generic driver version 2.4.2
    [   17.052703] NET: Registered PF_PPPOX protocol family
    [   17.348722] BPF:      type_id=1185 bits_offset=0
    [   17.348912] BPF:
    [   17.348996] BPF: Invalid name
    [   17.349106] BPF:
    [   17.349220] failed to validate module [cfg80211] BTF: -22
    [   17.472070] kmodloader: 3 modules could not be probed
    [   17.473133] kmodloader: - cfg80211 - 0
    [   17.473762] kmodloader: dependency not loaded cfg80211
    [   17.474421] kmodloader: - mac80211 - 1
    [   17.474988] kmodloader: dependency not loaded mac80211
    [   17.475632] kmodloader: dependency not loaded cfg80211
    [   17.476263] kmodloader: - mac80211_hwsim - 2

    root@OpenWrt:/usr/libexec/kselftests-bpf# insmod bpf_testmod.ko
    [ 4735.776792] missing module BTF, cannot register kfuncs
    [ 4735.777371] missing module BTF, cannot register kfuncs
    [ 4735.777955] missing module BTF, cannot register kfuncs
    [ 4735.778452] missing module BTF, cannot register kfuncs

Release Notes: https://lore.kernel.org/bpf/ZmjBHWw-Q5hKBiwA@x1/

Signed-off-by: Tony Ambardar <itugrok@yahoo.com>
Link: https://github.com/openwrt/openwrt/pull/15697
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
2024-06-13 14:16:33 +02:00
Tony Ambardar
f97da2c61a
tools/elfutils: add missing MIPS reloc support
Backport an upstream patch series that adds backend elfutils support for
DWARF relocations in MIPS debug info. This support is needed by pahole to
generate BTF for modules in BTF-enabled kernel builds.

The problem first manifests as pahole warnings during build:

    BTF [M] lib/libcrc32c.ko
    die__process_unit: DW_TAG_compile_unit (0x11) @ <0x932d> not handled!
    die__process_unit: tag not supported 0x11 (compile_unit)!
    die__process: got compile_unit unexpected tag after DW_TAG_compile_unit!
    die__process_unit: DW_TAG_compile_unit (0x11) @ <0x99a3> not handled!
    die__process_unit: tag not supported 0x11 (compile_unit)!
    die__process: got compile_unit unexpected tag after DW_TAG_compile_unit!

During system boot the problem then causes module loading failures, which
may result in many other runtime issues:

    [   13.169785] kmodloader: loading kernel modules from /etc/modules.d/*
    [ ... ]
    [   17.422840] mac80211_hwsim: initializing netlink
    [   17.526518] PPP generic driver version 2.4.2
    [   17.550346] NET: Registered PF_PPPOX protocol family
    [   17.795353] kmodloader: 26 modules could not be probed
    [   17.796084] kmodloader: dependency not loaded nf_conntrack
    [   17.796737] kmodloader: - act_connmark - 1
    [   17.797402] kmodloader: dependency not loaded nf_conntrack
    [   17.798056] kmodloader: - act_ctinfo - 1
    [ ... ]

Link: https://lore.kernel.org/bpf/ZlkoM6%2FPSxVcGM6X@kodidev-ubuntu/
Signed-off-by: Tony Ambardar <itugrok@yahoo.com>
Link: https://github.com/openwrt/openwrt/pull/15697
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
2024-06-13 14:16:33 +02:00
Christian Marangi
95597dc2e3
tools: tar: backport patch for paxlib shipped in tar
Tar 1.34 ship an old version of paxlib with rtapelib.c that produce some
compilation warning. This library got updated in 1.35 but we still can't
use the new Tar version.

GCC 14 then made these compilarion warning errors.

Manually backport the fixes to rtapelib.c and patch the version shipped
in 1.34 to fix these compilation warning.

Fixes: #15692
Fixes: 2951e0a80e9f ("tools: tar: backport patches fixing broken --delete")
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
2024-06-12 15:16:58 +02:00
Christian Marangi
2951e0a80e
tools: tar: backport patches fixing broken --delete
In experimenting with --delete for APK handling, it was discovered that
--delete is broken and corrupts the TAR in some case.

This is fixed in version 1.35 but 1.35 introduce some problem with MacOS
making it difficult to bump. Backport the 2 required patches to fix this
problem so --delete is usable again.

Link: https://github.com/openwrt/openwrt/pull/15543
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
2024-06-11 23:58:14 +02:00
Nick Hainke
ac2722cb02 tools/ccache: update to 4.10.0
Release Notes:
https://ccache.dev/releasenotes.html#_ccache_4_10

Refresh patch:
- 100-honour-copts.patch

Signed-off-by: Nick Hainke <vincent@systemli.org>
2024-06-10 16:08:19 +02:00
Nick Hainke
712c10ec48 tools/findutils: update to 4.10.0
Release Notes:
https://savannah.gnu.org/news/?id=10638

Remove upstreamed patch:
- 010-endpwent.patch [0]

[0] - fa7e628e19

Signed-off-by: Nick Hainke <vincent@systemli.org>
2024-06-10 13:02:06 +02:00
Nick Hainke
3fd593b848 tools/cmake: update to 3.29.5
Changelog:
- https://www.kitware.com/cmake-3-29-1-available-for-download/
- https://www.kitware.com/cmake-3-29-2-available-for-download/
- https://www.kitware.com/cmake-3-29-3-available-for-download/
- https://www.kitware.com/cmake-3-29-4-available-for-download/
- https://www.kitware.com/cmake-3-29-5-available-for-download/

Signed-off-by: Nick Hainke <vincent@systemli.org>
2024-06-10 01:27:02 +02:00
Nick Hainke
10a1e9b44a tools/quilt: update to 0.68
Release Notes:
https://savannah.nongnu.org/news/?id=10611

Signed-off-by: Nick Hainke <vincent@systemli.org>
2024-06-09 21:23:28 +02:00
Michał Kępień
77106faa37 tools: remove kernel2minor
Since the Yafut tool is now used for both updating the kernel on
MikroTik devices with NAND flash and preparing firmware images for
MikroTik devices with NOR flash, remove the kernel2minor utility from
the tree as it is no longer used for anything.

Signed-off-by: Michał Kępień <openwrt@kempniu.pl>
Link: https://github.com/openwrt/openwrt/pull/13453
Signed-off-by: Robert Marko <robimarko@gmail.com>
2024-06-05 17:03:24 +02:00
Michał Kępień
a60721f2ed mikrotik: switch to Yafut for building MikroTik NOR images
The Yafut tool now has limited capabilities for working on filesystem
images stored in regular files.  This enables preparing Yaffs2 images
for devices with NOR flash using upstream Yaffs2 filesystem code instead
of the custom kernel2minor tool.

Since minimizing the size of the resulting filesystem image size is
important and upstream Yaffs2 code requires two allocator reserve blocks
to be available when writing a file to the filesystem, a trick is
employed while preparing an OpenWRT image: the blank filesystem image
that Yafut operates on initially contains two extra erase blocks that
are chopped off after the kernel file is written.  This is safe to do
because Yaffs2 has a true log structure and therefore only ever writes
sequentially (and the size of the kernel file is known beforehand).
While the two extra erase blocks are necessary for writes, Yaffs2 code
seems to be perfectly capable of reading back files from a "truncated"
filesystem that does not contain these extra erase blocks.

In terms of image size, this new approach is only marginally worse than
the current kernel2minor-based one: specifically, upstream Yaffs2 code
needs to write three object headers (each of which takes up an entire
data chunk) when the kernel file is written to the filesystem:

  - an object header for the kernel file when it is created,

  - an object header for the root directory when the kernel file is
    created,

  - an updated object header for the kernel file when the latter is
    fully written (so that its new size can be recorded).

kernel2minor only writes two of these headers, which is the absolute
minimum required for reading the file back.  This means that the
Yafut-based approach causes firmware images to be at most one erase
block (64 kB) larger than those created using kernel2minor, but only in
the very unfortunate scenario where the size of the kernel file is
really close to a multiple of the erase block size.

The rest of the calculations performed when the empty filesystem image
is first prepared stems from the Yaffs2 layout used by MikroTik NOR
devices: each 65,536-byte erase block contains 63 chunks, each of which
consists of 1024 bytes of data followed by 16-byte Yaffs tags without
ECC data; each such group of 63 chunks is then followed by 16 bytes of
padding, which translates to "-C 1040 -B 64k -E" in the Yafut
invocation.  Yaffs2 checkpoints and summaries are disabled (using
Yafut's -P and -S switches, respectively) as they are merely performance
optimizations that require extra storage space.  The -L and -M switches
are used to force little-endian or big-endian byte order (respectively)
in the resulting filesystem image, no matter what byte order the build
host uses.  The tr invocation is used to ensure that the filesystem
image is initialized with 0xFF bytes (which are an indicator of unused
space for Yaffs2 code).

Signed-off-by: Michał Kępień <openwrt@kempniu.pl>
Link: https://github.com/openwrt/openwrt/pull/13453
Signed-off-by: Robert Marko <robimarko@gmail.com>
2024-06-05 17:03:24 +02:00
Michał Kępień
7e2a3af8c4 tools: add Yafut to enable creating Yaffs filesystem images
The Yafut tool has so far been used to update the kernel on devices with
NAND flash via MTD character devices.  Recent upstream updates extended
the tool with limited support for working with filesystem images stored
in regular files.  This enables Yafut to be used for preparing a Yaffs
filesystem image for a device with NOR flash on a build host and
subsequently flashing it to the target device without using Yafut
itself.

Add Yafut to tools/ so that it can be compiled and run on the host
building OpenWRT.

Signed-off-by: Michał Kępień <openwrt@kempniu.pl>
Link: https://github.com/openwrt/openwrt/pull/13453
Signed-off-by: Robert Marko <robimarko@gmail.com>
2024-06-05 17:03:24 +02:00
Robert Marko
4454361e54 tools/elfutils: pass -O2 in HOST_CXXFLAGS
Trying to compile elfutils on Fedora 40 with GCC 14.1.1 will fail with:
/home/robimarko/Building/AX3600/qualcommax/staging_dir/host/bin/g++ -std=c++11 -D_GNU_SOURCE -DHAVE_CONFIG_H -DLOCALEDIR='"/home/robimarko/Building/AX3600/qualcommax/staging_dir/host/share/locale"'  -DDEBUGPRED=0 -DSRCDIR=\"/home/robimarko/Building/AX3600/qualcommax/build_dir/host/elfutils-0.191/src\" -DOBJDIR=\"/home/robimarko/Building/AX3600/qualcommax/build_dir/host/elfutils-0.191/src\" -I. -I..  -I../libgnu -I../libgnu -I. -I. -I../lib -I.. -I./../libelf -I./../libebl -I./../libdw -I./../libdwelf -I./../libdwfl -I./../libasm -I../debuginfod -I/home/robimarko/Building/AX3600/qualcommax/staging_dir/host/include  -std=c++11 -Wall -Wshadow -Wtrampolines -Wlogical-op -Wduplicated-cond -Wnull-dereference -Wimplicit-fallthrough=5 -Werror -Wunused -Wextra -Wstack-usage=262144   -D_FORTIFY_SOURCE=3  -c -o srcfiles.o srcfiles.cxx
In file included from /usr/include/c++/14/x86_64-redhat-linux/bits/os_defines.h:39,
                 from /usr/include/c++/14/x86_64-redhat-linux/bits/c++config.h:2521,
                 from /usr/include/c++/14/cstdlib:41,
                 from ../libgnu/gettext.h:56,
                 from ../libgnu/eu-config.h:62,
                 from ../config.h:2378,
                 from srcfiles.cxx:31:
/usr/include/features.h:414:4: error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp]
  414 | #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
      |    ^~~~~~~
cc1plus: all warnings being treated as errors

So, lets do as the error says and pass -O2 in HOST_CXXFLAGS like we already
do by default in HOST_CFLAGS.

Link: https://github.com/openwrt/openwrt/pull/15368
Signed-off-by: Robert Marko <robimarko@gmail.com>
2024-05-31 16:01:43 +02:00
Michael Pratt
5f47ccc0ea tools/elfutils: do not directly link gnulib to libelf
The compiled library resulting from importing gnulib has been
linked to libelf in order to easily cover other link dependencies.
However, this is not appropriate for linking libelf to other programs
as it bloats the resulting libelf library, and may result in
multiple defintions of symbols based on whether or not
certain modules from gnulib are included while elfutils
already has it's own definition of a function.

This is not a problem while building elfutils, because gnulib has
it's own way of creating function aliases and special declarations
that allow the linker to ignore the original function definitions,
however, when libelf is used to link to something else,
this results in an error at link time.

The gnulib manual recommended linking the libraries directly,
but those who have written it may not have considered how this
can affect the ability to link that library in other builds,
they likely assume the build targets would not be a dependency.

Fix this by removing the linking between gnulib and libelf
and instead overriding Make variables in order to add linking
between gnulib and each of the binaries provided by elfutils,
using Make functions to avoid applying it to other subdirectories.

The function tdestroy() would still be missing on macOS,
but the existence of the gnulib tsearch object having been built
is an indicator of whether or not it is needed
because it is only built conditionally by gnulib,
so include linking that object only when it exists.

Block the unnecessary replacement of some functions by gnulib
so that future linking with libelf doesn't require
the associated gnulib "rpl" prefixed functions.
These replacements are very strict in order to correct
minor bugs that don't have a real impact in almost all cases
or new standards requirements that are not yet in effect or used.

Tested-by: Georgi Valkov <gvalkov@gmail.com> # macOS
Signed-off-by: Michael Pratt <mcpratt@pm.me>
Link: https://github.com/openwrt/openwrt/pull/15368
Signed-off-by: Robert Marko <robimarko@gmail.com>
2024-05-31 16:01:43 +02:00
Michael Pratt
7822908bf3 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 <gvalkov@gmail.com> # macOS
Signed-off-by: Michael Pratt <mcpratt@pm.me>
Link: https://github.com/openwrt/openwrt/pull/15368
Signed-off-by: Robert Marko <robimarko@gmail.com>
2024-05-31 16:01:43 +02:00
Michael Pratt
37f20d8c34 tools/gnulib: unmangle fts header on macOS
The gnulib fts header is meant to not be overwritten
in any way by the host system's copy of fts.h
and was therefore given a unique name instead.

This is fine if the built libgnu library is directly linked
with the target library, but if we want to keep them isolated
we end up having the definitions being mangled anyway
when the next object to link against included the fts.h header.

On some macOS platforms, the use of __DARWIN_INODE64
is messing with the link name for fts functions, resulting in:

Undefined symbols for architecture x86_64:
  "_rpl_fts_close$INODE64", referenced from:
...

Create a local fts header for gnulib
that completely blocks the macOS host fts header.

An alternative and more upstream friendly fix would be
to rename fts_.h to fts.h and add the macOS-only
include guard to that file within it's own include guard,
but that would be a massive patch, so do this for now.

Tested-by: Georgi Valkov <gvalkov@gmail.com> # macOS
Signed-off-by: Michael Pratt <mcpratt@pm.me>
Link: https://github.com/openwrt/openwrt/pull/15368
Signed-off-by: Robert Marko <robimarko@gmail.com>
2024-05-31 16:01:43 +02:00
Nick Hainke
6f2244735f tools/mkimage: update to v2024.04
Update to latest version.

Refresh patches:
- 030-allow-to-use-different-magic.patch
- 095-tools-disable-TOOLS_FIT_FULL_CHECK.patch

Signed-off-by: Nick Hainke <vincent@systemli.org>
2024-05-29 10:43:50 +02:00
Rosen Penev
337b0c80cb
tools: refresh all patches
Refresh all tools patches now that tools/refresh correctly works.

CI now checks for them and actively complain if tools have unrefreshed
patches.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
[ reword commit message ]
Link: https://github.com/openwrt/openwrt/pull/15524
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
2024-05-23 11:49:03 +02:00
Rosen Penev
8097aa0b32
tools/lz4: remove patches
meson is used to build it since 291b137. No need to patch Makefiles.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/15524
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
2024-05-23 11:49:02 +02:00
Christian Marangi
01048c7456
tools/padjffs2: use Host/Prepare/Default instead of raw commands
Now that Host/Prepare/Default is always defined, we can use that instead
of using raw commands to move files from the src directory to
HOST_BUILD_DIR.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
2024-05-22 11:56:45 +02:00
Christian Marangi
46bcbe4223
tools/missing-macros: install files from HOST_BUILD_DIR instead of src
Install files from HOST_BUILD_DIR instead of src. These files are now
correctly copied to HOST_BUILD_DIR and can be referenced from there.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
2024-05-22 11:53:52 +02:00
Sean Khan
d03b567b66 tools: mold: update to 2.31.0
New:
- mold is now up to 10% faster when linking very large, debug
  info-enabled executables such as Blender (~1.8 GiB) or Clang (~3.8
  GiB), thanks to several improvements we've made to the string merging
  algorithm. (53ebcd8, d714301, 40f6b17, c9faf3d)
- -z start-stop-visibility=hidden is now supported so that
  linker-synthesized __start_<section-name> and __stop_<section-name>
  symbols can be completely hidden from other ELF modules. Previously,
  only -z start-stop-visibility=protected was supported. (99a5b15)
- -Bsymbolic-non-weak and -Bsymbolic-non-weak-functions options are now
  supported for compatibility with LLVM lld. Just like lld, these options
  control which symbols are exported as dynamic symbols.
  -Bsymbolic-non-weak makes the linker to export only weak symbols,
  whereas -Bsymbolic-non-weak-functions makes it to export only weak
  function symbols. (7d17aa8)

Bug fixes and compatibility improvements:

- Previously, if a linker script contains a newline character in the
  beginning four bytes of a file, it was not recognized as a linker
  script by mold. Now, mold allows newlines at the beginning of a file.
  (ea054cc)
- Under rare circumstances, the INPUT linker script command may have
  found a different file than GNU ld would. Now, mold's behavior aligns
  with GNU ld's. (163975d)
- Previously, the --repro option produced corrupted tar files. Now the
  bug has been fixed. (32c4a09)
- mold generally guarantees that its output is reproducible, meaning that
  if you run the linker with the exact same command line options and
  input files, the output is guaranteed to be bit-for-bit identical to
  the previous outputs. However, under rare circumstances, it might
  produce different output due to a bug. It's reported that this
  nondeterminism caused random crashes for some programs (#1247). This
  bug has been fixed. (6463a7c)
- mold no longer sets the address of the .text section as the entry point
  address if --entry option is not given, just like LLVM lld. (020b1a7)
- [RISC-V] __global_pointer$ symbol is now exported from executables as
  required by the processor-specific ABI. (3df7c8e)
- [ARM32] --long-plt option is now recognized as known option by mold.
  mold ignores the option, though, because the PLTs generated by our
  linker is always long. (d432e98)

Release Notes:
https://github.com/rui314/mold/releases/tag/v2.31.0

Signed-off-by: Sean Khan <datapronix@protonmail.com>
Link: https://github.com/openwrt/openwrt/pull/15403
Signed-off-by: Robert Marko <robimarko@gmail.com>
2024-05-09 10:45:29 +02:00
Felix Fietkau
c3d4598c01 tools: add more linux include files to fix x86 build on macos
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2024-05-07 12:50:27 +02:00
Christian Marangi
49a64c9541
tools: pkgconf: provide prefix for host and hostpkg stagind directory
Some package might require to fix their pkg-config file to point to host
or hostpkg file. This is the case for glib2 library that provides with
pkg-config variables, tools to generates files from xml. Those tools
should use the host binary instead of the targets one to correctly build
packages that makes use of such tools.

Link: https://github.com/openwrt/openwrt/pull/15134
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
2024-05-05 17:22:26 +02:00
Christian Marangi
a8bfdf2ed4
gengetopt: backport patch fixing support for c++17
Backport patch fixing support for c++17 that got merged upstream in
gengetopt.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
2024-05-01 15:45:25 +02:00
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: b6f025b42429 ("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
Fabrice Fontaine
ff59f3f4bd tools/expat: fix PKG_CPE_ID
cpe:/a:libexpat_project:libexpat is the correct CPE ID for expat:
https://nvd.nist.gov/products/cpe/search/results?keyword=cpe:2.3🅰️libexpat:libexpat

Fixes: c61a2395140d92cdd37d3d6ee43a765427e8e318 (add PKG_CPE_ID ids to package and tools)

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/15291
Signed-off-by: Robert Marko <robimarko@gmail.com>
2024-04-27 23:37:57 +02:00
Fabrice Fontaine
832460b452 tools/flex: fix PKG_CPE_ID
cpe:/a:westes:flex is the correct CPE ID for flex:
https://nvd.nist.gov/products/cpe/search/results?keyword=cpe:2.3🅰️westes:flex

Fixes: c61a2395140d92cdd37d3d6ee43a765427e8e318 (add PKG_CPE_ID ids to package and tools)

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2024-04-27 12:08:11 +02:00
Fabrice Fontaine
e9ecaade6f tools/zlib: fix PKG_CPE_ID
cpe:/a:zlib:zlib is the correct CPE ID for zlib:
https://nvd.nist.gov/products/cpe/search/results?keyword=cpe:2.3🅰️zlib:zlib

Fixes: c61a2395140d92cdd37d3d6ee43a765427e8e318 (add PKG_CPE_ID ids to package and tools)

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2024-04-27 12:07:37 +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