Commit Graph

2444 Commits (master)

Author SHA1 Message Date
Josef Schlehofer 1356b3ab32
tools/patch: update to 2.8.1
This fixes creating files outside of the working directory with a
crafted patch, a NULL pointer dereference on bad hunks and an infinite
loop on null ranges.

Fixes: CVE-2026-56288
Fixes: CVE-2026-56289
Fixes: CVE-2026-115207

Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/26210
Signed-off-by: Jonas Jelonek <jonas@jonasjelonek.de>
2026-11-03 12:30:15 +01:00
Daniel Golle a1788e6156 tools/sccache: add sccache Rust compiler cache
RUST_SCCACHE builds sccache 0.18.0 from a vendor tarball and makes it
the RUSTC_WRAPPER of the cargo builds of host tools, target packages
and libstd-rust. For target packages, scripts/rust-target-wrapper.sh
runs it in turn. The option sits next to CCACHE and is available with
any Rust toolchain of the build system. The packages feed defines
RUST_SCCACHE as well, without a dependency, and Kconfig merges both
definitions, so the tools and the cargo variables check for a Rust
toolchain once more.

sccache is built without default features: the local disk cache stays,
the remote storage backends and their HTTP and TLS stacks are left out,
so the build needs no host library. sccache needs rustc to build, so
the rustc build from source and the sccache build run unwrapped.

sccache keeps its cache and configuration in $(TOPDIR)/.sccache, or in
RUST_SCCACHE_DIR when set, and its server listens on a socket in
$(TMP_DIR), so that each tree has a server of its own. distclean
removes .sccache, and the SCCACHE_* variables of the environment are
unexported.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2026-10-30 12:06:08 +02:00
Daniel Golle 0508180cc7 tools/meson: add rust entry to meson cross file
Add target and native Rust compiler entries when a package includes
rust-values.mk. Its include guard tells, as the packages feed has a
rust-values.mk of its own, which python3-host.mk includes for every
Python package. The target entry carries the triple, CPU flags,
target-owned sysroot and standard-library linkage choice; native probes
use the host sysroot.

Supply bindgen with the toolchain sysroot and selected LLVM paths.
Register the target libstd build dependency and configuration inputs
for Rust consumers.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2026-10-30 12:06:08 +02:00
Daniel Golle 32f1c26eb6 build: add Rust package build helpers
Add rust-package.mk for target packages written in Rust. The Cargo
environment carries the target triple, CPU flags, the C and C++ flags
for cc-rs, the linker and the ABI-specific sysroot of libstd-rust,
while native build scripts and proc macros keep the host sysroot and
linker. Builds run in the crate's working directory with an explicit
target and offline from the vendor tarball; with a source tree override
(git-src, USE_SOURCE_DIR), which has none, Cargo fetches the locked
crates. Target packages depend on libstd-rust at build time and track
its configuration inputs for rebuilds.

rustc runs the linker with arguments of its own, without TARGET_LDFLAGS.
The linker selection and the -z options that hardening.mk and
package.mk set for every package are passed to rustc, for packages and
for libstd-rust.

When the target triple is the build host's, cc-rs takes the host
compiler for target C code as well. For that triple the C and C++
compiler of cc-rs is scripts/rust-cc-wrapper.sh, linked into
$(STAGING_DIR_HOST)/bin by tools/rust. It runs the target compiler with
the target flags for build scripts whose OUT_DIR lies in the target
triple's directory, and the host compiler for the others.

RUST_PREFER_DYNAMIC is available with any Rust toolchain, controls the
default userspace standard-library linkage and defaults to shared
linking. Packages can override it. Release builds use LTO either way;
rustc runs LTO next to -Cprefer-dynamic only with the unstable
-Zdylib-lto. RUST_PKG_DEPENDS carries the architecture dependencies
and, with shared linking, the libstd-rust runtime dependency. For
packages that keep the default, that dependency is conditional on
RUST_PREFER_DYNAMIC, as .config is not read while package metadata is
collected.

Release builds emit no unwind tables and take the size options of
unstable rustc that libstd-rust is built with: panics without location,
derived Debug output reduced to type names and, with
RUST_PANIC_IMMEDIATE_ABORT, -Cpanic=immediate-abort. Permitting unstable
options for every crate with RUSTC_BOOTSTRAP=1 changes the code of
dependencies: the build scripts of anyhow, thiserror and proc-macro2
then detect unstable features and use them.
scripts/rust-target-wrapper.sh, the RUSTC_WRAPPER of package builds,
adds the options, and -Zdylib-lto with a shared libstd, only to the
target crates cargo compiles, recognised by --target, -C metadata and
--error-format=json, and permits unstable options for that crate alone.
Build scripts and their probes see neither. A package keeps panic
locations with RUST_PKG_LOCATION_DETAIL:=1 and selects the Debug output
with RUST_PKG_FMT_DEBUG. None of this applies with CONFIG_DEBUG.
Packages build the release profile, as maturin, CMake and autotools
projects do, and CONFIG_DEBUG gives it the settings of the dev profile,
ahead of the profile settings of the package. Build paths are mapped out
of packages as out of libstd-rust.

