Skip to content

new(mingw-w64.org): Windows runtime libs (headers + CRT + winpthreads) — from source#13047

Merged
jhheider merged 10 commits into
pkgxdev:mainfrom
tannevaled:new/mingw-w64-runtime
May 30, 2026
Merged

new(mingw-w64.org): Windows runtime libs (headers + CRT + winpthreads) — from source#13047
jhheider merged 10 commits into
pkgxdev:mainfrom
tannevaled:new/mingw-w64-runtime

Conversation

@tannevaled
Copy link
Copy Markdown
Contributor

Pure Windows runtime (headers + CRT + winpthreads), built from source for x86_64 + aarch64 targets. NOT a compiler — just the target-side libs.

Cross-compiled using pantry's existing llvm.org clang (--target=*-w64-mingw32).

Companion to #12984 which will be refactored to compose this runtime + pantry's llvm.org into the full Windows cross-toolchain (instead of vendoring upstream's prebuilt llvm-mingw).

Pure runtime — Windows API headers, C runtime, and pthread emulation.
NOT a compiler; just the *target-side* libs that a Windows-targeting
clang/gcc needs to actually produce working .exe/.dll output. The
compiler itself comes from pantry's existing llvm.org (clang + lld).

Built from source for x86_64-w64-mingw32 + aarch64-w64-mingw32 using
pantry's llvm.org clang as the cross compiler (LLVM is multi-target
by default; --target=*-w64-mingw32 works natively).

Build order per target:
  1. mingw-w64-headers   — install only (.h files)
  2. mingw-w64-crt       — CRT compiled against headers from (1)
  3. winpthreads         — pthread emulation on top of (2)

Composed by llvm.org/mingw-w64 (separate recipe) which wraps clang
into per-target driver scripts (x86_64-w64-mingw32-clang, etc.).

This replaces the previous vendored-tarball approach of
llvm.org/mingw-w64 — pkgx pantry policy is from-source over
vendored binaries.
…ses)

Upstream `mingw-w64/mingw-w64` only publishes git tags (v9.0.0,
v10.0.0, ... v14.0.0) — no GitHub releases. Default `github:` mode
queries the releases endpoint first and falls back to tags, but the
fallback wasn't producing entries in CI.

Force tags mode explicitly via `github: mingw-w64/mingw-w64/tags`
and add `strip: - /^v/` to drop the v prefix.

Fixes "no versions parsed" failure on all 4 CI runners.
CRT configure failed with "Please check if the mingw-w64 header set
and the build/host option are set properly." — it probes `<windows.h>`
via CC, but clang had no sysroot pointing at the just-installed
headers.

Re-order: install headers first, THEN export CC/CXX with
`--sysroot={{prefix}}/$T` so the cross-compiler can find them.
Matches what llvm-mingw upstream does.
Headers + CRT now build cleanly with --sysroot, but winpthreads
failed at the resource-compile step:

  libtool: error: unrecognised option: '-i'

libtool needs RC set so it recognises the windres-compile path
through its wrapper. Add `export RC=llvm-windres` (and WINDRES for
configure-script consistency).
winpthreads' version.rc includes <winver.h> from the mingw-w64
headers. CC --sysroot handles regular C compiles, but windres uses
its own include path — and without `-I`, it can't find winver.h:

  ../mingw-w64-libraries/winpthreads/src/version.rc:23:10:
    fatal error: 'winver.h' file not found

Pass RCFLAGS=-I{{prefix}}/$T/include to the winpthreads configure
so windres looks in the same place clang's sysroot does.
@tannevaled
Copy link
Copy Markdown
Contributor Author

Linux x86_64 + aarch64 both green on the latest commit — the from-source build works end-to-end (headers + CRT + winpthreads).

darwin x64 / darwin ARM64 fail but logs aren't API-accessible (self-hosted runners return 404). @jhheider could you paste the tail of the failing darwin job?

The Linux fix was 3-step:

  1. headers FIRST, then export CC/CXX with --sysroot={{prefix}}/$T (so CRT finds windows.h)
  2. export RC=llvm-windres (so libtool recognises rc-compile path)
  3. pass RCFLAGS=-I{{prefix}}/$T/include to winpthreads configure (so windres finds winver.h)

Darwin uses the same llvm.org toolchain (multi-target clang + llvm-windres etc.) and the same gnu.org/coreutils for install(1), so I'd expect the same recipe to work. Likely candidates if it doesn't:

  • BSD vs GNU tool difference somewhere
  • darwin clang's --sysroot handling for Windows targets
  • some configure probe that behaves differently under macOS host

Job URLs:

tannevaled and others added 5 commits May 29, 2026 22:31
winpthreads' libtool link step failed with:

  checking command to parse nm output from clang
    --target=x86_64-w64-mingw32 --sysroot=... object... failed
  make[2]: *** [libwinpthread.la] Error 1

because the host's GNU nm doesn't grok PE/COFF objects emitted by
clang's mingw32 target. Wire libtool to llvm-nm (which handles every
object format LLVM emits, including PE) plus the rest of the binutils
libtool probes — llvm-strip / llvm-objdump / llvm-objcopy — so we don't
hit the same wall again on the next libtool stage.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…F pipe

libtool's configure-time nm probe constructs a global_symbol_pipe
that, with llvm-nm on PE/COFF objects, ends up missing a filter
stage and emits `llvm-nm ... |  | sed ...` (double pipe → shell
syntax error). This only affects the shared (DLL) link path; the
static .a build never goes through that pipeline.

Switch winpthreads to --enable-static --disable-shared so we get
libpthread.a (which is what mingw-w64 consumers link against) and
sidestep the broken libtool nm-probe.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…test

darwin libtool installs the static winpthread as libwinpthread.lib
(PE-style .lib extension), not libpthread.a. linux libtool installs
libpthread.a. The build itself succeeds on both; only our verify
step rejected darwin output.

Accept either filename so the darwin job goes green.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@jhheider jhheider marked this pull request as ready for review May 30, 2026 04:20
@jhheider jhheider merged commit ff227d7 into pkgxdev:main May 30, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants