1
0
mirror of https://github.com/skeeto/w64devkit.git synced 2026-10-24 17:39:18 +03:00

233 Commits

Author SHA1 Message Date
Christopher Wellons
5e7953184d Add missing trailing newline to libgomp-gfortran-path.patch
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>
2026-09-03 08:52:58 -04:00
Christopher Wellons
3e233990e0 Rename the crossgcc patch queue to gcc-final
"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>
2026-09-03 08:43:31 -04:00
Christopher Wellons
21a80a34a8 gdb: allow zero repeat count in artificial arrays 2026-09-03 08:18:44 -04:00
Christopher Wellons
0863bbaad7 gcc: Fix compound literals ICE
int g(){__builtin_strlen((static struct{char i,d[]}){0,0}.d);}

Via gardenweb.
2026-09-03 08:17:31 -04:00
Christopher Wellons
5179007b22 Manage patch queues with quilt series files
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>
2026-08-30 17:25:31 -04:00
Christopher Wellons
54c7887e6d Drop the ANSI stubs from x86 NSIS builds
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>
2026-08-30 13:13:16 -04:00
Peter0x44
2e424d7941 Replace variant arguments with build profiles
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.
2026-08-30 13:13:16 -04:00
Christopher Wellons
5daabd5683 Replace the variant patch with Dockerfile build args
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>
2026-08-30 13:13:16 -04:00
Peter0x44
47e0092d6d Fix i686 multilib tool aliases 2026-08-30 13:13:16 -04:00
Peter0x44
0f358cbe71 Default x86 Windows target version in headers 2026-08-30 13:13:16 -04:00
Christopher Wellons
58ad9865a5 Self-locate GCC driver so the toolchain works without PATH
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>
2026-08-27 20:59:35 -04:00
Christopher Wellons
af35517988 Upgrade to ccache 4.14
- 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.
2026-08-23 15:29:42 -04:00
Peter0x44
8611d4d242 Fixes for ccache output on Windows consoles
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.