Without a Rust toolchain of the build system, Rust packages build with
rust/host of the packages feed, which installs to $(STAGING_DIR)/host,
so that packages can move from the Rust support of the packages feed
one at a time. RUSTC and CARGO point there, there is neither a sysroot
of libstd-rust nor a shared libstd, the mips64 triples are those its
std is built for, and on the build host's triple the target linker is
set through the Cargo variable. The build dependencies, on libstd-rust
or rust/host, follow USE_RUST_TOOLCHAIN in the package metadata, also
for host builds through rust-host-build.mk. After a switch from None to
a Rust toolchain, the cargo of rust/host still comes first in PATH, so
the help of the toolchain choice names its clean-up.

The file is derived from lang/rust in the packages feed by Luca Barbato
and Donald Hoskins.

Reported-by: Andre Heider <a.heider@gmail.com>
Co-developed-by: Brian Redbeard <redbeard@dead-city.org>
Signed-off-by: Brian Redbeard <redbeard@dead-city.org>
Co-developed-by: Aditya Nugraha <vortexilation@gmail.com>
Signed-off-by: Aditya Nugraha <vortexilation@gmail.com>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2026-10-30 12:06:08 +02:00
Daniel Golle db310ff0fb libstd-rust: build and package the Rust standard library
Build the sysroot crate with the selected Cargo and rustc, using the
source tarball's vendored crates and shared target CPU flags. Stage the
rlibs and shared library through normal package-owned target staging,
and include that sysroot in the SDK.
Separate Cargo output by ABI identity to keep dependency artefacts from
different configurations in their own build directories.

Name the shared library and package ABI from compiler, source, target
and build configuration inputs, with configuration changes triggering
a rebuild. Declare libgcc as a runtime dependency for libgcc_s.so.1.

Release builds optimise for size, abort on panic and emit no unwind
tables. They also take the size options of unstable rustc, which the
sysroot build permits anyway: panics carry no location
(-Zlocation-detail=none) and derived Debug output is reduced to type
names (-Zfmt-debug=shallow). RUST_PANIC_IMMEDIATE_ABORT, on by default,
builds with -Cpanic=immediate-abort and without the panic-unwind
feature: a panic stops the program at once, without formatting a
message. rustc requires the same panic strategy for all crates of a
program, the standard library included, so this is a build-wide option.
Debug builds retain unwinding, panic messages and full Debug output.

Build paths are mapped out of the library as iremap in rules.mk does
for C, unless CONFIG_DEBUG is set without
CONFIG_REPRODUCIBLE_DEBUG_INFO. The map stays out of the inputs of the
ABI identity, which would otherwise depend on the build path.

rust-values.mk maps the OpenWrt target to its Rust target triple and CPU
flags; the mapping is derived from lang/rust in the packages feed by
Luca Barbato and Donald Hoskins. The mips64 ABI comes from
CONFIG_MIPS64_ABI, which every mips64 configuration sets, and n64 maps
to the muslabi64 and gnuabi64 triples. These are hard-float, so
soft-float mips64 with musl uses mips64-openwrt-linux-musl, the
soft-float n64 target of rustc, and the other soft-float mips64 and
mips64el configurations, which have no Rust target, get no Rust
packages. The e500v2 of mpc85xx has no FPU but shares the hard-float
powerpc triple, whose hard-float feature is turned off with
CONFIG_SOFT_FLOAT. When the target triple is the build host's, as for
x86_64 and aarch64 glibc targets, Cargo links build scripts with the
target linker as well but keeps target rustflags off them, so the target
linker is passed as a rustflag in that case.

include/scan.mk rescans the package metadata when an include/rust-*.mk
file changes, as for include/package*.mk.

Co-developed-by: Brian Redbeard <redbeard@dead-city.org>
Signed-off-by: Brian Redbeard <redbeard@dead-city.org>
Co-developed-by: Aditya Nugraha <vortexilation@gmail.com>
Signed-off-by: Aditya Nugraha <vortexilation@gmail.com>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2026-10-30 12:06:08 +02:00
Daniel Golle 0557493657 tools/corrosion: add corrosion-rs CMake-Cargo integration
Build corrosion-rs 0.5.1 from its GitHub release archive and install
its CMake modules into $(STAGING_DIR_HOST)/lib/cmake/Corrosion. CMake
projects use them through find_package(Corrosion) and
corrosion_import_crate(). USE_CORROSION is enabled by default with any
Rust toolchain.

