The main thread's thread_local destructors must finish before any
static destructor starts, but statics and atexit handlers registered
after the first thread_local was constructed ran first, because cross
builds of libstdc++ used their atexit-based fallback. Use the CRT's
__cxa_thread_atexit instead. On msvcrt that is only correct with
mingw-w64 a394c23a51, merged after v14.0.0, so backport it without its
Makefile.am change. Tested on Windows 11 and XP, x64 and x86. One XP
limitation is noted in the gcc patch header.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Stubs drop from ~117 KB to ~52 KB on x86 and from ~133 KB to ~51 KB on
x64, mostly by discarding unreferenced libuuid.a constants, and every
installer shrinks by as much. See the patch header for details.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
NSISdl compared WSAGetLastError() against EINPROGRESS and EWOULDBLOCK,
which mingw-w64's errno.h defines as the CRT's POSIX codes, so its
Winsock fallbacks never applied and no comparison could match. Every
NSISdl::download failed at once with "connecting to host", and fixing
only connect() leaves recv() closing the connection early. Patch all
five comparisons to use WSAEWOULDBLOCK.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
In busybox-w32, recursing into a bare drive such as C: walked the root
of the drive, while stat() treated C: as its current directory, so
"rm -rf C:" run in C:\some\dir deleted from the root of C:. cp, mv, ln,
install, find, grep -r, tar, chmod -R, du, diff -r, ls, wget -P,
mktemp -p and globs like C:* were affected too. Now C: is the drive's
current directory everywhere, as in Windows, and rm refuses it as it
refuses "." itself.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
man now looks in MANPATH and then the kit's share/man, formats pages
with the kit's nroff, finds target-prefixed names such as
x86_64-w64-mingw32-gcc under their base name, and pages through less -R.
less -R previously stripped SGR escapes. It now passes them through with
correct line widths and searching, so pages show bold and underline, and
so does colored output such as ls --color=always.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A small, self-contained roff formatter for BusyBox man to run in place
of groff. It covers what manual pages use: man(7), mdoc(7) and tbl, laid
out like groff and mandoc respectively. Over 98% of the lines in a
295,000-line corpus of real pages render identically to those tools. -w
lints a page, and it also formats pages that are not installed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Download the release instead of vendoring the amalgamated pkg-config.c,
and generate the amalgamation with its makefile. Also install its
manual page, and point make2compdb.c's credits at u-config itself.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
GCC 16 lowered the 32-bit cygming preferred stack boundary to 4 bytes,
and the i386 back end then places long long locals at 4-byte alignment
even though -malign-double, the default on these targets, makes
_Alignof(long long) 8. Such locals trap under -fsanitize=alignment.
Treat them as the back end already treats doubles.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With msvcrt, mingw-w64 defaults x86 to a 32-bit time_t, so ordinary
programs built today fail in January 2038. A new header patch makes
64-bit time_t the default, as with UCRT and MSVC, and everything in the
kit is built that way, including the kit's own tools. The 64-bit time
functions are emulated in libmsvcrt-os.a on top of XP-era imports, so
programs still run on Windows XP. Use _TIME_BITS=32 or
_USE_32BIT_TIME_T to opt out.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
libstdc++ implemented system_clock::now() with gettimeofday, whose
timeval has a long tv_sec, and long is 32 bits on Windows. Both
system_clock and steady_clock (derived from it on this target) would
overflow in January 2038 on x64 as well as x86, no matter how time_t is
configured. A new patch reads the system time directly, preferring
GetSystemTimePreciseAsFileTime as mingw-w64's gettimeofday does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
thrd_sleep, mtx_timedlock, and cnd_timedwait take a struct timespec,
whose layout follows time_t. libmingwex.a was compiled for 32-bit
time_t only, so x86 programs built with 64-bit time_t read garbage
timeouts. The plain names keep the 32-bit ABI so existing objects still
link correctly, and threads.h redirects 64-bit time_t callers to new
*64 variants. x64 is unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Without -M or --long, the zstd CLI refuses frames with windows over
128MiB, and some files in the wild now require --long=30. A new patch
adds a ZSTDCLI_DECOMPRESS_WINDOWLOG build option for the decompression
default, set to 31 in the x64 kit only. Compression defaults, and so
compatibility of produced files with other zstd builds, are unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fixes an nsExec::ExecToLog crash. makensis's default target now comes
from the build's TARGET_ARCH rather than its own pointer size, which
gives the same defaults here: amd64 in the x64 kit, x86 in the x86 kit.
Patches refreshed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Bug fixes, including cleanup of temporary response files on Windows,
storage helper lock compatibility with versions before 4.14, and GCC
profile data lookup for objects in subdirectories. Patches refreshed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Quilt.cpp now honors --strip-trailing-cr in QUILT_DIFF_OPTS, set in
src/quiltrc, so a refresh against a CRLF file produces an LF-only
patch, and push still applies it with the file's CRLF line endings.
NSIS's Source/build.cpp no longer needs its carriage returns stripped
before patching. The NSIS patches are refreshed accordingly.
This release also makes push --refresh honor QUILT_REFRESH_ARGS.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Quilt.cpp is now an ordinary external dependency, fetched as a release
tarball. A POSIX build replaces Debian's quilt for applying every patch
queue in the image, and the same build generates the amalgamation that
is compiled into quilt.exe and shipped as src/quilt.cpp, as before.
Before switching, every queue was pushed with both Debian's quilt and
Quilt.cpp against its pinned source, producing identical trees and
output.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
src/quiltrc fixes refresh output (no Index: lines or timestamps, a/ b/
prefixes, diffstat) so that every contributor produces identical
patches. src/README.md describes driving the queues with it, the policy
of refreshing a component's whole queue when its version changes, and
how gcc-final stacks on gcc.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gendef's one patch was a second queue pushed onto the mingw tree in the
gendef build stage. It now sits at the end of the mingw queue, so the
tree is patched once like every other component.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tugz provides gzip, unzip, and a new Info-ZIP compatible zip. Built from
the release amalgamations; gunzip and zcat are alias.c aliases of gzip,
which selects its mode by program name. It runs on Windows XP, looking
up Vista-era functions at run time.
With those applets disabled, BusyBox tar runs the external gzip/gunzip
for .gz, as it already does for zstd. A new patch swaps the internal
inflater, now unused, for a stub that execs gunzip.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
GDB waited with WaitForDebugEvent, so Windows converted
OutputDebugStringW strings to the inferior's ANSI code page first,
losing any character outside it. On Windows 10 and later, wait with
WaitForDebugEventEx instead, which opts in to Unicode strings, and
convert them from UTF-16 to the host charset.
WaitForDebugEventEx is looked up at runtime, so gdb.exe does not import
it and still runs on older Windows with the old behavior. gdbserver
shares the wait wrapper but does not opt in. Details in the patch
header.
Tested on Windows 10 and Windows XP.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The sed chain grew with each tweak and fails silently: a pattern that
misses leaves the default in place, a wildcard like CONFIG_FTP\w* may
catch symbols added by a future upstream, and kconfig quietly discards
values it rejects. List the overrides in src/busybox.config instead.
Kconfig keeps the first assignment of each symbol and ignores later
ones, so prepending the overrides to the stock defconfig makes them
win. After configuring, every override must appear verbatim in .config,
or the build fails and prints the ones that did not take (unknown
symbol, out-of-range value, unmet dependency).
The resulting .config is identical to the sed chain's for both x64 and
x86.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The busybox-w32 defconfig caps HISTSIZE at 1023 and defaults to 384,
which is cramped for desktop use. Nothing in the history code is worse
than linear. The one cost that scales with history is fork emulation:
each forkshell child of an interactive shell (command substitution,
subshell, pipeline stage) receives a copy of the in-memory history. At
10k entries that adds roughly 0.3 ms to a ~5 ms spawn. The cap itself
only sizes a fixed pointer array, so raising it is nearly free, and
the 1024 default stays well under 1% per fork.
Upstream Kconfig limits FEATURE_EDITING_HISTORY to 2000, and kconfig
treats out-of-range values as unset, so patch the range.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Without it GNU patch reads the final context line as incomplete, warns
"patch unexpectedly ends in middle of line", drops that line, and
reports fuzz 1 on the hunk. The hunk now applies with a plain offset.
This is the residual issue after 9d32fc5 fixed the file's line endings;
the leftover fuzz was the newline, not CRLF.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
"crossgcc" names a property both GCC builds share: /x-gcc is a plain
cross build and /gcc is a Canadian cross, so "cross" does not tell them
apart, and it points at the bootstrap compiler, which is the one queue
it does not apply to.
What separates the queues is reach. Both push onto the same tree, which
is never popped: src/gcc goes on before the bootstrap compiler and is
still applied when the shipped compiler configures, so it reaches both.
The second queue goes on top afterward and reaches only the compiler
that ships. Name it for that.
As a bonus the directories now sort in push order; crossgcc sorted
before gcc while being applied after it.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Move each component's patches from flat, prefixed file names into a
per-component directory with a quilt series file, dropping the number
prefixes: application order is now stated by series rather than
enforced by lexicographic glob expansion. Outside the build, a queue
is managed by our own quilt against an unpacked tarball from source/
with QUILT_PATCHES=/path/to/src/<component>. The shipped kit carries
the same layout under $W64DEVKIT_HOME/src, consumable by the bundled
quilt.exe the same way.
Inside the build, apply queues with Debian's original quilt rather
than a native build of src/quilt.cpp, whose amalgamation is
Windows-only. This keeps battle-tested GNU patch as the engine, and
makes every image build a conformance check: series semantics mean
whatever the reference implementation says, and a queue our clone
manages must be accepted by original quilt. The .pc state is removed
after each push because source trees are never popped, and a stale
.pc from one queue blocks pushing a second queue onto the same tree,
which happens twice: gcc then crossgcc, mingw then gendef.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
NSIS unconditionally builds ANSI stubs and plugin variants alongside
Unicode whenever the target CPU is x86, with no option to disable
them. ANSI installers are legacy compatibility w64devkit does not
need: makensis defaults to Unicode everywhere, and "Target x86-ansi"
fails cleanly with "adequate stub not found". This keeps the x86 kit
and the multilib kit's secondary x86 set Unicode-only, matching the
shape of the amd64 set.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Replace the loosely coordinated collection of x86 build arguments with
a single VARIANT selector. Define x64, x86, and multilib configuration
stages, then select the requested stage as the common cross-compiler
base. This keeps each supported configuration closed and prevents
callers from combining incompatible architecture settings.
Make x64 the default standalone profile. It targets
x86_64-w64-mingw32, disables GCC multilib support, builds only the
64-bit CRT, and omits the secondary 32-bit libraries and aliases.
Keep the standalone x86 behavior in its own profile. It targets
i686-w64-mingw32, retains the Pentium 4 default, enables only the
32-bit CRT, preserves the Windows XP header default and manifest
behavior, selects the 32-bit BusyBox and NSIS configurations, disables
zstd threading, and raises _WIN32_WINNT only while building CMake.
CMake and its bundled curl require at least Windows Vista APIs, so the
C and C++ flags continue to target Windows 7 without changing the
XP-oriented default of the installed toolchain.
Define multilib as an x86_64 compiler with GCC multilib enabled, both
CRT library sets installed, and the existing i686 forwarding aliases.
Use a dedicated EXTRA_32 setting for the secondary lib32 libraries,
winpthreads builds, thread support object, and aliases instead of
inferring that work from the spelling of a GCC configure option.
Expose independent CRT_LIB32 and CRT_LIB64 settings so each profile
selects exactly the runtime libraries it needs.
Pass the profile's CMake C and C++ flags directly rather than building
an optional argument list through shell positional parameters. Keep all
other profile-specific values next to the selected base stage, including
GCC architecture and manifest flags, BusyBox configuration, zstd
options, and NSIS target architecture.
Simplify multibuild.sh to pass only VARIANT to Docker. Add -m for the
multilib flavor, make -a build all three profiles, and remove the old
argument-file and Dockerfile-patch fallback paths. Update unsigned and
signed CI builds to select x64 or x86 directly, remove the obsolete
variant-x86.args bundle, and document the new build interface.
Verify all three profiles with docker build --check and complete cross
toolchain builds. Smoke-test x64 and x86 compilation, plus both the
64-bit compiler and i686 alias in the multilib profile. Also build the
x64 and x86 CMake targets to exercise both the empty and Windows 7
CMake flag configurations.
Hoist every variant-sensitive value into an ARG at the top of the cross
stage, with defaults producing the x64 kit, and gate the multilib-only
sidecar builds on MULTILIB. The x86 variant becomes a set of NAME=value
overrides in src/variant-x86.args, which multibuild.sh turns into
--build-arg options. A plain "docker build" continues to work untouched,
downloads stay shared between variants, and the patch mechanism remains
available as a fallback for a future variant needing structural changes.
One hazard of this approach: ARGs leak into the environment of every
subsequent RUN in the stage, and configure scripts read arbitrary
environment variables. mingw-w64-crt decides whether to build the Win64
runtime by testing whether a shell variable named LIB64 is merely set,
so an ARG of that name forced lib64 on past an explicit --disable-lib64.
Hence CRT_LIB64. Keep ARG names clear of names configure might consult.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The driver trusted argv[0], which requires a PATH search when it lacks
a directory component, as with w64devkit command aliases. Instead ask
Win32 for the true module path. Also search the driver's own directory
for subprograms, because as and ld live in bin/ rather than a tooldir.
Invoked by absolute path, the toolchain no longer needs its bin/ in
PATH, and remains relocatable.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- Windows path rewriting is now case-insensitive and Unicode-aware, and
ignore_headers_in_manifest matches case-insensitively on Windows.
- Detects C23 #embed directives and assembler .incbin directives,
preventing false cache hits.
- Removed the cpp_extension (CCACHE_EXTENSION) option; preprocessor
output is now processed in memory instead of via temporary files.
- Fixed a size overflow when allocating very large files on Windows.
Both Windows console output patches were regenerated against 4.14.
Ccache captures compiler diagnostics and writes them to the terminal
itself. Its Unix-style isatty and TERM checks do not reliably describe
Win32 console capabilities, and its byte-oriented output path cannot
preserve Unicode outside the active code page.
The color bug can be reproduced in a legacy console without virtual
terminal processing:
printf 'int main(void) { return undeclared; }\n' > error.c
TERM=cygwin ccache gcc -c error.c
The diagnostic contains literal escape sequences such as ?[01m?[K
instead of colored text.
The Unicode bug can be reproduced with a non-ASCII identifier:
printf 'float π(void) { return 3; }\nvoid f(void) { float unused = π(); }\n' > unicode.c
ccache gcc -Wall -Wextra -c unicode.c
ccache gcc -Wall -Wextra -c unicode.c
The source line emitted by ccache renders π as mojibake on both captured
and cached diagnostic output.
Add two ccache patches. The first detects native console handles with
GetConsoleMode, enables virtual terminal processing when available, and
otherwise translates supported SGR and erase-line sequences with Win32
console APIs. Redirected output remains unchanged.
The second decodes valid UTF-8 and writes non-ASCII text to native
consoles with WriteConsoleW. ASCII, invalid UTF-8, and redirected output
retain the existing byte-oriented path.
Apply both patches when building ccache.
Fixesskeeto/w64devkit#413.
Defining __trap_terminate_handler in vterminate.cc places it in the
same archive member as the verbose terminate handler, so the default
terminate handler dragged __cxa_demangle, __mingw_sprintf, and gdtoa
into every program that can throw, despite --disable-libstdcxx-verbose.
Define it in eh_term_handler.cc instead, alongside the initializer that
references it, so vterminate.o stays out of default links. A trivial
C++ program shrinks from 190K to 104K.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Message ids for .mc files that use a relative MessageId across a change
of Facility will change. See the patch for details.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Binutils 2.47 includes several fixes for PE-COFF weak external fixes
from 2e2848327d8f, afec39e439ea, and 65043894aaac. The last of these
fixes GCC PR124263 so gcc-contract-violation-handler is no longer
needed.
It also includes 18ca02157d9c, which automatically promotes oversized
PE-COFF objects to BigObj. The limit was also increased to the safe
limit for regular COFF in d9d09c878e56.
The debugger breakpoint path normalization fix landed upstream (as
cmSystemTools::ToNormalizedPathOnDisk), so drop the local patch.
cmake-force-ninja.patch is still needed.
CMake 4.4.0 bundles curl 8.20.0, whose curl_setup.h now hard-errors
if _WIN32_WINNT < 0x0600. CMake's bundled copy explicitly disables
curl's CURL_TARGET_WINDOWS_VERSION option (wrapped in "if(0) XXX
not needed for build within cmake"), so the flag has to reach C
compilation directly. Add CMAKE_C_FLAGS matching the existing
CMAKE_CXX_FLAGS override.
These functions are static emulations present in every libmsvcr*.a,
but the headers declare them dllimport (_CRTIMP), so callers reference
__imp__strtof_l and __imp__wcstof_l, which nothing defines, and the
link fails. Define fake import pointers alongside the definitions, as
already done for other statically-emulated functions such as
__acrt_iob_func and _initialize_onexit_table.
The _strtof_l half was merged upstream after v14.0.0 as 373c7dd0
("crt: Add missing __MINGW_IMP_SYMBOL for _strtof_l()"). The
_wcstof_l half is the same fix for the wide variant, which remains
broken upstream.
Teach libgomp's GFORTRAN probe to accept a target compiler name found
via PATH during the final canadian-cross build.
The configure test only used test -x on the first word of GFORTRAN,
which fails when it is passed as x86_64-w64-mingw32-gfortran plus flags.
Checking command -v in both configure.ac and the generated configure
script keeps FC enabled so libgomp installs the Fortran OpenMP/OpenACC
modules again.
With -fdeclone-ctor-dtor codegen emits a call-site reference for a
std::basic_string ctor that no callee under any configuration emits.
This bug first appeared in GCC 16.
libstdc++exp.a's default handle_contract_violation is marked weak so
users can supply their own. PE-COFF __attribute__((weak)) does not act
as an ELF-style fallback definition; it makes the symbol an alias for
some other (strong) definition. With no such definition the default
never resolves and -fcontracts -lstdc++exp fails to link.
Drop the weak attribute so the default is an ordinary strong symbol.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124263