Fixes skeeto/w64devkit#413.
2026-08-16 15:32:43 -05:00
Christopher Wellons
3c04ff709b Move trap terminate handler out of vterminate.cc
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>
2026-08-13 18:24:58 -04:00
Christopher Wellons
9d32fc517a Swap libgomp patch from CRLF to LF
The upstream source is LF so there is no reason for this to be CRLF.
2026-08-07 14:09:05 -04:00
Christopher Wellons
f53bfd0308 binutils: number windmc messages per facility
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>
2026-08-02 19:28:51 -04:00
Christopher Wellons
398961a84f binutils: carry windmc severity, facility forward
Fixes #409, closes #410.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-02 19:28:51 -04:00
Christopher Wellons
819813aec6 binutils: patch windmc to accept BOM (#408) 2026-08-01 14:52:56 -04:00
Peter0x44
d37cd99adc Drop patches Binutils 2.47 obsoleted
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.
2026-07-26 20:02:44 -05:00
Christopher Wellons
adadb3e9f5 Upgrade to CMake 4.4.0
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.
2026-07-21 09:09:14 -04:00
Christopher Wellons
9a11bb6f53 crt: __MINGW_IMP_SYMBOL for _strtof_l and _wcstof_l
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.
2026-07-10 20:24:08 -04:00
Peter0x44
995d9c68dc fortran libgomp fix patch
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.
2026-05-28 01:58:23 -04:00
Christopher Wellons
614fe39553 Introduce most of C11 threads
Closes #388.
2026-05-25 20:53:35 -04:00
Christopher Wellons
3dc8d3da44 gcc: Remove -fdeclone-ctor-dtor from -O[sz]
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.
2026-05-25 20:11:08 -04:00
Christopher Wellons
c55e415d2b gcc: Patch undefined handle_contract_violation #393
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
2026-05-25 08:42:28 -04:00
Christopher Wellons
7523c6755b busybox: Swap x86 to mingw32w_defconfig (#315) 2026-05-08 22:45:45 -04:00
Christopher Wellons
75ee239be7 Add NSIS 3.12 (makensis only)
Adds a CLI-only NSIS install for compiling .nsi scripts. Skips the
GUI wizards (makensisw, the NSIS installer creator) and documentation.

Path-resolution problem: makensis at $PREFIX/bin/makensis.exe would
auto-detect NSISDIR=$PREFIX (parent dir of bin), so NSIS would look
for $PREFIX/{Include,Stubs,Plugins,...} -- collides with w64devkit's
own $PREFIX/include on Windows's case-insensitive filesystem. Solve
by installing the real makensis under $PREFIX/share/nsis/bin/, where
auto-detection lands correctly on $PREFIX/share/nsis. A small alias
EXE at $PREFIX/bin/makensis.exe (built from the existing alias.c)
exec's it. Fully relocatable, no env vars.

New stages: dl-nsis, build-nsis. SCons + python3 only inside
build-nsis (not base) to avoid cache invalidation. TARGET_ARCH
derived from $ARCH at build time so the same Dockerfile works for
x64 and x86 -- no variant-x86.patch hunk needed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-08 22:44:05 -04:00
Christopher Wellons
b79f08a16b Upgrade to busybox-w32 FRP-6075
Drop busybox-005-disable-utf8-check.patch, now handled upstream.

Add a join.exe alias for the new join applet.

busybox-w32 gained crond and crontab applets, but I have decided to
disable them. It also gained a uuidgen applet, but we already have a
more complete, more appropriate implementation.

https://frippery.org/busybox/release-notes/FRP-6075.html
2026-05-07 13:32:50 -04:00
Christopher Wellons
ddc4c7f89e Move code-signing into the build pipeline
Sign every PE inside the toolchain (~250 .exe and .dll), pack, then
sign the resulting self-extracting archive. All signing runs at
docker run time so the bulk of the build remains fully cacheable
and secrets never enter image layers.

Stage layout:
- dl-aas-sign / build-aas-sign: SHA-pinned source tarball with
  vendored mbedtls + nlohmann/json, built with the base image's
  Debian gcc.
- final: assembly only (drop the trailing 7z + CMD).
- signed (new): COPY aas-sign + sign-and-pack.sh, CMD runs the
  script at docker run time. Reads AZURE_CLIENT_ID/TENANT_ID and
  the GitHub OIDC env vars from -e flags.
- pack (new, default target): RUN 7z + CMD cat sfx archive.
  Behaviorally identical to the old final.

The release workflow rebuilds --target signed for each arch
(reusing the same GHA cache scope as the unsigned pack build),
then docker runs the image to produce the signed package on
stdout.
2026-05-03 11:10:55 -04:00
Peter0x44
18e17fdf54 Upgrade to GCC 16.1.0
Bumps GCC from 15.2.0 and adjusts the build for the new release:

- Drop the obsolete stdcall-align patch, no longer needed.

- Configure with --enable-tls so libstdc++ uses native Windows TLS
  rather than emutls. This is an ABI break: object files built with
  earlier w64devkit releases cannot be linked against new builds.

- Import gcc-dynamic-load-tzdb.patch (originally from
  redpanda-cpp/mingw-lite, by CyanoHao) so that libstdc++'s C++20
  std::chrono::current_zone() Windows backend resolves
  GetDynamicTimeZoneInformation at runtime via LoadLibrary/
  GetProcAddress. Without this, _WIN32_WINNT < 0x0600 builds fail
  to compile tzdb.cc.

- Add gcc-libgfortran-mapview.patch to replace the new
  MapViewOfFileExNuma call in libgfortran's caf_shmem with
  MapViewOfFileEx, which mingw-w64 declares for older Windows
  targets. NUMA_NO_PREFERRED_NODE makes the two calls equivalent,
  so no functional change.
2026-05-02 13:48:44 -04:00
Christopher Wellons
1f9d292f18 Update to dcmake 1.6.5
dcmake now sets _WIN32_WINNT internally, so drop the matching
define from variant-x86.patch for the dcmake build.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-14 10:59:14 -04:00
Christopher Wellons
f248170154 Update to dcmake 1.5.0
Now requires Windows 7 even more than before.
2026-04-11 17:35:08 -04:00
Christopher Wellons
b010e46fba ninja: Fix deps log recovery
In DepsLog::Load(), the file offset used for truncation-based recovery
was advanced past each record immediately after reading its bytes from
disk, but before validating the record's semantic correctness (e.g. the
path checksum or node-id range checks). When a record was structurally
complete but semantically invalid, recovery truncated the file to an
offset that included the bad record, so it was never removed.

This created an infinite cycle: every build would load the deps log, hit
the corrupt record, "recover" by truncating everything after it (but not
the record itself), then append new dependency records that would be
destroyed by the next build's recovery. The result was spurious rebuilds
on every invocation.

Move the offset update to the end of the loop body, after all validation
has passed. Now when a record fails validation, the offset still points
before it, and truncation correctly removes it.

(This patch has been submitted upstream.)
2026-04-11 16:25:16 -04:00
Christopher Wellons
dc1b730fc1 cmake: normalize breakpoint paths
The breakpoint manager normalizes incoming setBreakpoints paths with
GetActualCaseForPath, but SourceFileLoaded and GetBreakpoints use
paths from CollapseFullPath, which preserves whatever case the caller
provided.  On case-insensitive filesystems these can differ for the
same file, so the unordered_map keys do not match and breakpoints are
silently missed.

On macOS (HFS+) GetActualCaseForPath is a no-op, so the setBreakpoints
path passes through unmodified.  If the DAP client sends "Test.cmake"
but cmake was invoked with "cmake -P test.cmake", the breakpoint is
stored under "Test.cmake" while GetBreakpoints looks up "test.cmake".

On Windows GetActualCaseForPath *does* normalize, but only in
HandleSetBreakpointsRequest.  The breakpoint is stored under the
canonical "Test.cmake", while SourceFileLoaded and GetBreakpoints
still receive "test.cmake" from CollapseFullPath.  The keys disagree
from the opposite direction.

Add a NormalizePath helper and apply it in all three public entry
points so that every map key goes through the same transformation.
On non-Windows it uses GetRealPath (wrapping realpath(3), which
returns the actual filesystem case on macOS and resolves symlinks on
Linux).  On Windows the existing GetActualCaseForPath is retained.
2026-04-11 14:18:12 -04:00
Christopher Wellons
c4ee256cc2 Introduce quilt command (Quilt.cpp)
This is a primitive source control system for w64devkit, a C++ clone of
a classic, old-school tool still in some use today.
2026-04-05 22:03:30 -04:00
Christopher Wellons
4a6417c21e Introduce etc/ in the sysroot
This is where src/profile *really* belongs, and I have plans for more
etc/ entries.
2026-04-05 21:57:16 -04:00
Christopher Wellons
78f0e962e2 recycle: Use "full" paths and ignore special codes
SHFileOperationWhas has a subtle, easy-to-misuse interface that does not
follow its own documentation. It says FO_DELETE skips relative paths,
but that's definitely not the case at least on some versions of Windows.
2026-03-28 12:49:14 -04:00
Christopher Wellons
c05f24b368 Upgrade to Mingw-w64 14.0.0
https://www.mingw-w64.org/changelog/#v1400-2026-03-27
2026-03-27 12:19:25 -04:00
Christopher Wellons
75ee252f2b New command: recycle
Send files and folders to the recycle bin without confirmation.
2026-03-26 18:59:09 -04:00
Christopher Wellons
6d6cd37cbe ctags: Silence the annoying TOML warnings 2026-03-24 16:06:20 -04:00
Christopher Wellons
218fcb1c9a vim: Backport QML support 2026-03-23 21:38:27 -04:00
Christopher Wellons
f5e6fc4ae3 ctags: Fix trailing slash handling 2026-03-23 21:34:08 -04:00
Christopher Wellons
bc3805f83e ctags: Add QML tag support
I have my own personal use for this feature, so I'm including it.
2026-03-23 21:34:08 -04:00
Christopher Wellons
4b1706e4e3 Introduce zstd/unzstd commands
Threads are disabled in the x86 build because zstd uses Windows 7
threading features. Closes #358.
2026-03-23 21:00:55 -04:00
Christopher Wellons
1d10baf609 Switch to speed-oriented builds
Aliases remain small because size is important and they are already
maximum speed. The distribution is ~10MB (~22%) larger, but C++ builds
with this toolchain are ~25% faster.
2026-03-17 18:55:14 -04:00
Peter0x44
c9cfbde595 Build curses UI of CMake (ccmake) 2026-03-15 14:26:46 -04:00
Christopher Wellons
6c51423969 Upgrade to Binutils 2.46
https://lists.gnu.org/archive/html/info-gnu/2026-02/msg00006.html
2026-03-10 22:45:49 -04:00
Christopher Wellons
fa8d54d4e5 Break the build into independent stages
By breaking independent parts of the build into stages breaks implied
dependencies between those parts. A tool built later will not require
rebuilding when earlier unrelated tools are changed. That includes
upgrades to require new downloads. Most tools can be upgraded without
requiring unnecessary rebuilds.
2026-03-10 20:54:07 -04:00
Christopher Wellons
d8ee5fc502 Introduce CMake and Ninja
Unlike "standard" CMake, this build defaults to the Ninja generator and
w64dk toolchain without looking for Visual Studio.
2026-03-06 18:11:02 -05:00
Christopher Wellons
c5bb7fbc74 Add ccache to the distribution (#327) 2026-03-02 07:24:12 -05:00