With CMake 3.19 or later corrosion builds its generator only for
CORROSION_NATIVE_TOOLING, so the release archive is the whole source.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2026-10-30 12:06:08 +02:00
Daniel Golle 0ced767f14 tools/cbindgen: add cbindgen host tool
Build cbindgen 0.28.0 from a vendor tarball. cbindgen generates C
headers from Rust code and is needed by Mesa for the NIL and NAK
components of the Nouveau driver. USE_CBINDGEN is enabled by default
with any Rust toolchain.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2026-10-30 12:06:08 +02:00
Daniel Golle 84e70f447e tools/bindgen: add bindgen-cli host tool
Build bindgen-cli 0.73.2 from a vendor tarball. bindgen loads libclang
from the BPF LLVM toolchain: the prebuilt one unpacked into the source
tree, the one built by tools/llvm-bpf or the host LLVM. Versions before
0.72.1 generate opaque structures together with libclang 22 or newer,
which tools/llvm-bpf provides.

BUILD_BINDGEN is enabled by default with any Rust toolchain and selects
the built LLVM when neither the host nor the prebuilt LLVM is in use.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2026-10-30 12:06:08 +02:00
Daniel Golle 429ccec264 tools/rust: add Rust host compiler
Provide rustc, cargo, the host rust-std, rust-src and llvm-tools in
$(STAGING_DIR_HOST) in one of three ways. RUST_TOOLCHAIN_BUILD builds
them from the rustc source tarball with x.py. RUST_TOOLCHAIN_PREBUILT
installs the pinned components from static.rust-lang.org. For
RUST_TOOLCHAIN_HOST the components come from a relocatable toolchain on
the build host, which has to match the Rust version and is checked after
installation. The pinned components cover Linux hosts with glibc or
musl and macOS hosts, on x86_64 and aarch64; other hosts get an error
that names the host.

The choice sits in a "Rust toolchain options" menu of the developer
options, next to the external toolchain options and independent of
them. EXPERIMENTAL defaults to the prebuilt toolchain. As a Kconfig
choice resolves to none while its menu is hidden, USE_RUST_PREBUILT
carries that default in this case.

The xz2 crate of bootstrap is linked statically so that the compiler
needs no host liblzma at run time.

host-build.mk empties MAKEFLAGS for the build; x.py gets the jobserver
of make in MAKEFLAGS, so that bootstrap leaves the job count of ninja
and cargo to it, and one job when make runs without a jobserver.

The LLVM of a Rust release sinks the leading fence of a weak cmpxchg
into the reservation. On the e500v2 of mpc85xx the sync there clears
the reservation, so compare_exchange_weak loops never end. tools/rust
carries the LLVM change of rust/host in the packages feed, and on
mpc85xx the source build is the only choice and the default.

All three ways install into a prefix in one build directory, whose
prepared stamp depends on the choice, and the prefix is copied to
$(STAGING_DIR_HOST). As all three enable the same tool, the stamp of
the tools stage depends on the choice too. The installed files are
recorded in $(STAGING_DIR_HOST)/stamp and removed on clean and before
the next installation. The rust-installer metadata is removed from the
prefix: its manifests name absolute paths, which its uninstall.sh and
a later install.sh into the same prefix delete, those of the build
host's toolchain included.

Cargo reads .cargo/config.toml in every parent directory of its working
directory, and cargo and rustc take settings from the environment. The
build stops when such a file exists in TOPDIR or a parent directory,
and the CARGO, CARGO_* and RUST* variables of the environment are
unexported.

rust-values.mk holds the Rust version, the host triple, the hashes of
the pinned components and the Cargo home. The Cargo home is
$(STAGING_DIR_HOSTPKG)/cargo, shared by all targets, so that $(DL_DIR)
holds downloads only.

The xz2 and LLVM patches, the Rust build recipe and rust-values.mk are
derived from lang/rust in the packages feed by Luca Barbato and Donald
Hoskins.

Suggested-by: Andre Heider <a.heider@gmail.com>
Co-developed-by: Brian Redbeard <redbeard@dead-city.org>
Signed-off-by: Brian Redbeard <redbeard@dead-city.org>
Co-developed-by: Aditya Nugraha <vortexilation@gmail.com>
Signed-off-by: Aditya Nugraha <vortexilation@gmail.com>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2026-10-30 12:06:08 +02:00
Carsten Schuette 85398d134e mold: bump to 2.42.1
Update mold to 2.42.1

Changelog:
https://github.com/rui314/mold/releases/tag/v2.42.1

This is the last version of mold based on C++, newer versions are based
on Rust which needs different build systems.

Signed-off-by: Carsten Schuette <schuettecarsten@googlemail.com>
Link: https://github.com/openwrt/openwrt/pull/26188
Signed-off-by: Robert Marko <robimarko@gmail.com>
2026-10-26 09:33:59 +01:00
Paul Spooren de24245e08
build: read full blocks from pipes in image headers
Many image recipes write header fields with printf or echo piped into
dd bs=N count=1 conv=sync. Bash writes the output of both line
buffered, so a field holding a 0x0a byte reaches the pipe in two writes.
If dd reads between them, it gets a short block, pads it with zeros due
to conv=sync and stops due to count=1, so the rest of the field is
lost. This depends on the scheduling of the builder, and the rebuilder
has caught it in a ZNET header of the Zyxel WSM20:

  -00000000: 5a4e 4554 80cd 7900 530a 4132 530a 0000  ZNET..y.S.A2S...
  +00000000: 5a4e 4554 80cd 7900 530a 4132 530a 4132  ZNET..y.S.A2S.A2

Fields holding sizes, CRCs or MD5 sums hit this at random, e.g. in
elx-header, iodata-mstc-header2, seil-header or nec-fw. Text fields
only hit it if they contain a newline, but they use the same pattern.
dongwon-header had the same problem and no longer uses dd since
commit f6ef30a35e ("ath79: dongwon-header: don't read the CRC from a
pipe with dd").

Pass iflag=fullblock to every dd that reads such a pipe with count= or
conv=sync, so dd reads until the block is full or the input ends.
dd with bs=1 is left alone, as a read always returns a full block there.

iflag=fullblock is supported by GNU and uutils dd, like
oflag=seek_bytes already used in ramips. Build dd in tools/coreutils as
well, so hosts other than Linux get GNU dd next to the GNU date and
stat the images already need.

Link: https://github.com/openwrt/openwrt/pull/25897
Signed-off-by: Paul Spooren <mail@aparcar.org>
2026-10-14 18:40:19 +02:00
Yanase Yuki b050ce74d9 tools/libdeflate: update to 1.26
Changelog:
https://github.com/ebiggers/libdeflate/blob/v1.26/NEWS.md

Signed-off-by: Yanase Yuki <dev@zpc.st>
Link: https://github.com/openwrt/openwrt/pull/25894
Signed-off-by: Robert Marko <robimarko@gmail.com>
2026-10-14 18:10:01 +02:00
Daniel Golle 4e25209d0e tools: firmware-utils: add mkrkboot and mkhsfls
mkrkboot builds the Android boot image, with the Rockchip resource
image holding the device tree, that the U-Boot of the Rockchip RV11xx
camera SoCs boots.

mkhsfls packs the .FLS container accepted by the web interface of
Herospeed cameras.

Both are used by the image recipes of the rockchip/armv7 subtarget.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2026-10-13 10:58:21 +01:00
Yanase Yuki 9f2635e4b7 tools/expat: update to 2.9.0
Includes fixes for:
- CVE-2026-93990
- CVE-2026-102633
- CVE-2026-77214

Full changelog:
https://github.com/libexpat/libexpat/blob/R_2_9_0/expat/Changes

Signed-off-by: Yanase Yuki <dev@zpc.st>
Link: https://github.com/openwrt/openwrt/pull/25752
Signed-off-by: Nick Hainke <vincent@systemli.org>
2026-10-11 09:45:53 +02:00
Shiji Yang 24de657e0f tools/mkimage: update to version 2026.10
Update to the latest release. Adjust the `HOST_BUILD_DIR` directory
pattern to align with upstream changes. Out-of-sync server URLs have
also been removed[1].

[1] https://lore.kernel.org/u-boot/20261010142922.GI769217@bill-the-cat/

Signed-off-by: Shiji Yang <yangshiji66@outlook.com>
Link: https://github.com/openwrt/openwrt/pull/25783
Signed-off-by: Nick Hainke <vincent@systemli.org>
2026-10-11 09:40:27 +02:00
Felix Fietkau f3c75e3562 tools/elfutils: fix the build on macOS
The DEFAULT_INCLUDES override adds -I. to the src directory. There,
upstream deliberately clears DEFAULT_INCLUDES: with libc++, <format>
includes <stack>, which then resolves to the stack binary in src.

Leave out -I. for the src directory.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-08 09:50:39 +02:00
Ryan Leung 79bc56cb74 u-boot: add project's new download source
Das U-Boot project is transitioning their infrastructure [1],[2] and now publishes releases on their
GitLab [3]. Add it as the first download source and keep the existing sources which are currently
still available for historical releases.

Also update the U-Boot project web page [1] for the package URL and bump PKG_RELEASE for uboot-tools

[1]: https://lore.kernel.org/u-boot/20260511174116.GJ1858239@bill-the-cat/
[2]: https://lore.kernel.org/u-boot/20260727224922.GB1188@bill-the-cat/
[3]: https://git.u-boot-project.org/u-boot/u-boot/-/releases/

Signed-off-by: Ryan Leung <untilscour@protonmail.com>
Link: https://github.com/openwrt/openwrt/pull/25343
Signed-off-by: Robert Marko <robimarko@gmail.com>
2026-10-07 14:29:03 +02:00
Tianling Shen be0af59be9 tools/7z: update to 26.03
This version contains fixes for following CVEs:
- CVE-2026-48092
- CVE-2026-48095
- CVE-2026-48101
- CVE-2026-48102
- CVE-2026-48103
- CVE-2026-48104
- CVE-2026-48111
- CVE-2026-48112
- CVE-2026-14266
- CVE-2026-58052

Changelog: https://www.7-zip.org/history.txt

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
Link: https://github.com/openwrt/openwrt/pull/25597
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
2026-10-05 00:45:33 +02:00
Paul Spooren 1eaea67aef
tools/mtd-utils: make mkfs.ubifs images reproducible
UBIFS root file systems differ between builds, e.g. the one of the
Microchip SAMA7G5-EK: the superblock gets a random UUID, the inodes get
the ctime of the build host, which can't be reset with touch, and the
entries of each directory are added in readdir() order, which depends on
the host file system and decides inode numbers and layout.

Add a patch that, when SOURCE_DATE_EPOCH is set, uses a time-based
(version 1) UUID with that time and clamps all inode times to it. The
node ID of the UUID is taken from the new --uuid-node option, which the
image build sets from IMG_PART_DISKGUID, itself derived from
SOURCE_DATE_EPOCH and the kernel vermagic.
Directory entries are added sorted by name. Two trees with the same
contents but different ctimes and readdir() order now give identical
images; without SOURCE_DATE_EPOCH the UUID stays random.

Link: https://github.com/openwrt/openwrt/pull/25430
Signed-off-by: Paul Spooren <mail@aparcar.org>
2026-10-03 22:45:10 +02:00
Paul Spooren 3746b9b307
tools: firmware-utils: update to Git HEAD (2026-09-30)
fac587ee67d5 mkzynfw: add board profiles for Zyxel XGS2220 series
a0177f9b3bba mkzynfw: align RTL_OTTO_BOARD definitions
ceaf0f9c1e22 mksenaofw: warn instead of erroring on plain type-0 images
71f8d9a9a22a asusuimage: fix fs_offset extraction in show_info
9cf0f6e00e39 zyimage: make output byte order explicit
a1d9589f1ea1 dlink-sge-image: initialize the signature length

Link: https://github.com/openwrt/openwrt/pull/25517
Signed-off-by: Paul Spooren <mail@aparcar.org>
2026-10-01 20:29:41 +02:00
Josef Schlehofer 43ec1e56b4 tools/b43-tools: update to latest git HEAD
Update b43-tools to latest git commit 36284a5 (release b43-fwcutter-021).

Includes upstream commit 61105cc ("Makefiles: Declare source
prerequisites for object rules"), which fixes build failures on macOS
and systems where $< resolved to generated dependency prerequisites
rather than the source file.

Changes:
36284a5 fwcutter: Update release script
8690498 ci: Reduce flags
e23a1bb Align all CFLAGS
8440ca7 Add build CI
672a056 Use true instead of hardcoding /bin/true
7fd711a fwcutter: Bump version
61105cc Makefiles: Declare source prerequisites for object rules

Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/25500
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
2026-10-01 01:07:23 +02:00
Ivan Pavlov a5bc79c39b tools/elfutils: update to 0.196
To reduce the size of the downloaded source files, the version of tools library
has been aligned with the version used in the packages.

Release notes: https://inbox.sourceware.org/elfutils-devel/CAJDtP-QXj15OOpBxLdU+V1PZKM8YmnsE1eVy-R2R5xbE7Shk5A@mail.gmail.com/T/#u

Manually rebased patches:
 - 012-backport-mips-support-readelf.patch
 - 100-portability.patch

Removed patches:
 - 001-fix-backport-iquote-include.patch - fixed in [1]
 - 110-objects-manifest.patch - upstreamed

Include new submodule 'libdwfl_stacktrace' in makefile.
Changes from 8f920d2 are rolled back after fix [1]

1. https://sourceware.org/bugzilla/show_bug.cgi?id=33103

Fixes: 8f920d2f94
Signed-off-by: Ivan Pavlov <AuthorReflex@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/25388
Signed-off-by: Robert Marko <robimarko@gmail.com>
2026-09-29 09:27:40 +02:00
Robert Marko cec4e5acae tools: mkimage: refresh patches
Refresh mkimage patches, so that CI is happy.

Signed-off-by: Robert Marko <robimarko@gmail.com>
2026-09-28 14:12:42 +02:00
Massimo Mazzariol 6f684052de tools/mkimage: reject empty custom magic
Reject custom magic values when strtoull() does not parse any
digits, in addition to values outside the 32-bit uImage magic range.

Signed-off-by: Massimo Mazzariol <mazzariol.massimo@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/25288
Signed-off-by: Robert Marko <robimarko@gmail.com>
2026-09-25 10:05:04 +02:00
Massimo Mazzariol 36efe835fd tools/mkimage: validate custom magic range
strtoull() can parse values wider than the 32-bit uImage magic field.
Reject values above UINT32_MAX before assigning the parsed value to
params.magic.

Signed-off-by: Massimo Mazzariol <mazzariol.massimo@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/25288
Signed-off-by: Robert Marko <robimarko@gmail.com>
2026-09-25 10:05:04 +02:00
Massimo Mazzariol f9a75af743 tools/mkimage: support custom magic in dumpimage
OpenWrt's custom uImage magic patch makes legacy image verification use
params.magic instead of IH_MAGIC.

mkimage initializes this field, while dumpimage leaves it zeroed. This
causes dumpimage to reject valid legacy uImages using the standard
IH_MAGIC with FDT_ERR_BADMAGIC.

Initialize dumpimage's magic to IH_MAGIC so the normal verification path
works by default. Also add -M handling matching mkimage, allowing
dumpimage to verify and extract uImages built with a custom magic.

Tested with the patched U-Boot 2026.07 host tools. Standard-magic images
list and extract correctly, custom-magic images are accepted with the
matching -M value, and are rejected without it or with an incorrect
magic. Extracted payloads were verified byte-for-byte.

Fixes: #25287
Signed-off-by: Massimo Mazzariol <mazzariol.massimo@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/25288
Signed-off-by: Robert Marko <robimarko@gmail.com>
2026-09-25 10:05:04 +02:00
Robert Marko e4f2ae3b8d tools/cmake: pass testing option after bootstrap separator
Host/Configure/Default supplies the bootstrap "--" separator before
CMAKE_HOST_OPTIONS. Keep BUILD_TESTING with the CMake cache options so
it is passed after that separator, without introducing a second one.

Fixes: ddb23f3a02 ("tools/cmake: pass -DBUILD_TESTING=OFF to bootstrap")
Signed-off-by: Robert Marko <robimarko@gmail.com>
2026-09-23 16:57:43 +02:00
Josef Schlehofer ddb23f3a02 tools/cmake: pass -DBUILD_TESTING=OFF to bootstrap
Instead of carrying 100-no-testing.patch, pass -DBUILD_TESTING=OFF
directly to CMake's bootstrap script. This avoids refreshing the patch
on every CMake update.

The patch also changed the default in the installed CTest.cmake module.
Preserve that behavior by passing -DBUILD_TESTING=OFF by default in
cmake.mk for target and host builds. Packages can override it via
CMAKE_OPTIONS or CMAKE_HOST_OPTIONS.

OpenWrt never runs CMake tests, so building them only wastes build time.

This replaces the patch introduced in 8af80e79bd ("tools/cmake:
update to 3.17.0").

Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/24403
Signed-off-by: Robert Marko <robimarko@gmail.com>
2026-09-23 16:29:25 +02:00
Josef Schlehofer ad71bfef7e tools/cmake: pass zstd paths to bootstrap
Instead of carrying a patch (150-zstd-libarchive.patch) that modifies
Utilities/cmlibarchive/CMakeLists.txt to enable pkg-config search for
zstd, pass explicit staging library and include paths (-DZSTD_INCLUDE_DIR
and -DZSTD_LIBRARY) directly to CMake's bootstrap script.

ZSTD_INCLUDE_DIR and ZSTD_LIBRARY are the cache variables CMake itself
sets when --system-zstd is not used, so pre-seeding them guarantees that
CMake always links against OpenWrt's staging libzstd without requiring
a patch.

Fixes: 0e3d51ccae ("tools/cmake: fix compilation with host libzstd-dev")
Suggested-by: Michael Pratt <mcpratt@pm.me>
Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/24407
Signed-off-by: Robert Marko <robimarko@gmail.com>
2026-09-23 15:17:59 +02:00
Felix Fietkau d5c26afe33 tools/yafut: refresh patch
Refresh 100-honour-SOURCE_DATE_EPOCH.patch

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-09-23 11:58:39 +02:00
John Crispin 6eae1d6b77 tools: cache the configure results of eleven more autotools tools
Configure stage without a cache against a warm cache:

  mtools      3.34 s -> 0.28 s
  gengetopt   4.39 s -> 2.13 s
  fakeroot   10.97 s -> 8.73 s
  xz          4.32 s -> 2.17 s
  libressl    3.07 s -> 1.46 s
  flex       12.32 s -> 10.98 s
  expat       2.74 s -> 1.52 s
  bc          1.34 s -> 0.38 s
  dosfstools  3.13 s -> 2.54 s
  libtool     2.86 s -> 2.29 s
  mtd-utils   4.06 s -> 3.56 s

flex, fakeroot, dosfstools and mtd-utils run autoreconf in the same
stage, and the cache does not reach that part.

Each of the eleven configures the same way with a warm cache as it does
without one: the check configures three times, without a cache, with a
cold cache and with a warm cache, and every generated file of the first
and the last run is identical. A static scan of each configure script
found no cache check that changes CFLAGS, CPPFLAGS, LDFLAGS or LIBS
without restoring it.

patchelf, mklibs and automake pass the same check but gain less than
half a second, so they stay out.

make world after make tools/clean now takes 121 s against 177 s with
cold caches.

Signed-off-by: John Crispin <john@phrozen.org>
2026-09-22 20:29:59 +02:00
John Crispin 37f7186e75 tools/sparse: build in parallel
sparse set PKG_BUILD_PARALLEL, which a host build does not read, so it
built with one job. Use HOST_BUILD_PARALLEL: 6.6 s -> 1.3 s.

It builds five times out of five with the job server, and each build
installs files that are identical to those of a serial build.

Signed-off-by: John Crispin <john@phrozen.org>
2026-09-22 20:29:59 +02:00
John Crispin c3447b76fe tools: build autoconf, automake, libtool, dosfstools and make-ext4fs in parallel
libtool      22.5 s -> 20.0 s
  dosfstools    6.0 s ->  4.8 s
  make-ext4fs   2.1 s ->  1.2 s
  automake      3.9 s ->  3.4 s
  autoconf      3.1 s ->  2.6 s

Each one builds five times out of five with the job server, and each
build installs files that are identical to those of a serial build.

Signed-off-by: John Crispin <john@phrozen.org>
2026-09-22 20:29:59 +02:00
John Crispin 0f05c481fd tools: pass the job server to the compile step of mtools, mkimage and lzma
host-build.mk clears MAKEFLAGS, so a custom Host/Compile that runs a bare
$(MAKE) builds with one job, whatever HOST_BUILD_PARALLEL says. mtools
sets the flag, but its compile step never used it.

Each of the three now passes $(HOST_JOBS), and mkimage and lzma set
HOST_BUILD_PARALLEL:

  mkimage  11.7 s -> 7.2 s
  mtools    8.3 s -> 4.8 s
  lzma      4.0 s -> 1.8 s

Each one builds five times out of five with the job server, and each
build installs files that are identical to those of a serial build.

Signed-off-by: John Crispin <john@phrozen.org>
2026-09-22 20:29:59 +02:00
John Crispin ec4768fbed yafut: use a reproducible timestamp
yaffsfs_CurrentTime() returns the wall clock, and Yaffs writes that value
to the access, modification and change time of every object header. The
RouterBOARD images of ipq40xx/mikrotik therefore differ on every build,
and so does the sysupgrade metadata checksum that follows them.

Add a patch that reads SOURCE_DATE_EPOCH, which the build already exports.

Tested with two images written one second apart. They are identical with
SOURCE_DATE_EPOCH set and differ without it.

Signed-off-by: John Crispin <john@phrozen.org>
2026-09-22 18:46:30 +02:00
John Crispin cd322612cc tools: cache the configure results of ten autotools tools
These ten hold up the wall clock on their own. Their configure stages
run while nothing else does, because the tools build in dependency
order. Measured over a full build, cold cache against warm:

  sed        21.68 s -> 1.22 s
  m4         21.48 s -> 1.22 s
  findutils  19.47 s -> 1.56 s
  tar        17.75 s -> 1.47 s
  cpio       14.28 s -> 1.26 s
  bison      12.81 s -> 1.29 s
  patch      12.16 s -> 1.31 s
  elfutils   26.58 s -> 15.47 s

Each of the ten configures the same way with a warm cache as it does
without one. The check runs configure three times, without a cache, with
a cold cache and with a warm cache, and compares every file that
configure generates between the first and the last. ncurses fails that
check; these do not.

The only difference left is ac_ct_AR and ac_ct_RANLIB, which a cold run
fills through the fallback path of AC_CHECK_TOOL and a warm run leaves
empty. AR and RANLIB are correct in both, and no generated Makefile
reads the ac_ct_ form.

tools/cmake keeps its 33 s, the longest configure stage in the build. It
bootstraps with its own script rather than autoconf, so this does not
reach it.

Signed-off-by: John Crispin <john@phrozen.org>
2026-09-22 18:18:58 +02:00
John Crispin 3d597977b6 tools: build erofs-utils, mtd-utils and cpio in parallel
A tool builds with -j1 unless it sets HOST_BUILD_PARALLEL, and 45 of the
73 tools do not set it. These three gain the most from the job server on
a cold build of this tree:

  erofs-utils  23.11 s -> 15.73 s
  mtd-utils    11.70 s ->  6.42 s
  cpio          8.46 s ->  3.56 s

Each one builds three times out of three with the job server, and each
build writes a tree that is identical to the one a serial build writes.

Signed-off-by: John Crispin <john@phrozen.org>
2026-09-22 18:18:58 +02:00
Shiji Yang cce54a1d82 tools/xz: update to version 5.8.4
Release Notes:
https://github.com/tukaani-project/xz/releases/tag/v5.8.4

Signed-off-by: Shiji Yang <yangshiji66@outlook.com>
Link: https://github.com/openwrt/openwrt/pull/25295
Signed-off-by: Robert Marko <robimarko@gmail.com>
2026-09-21 13:28:13 +02:00
Wei-Ting Yang d0d8c40b67 tools/expat: update to 2.8.4
This version bump includes fixes for the following CVEs:
- CVE-2026-66046
- CVE-2026-72522
- CVE-2026-76641
- CVE-2026-76956
- CVE-2026-76957

Full release notes:
https://github.com/libexpat/libexpat/blob/master/expat/Changes

Signed-off-by: Wei-Ting Yang <williamatcg@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/25134
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
2026-09-12 16:49:17 +02:00
Andy Chiang f3f427048a tools: erofs-utils: update to 1.9.4
ChangeLog:
  https://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs-utils.git/tree/ChangeLog?h=v1.9.4

Build system: x86/64
Tested on: x86/64

Signed-off-by: Andy Chiang <AndyChiang_git@outlook.com>
Link: https://github.com/openwrt/openwrt/pull/24991
Signed-off-by: Robert Marko <robimarko@gmail.com>
2026-09-08 10:09:34 +02:00
Hannu Nyman 50258d2078 tools/cmake: update to version 4.4.3
Update cmake to version 4.4.3.
(No need for patch changes)

Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
Link: https://github.com/openwrt/openwrt/pull/25043
Signed-off-by: Robert Marko <robimarko@gmail.com>
2026-09-06 20:08:49 +02:00
Josef Schlehofer c0262ed5af tools: gnulib: remove stale gl_-prefixed macros from staging
Commit c820f097e0 ("tools: gnulib: install .m4 file with gl_ prefix")
installed gnulib autoconf macros under gl_-prefixed file names. The
scheme was later reverted in commit cda598a595, but the previously
installed files were never removed from share/aclocal.

As aclocal reads the whole directory, stale gl_*.m4 files can override
the current unprefixed macros. This breaks elfutils builds on macOS
after the gnulib stable-202507 update, resulting in empty #if
expressions in the generated ctype.h.

Remove the stale files in Host/Uninstall. Host/Install calls it first,
so affected build trees are cleaned up automatically on the next
gnulib reinstall.

Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/24759
Signed-off-by: Robert Marko <robimarko@gmail.com>
2026-08-19 19:46:46 +02:00
Luiz Angelo Daros de Luca 36946e2993 tools: firmware-utils: update to Git HEAD (2026-07-30)
df23826047c9 uimage_padhdr: improve error handling and cleanup
c9da48613b5d uimage_padhdr: add options to insert data into padding area

Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/24773
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
2026-08-19 01:19:54 +02:00
Peter Polonec 56c6654957 tools: zip: fix command injection in -T
[backport from Debian zip 3.0-16]
https://sources.debian.org/data/main/z/zip/3.0-16/debian/patches/fix-command-injection.patch

Info-ZIP 3.0 builds a shell command with the archive name when -T tests
an archive. A crafted archive name can inject additional shell commands.

Backport Debian's fix. Quote the archive name before it is added to the
test command.

Link: https://sintonen.fi/advisories/infozip-test-option-command-injection.txt
Signed-off-by: Peter Polonec <polonec.devel@pm.me>
Link: https://github.com/openwrt/openwrt/pull/24730
Signed-off-by: Robert Marko <robimarko@gmail.com>
2026-08-17 10:36:17 +02:00
Rosen Penev fc636dac86
tools/meson: update to 1.11.2
Remove upstreamed patch and refresh others.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/24560
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
2026-08-14 12:11:19 +02:00
Carsten Schuette dfa0a92172 mold: bump to 2.42.0
Update mold to 2.42.0

Changelog:
https://github.com/rui314/mold/releases/tag/v2.42.0

Signed-off-by: Carsten Schuette <schuettecarsten@googlemail.com>
Link: https://github.com/openwrt/openwrt/pull/24672
Signed-off-by: Robert Marko <robimarko@gmail.com>
2026-08-14 11:00:45 +02:00
Rosen Penev 5f144a7513 tools/sed: update to 4.10
Remove upstreamed patch.

Remove HOST_CONFIGURE_VARS. These are not needed any more.
ac_cv_search_setfilecon was removed completely and the others are guarded
by if test "$with_selinux" != no; then now.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/24572
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
2026-08-13 23:39:03 +02:00
Rosen Penev d70761c2e5 tools/isl: update to 0.28
Basic update. No patches.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/24573
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
2026-08-06 23:11:50 +02:00
Jack Sun ac61bc0a9c tools/cmake: update to 4.4.0
Release notes:https://cmake.org/cmake/help/latest/release/4.4.html

Refresh patches:
- 100-no-testing.patch
- 130-bootstrap_parallel_make_flag.patch
- 150-zstd-libarchive.patch
- 160-disable_xcode_generator.patch

Signed-off-by: Jack Sun <sunjiazheng321521@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/24324
Signed-off-by: Robert Marko <robimarko@gmail.com>
2026-08-04 21:40:38 +02:00
Paweł Owoc 9452d96721 tools: elfutils: fix uio header inclusion
Fixes arm64 build failures by replacing <linux/uio.h> with POSIX <sys/uio.h>
to avoid header redefinition conflicts.

gnulib's fcntl.h ends up including glibc's fcntl.h and fcntl-linux.h
which includes glibc's types/struct_iovec.h,
thats where the redefinition happens.

the lines that use <linux/uio.h> are antiquated and were never necessary.
it can be traced back to the original 2014 change that added the file with aarch64 support
in upstream commit 66637fa21044ac0058b25522f473669e73de328b

it was never necessary to use the linux header over the glibc headers,
as elfutils only needs the iovec struct and that struct was present since glibc 2.0 in the 1990s

Signed-off-by: Paweł Owoc <frut3k7@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/24539
Signed-off-by: Robert Marko <robimarko@gmail.com>
2026-08-04 09:17:53 +02:00