1- # llvm- mingw: LLVM-based mingw-w64 cross-compiler toolchain.
1+ # llvm.org/ mingw-w64 — from-source LLVM mingw-w64 cross-compiler toolchain.
22#
3- # **Composition recipe** — wraps pantry's `llvm.org` (clang + lld
4- # + LLVM tools) with `mingw-w64.org` (Windows runtime: headers + CRT
5- # + winpthreads) to produce a self-contained from-source Windows
6- # cross-compiler.
3+ # Builds the COMPLETE llvm-mingw toolchain from source via upstream
4+ # mstorsjo/llvm-mingw's own build orchestration (`build-all.sh`):
5+ # - clang + lld + the LLVM binutils-equivalents
6+ # - the mingw-w64 runtime (headers + CRT + winpthreads)
7+ # - the LLVM runtimes for the Windows targets: compiler-rt builtins,
8+ # libunwind, libc++abi, libc++
9+ # - the per-target driver wrappers (install-wrappers.sh)
10+ # No vendored binaries — everything is compiled here.
711#
8- # Build is trivial — just generates per-target driver scripts that
9- # shim clang with `--target=<target>` + `--sysroot=<mingw-w64.org>`.
10- # All real compilation work happens upstream in the two component
11- # recipes.
12+ # Why inline (clang and all) rather than composing pantry's llvm.org: the
13+ # Windows-target runtimes must match the exact clang that builds them, and
14+ # pkgx dependency constraints can't "drift" to track that. Building the whole
15+ # toolchain from one source tree makes it internally consistent by
16+ # construction, and versioning to mstorsjo's releases (which pin the matching
17+ # llvm-project) means there's no LLVM-version dance to get wrong.
1218#
13- # Previously this recipe vendored upstream mstorsjo/llvm-mingw's
14- # prebuilt tarballs. pkgx pantry policy is from-source over
15- # vendored — so we now compose pantry's own builds. See
16- # pkgxdev/pantry#13047 (mingw-w64.org runtime) for the runtime side.
19+ # Compiled on the builder at pkgx's glibc floor, so the host-side driver
20+ # binaries run on old hosts with NO bklibcvenv seal. (Replaces the previous
21+ # approach of vendoring mstorsjo's prebuilt tarball; pantry policy is
22+ # from-source over vendored.)
23+ #
24+ # NOTE: this is a full LLVM build — long, by design. "Build time isn't the
25+ # end of the world to get it right."
1726
1827distributable :
19- url : https://github.com/mstorsjo/llvm-mingw/archive/refs/tags/{{ version.raw }}.tar.gz
28+ url : https://github.com/mstorsjo/llvm-mingw/archive/refs/tags/{{version.tag }}.tar.gz
2029 strip-components : 1
2130
2231versions :
2332 github : mstorsjo/llvm-mingw
2433
25- platforms :
26- - linux/x86-64
27- - linux/aarch64
28- - darwin/x86-64
29- - darwin/aarch64
30-
34+ # Runtime libs the host-side clang/lld link. Built at the 2.28 floor, so these
35+ # pkgx-built deps (all <= 2.28) satisfy it — pkgx supplies them via its runtime
36+ # env, no seal needed. linux-only (darwin links libSystem/libc++ from the OS).
3137dependencies :
32- llvm.org : ' *' # clang + clang++ + lld-link + LLVM tools
33- mingw-w64.org : ' *' # Windows runtime (headers + CRT + winpthreads)
38+ linux :
39+ gnu.org/gcc/libstdcxx : ^14 # libstdc++.so.6 + libgcc_s.so.1
40+ zlib.net : " *"
41+ facebook.com/zstd : " *"
3442
3543build :
3644 dependencies :
37- gnu.org/coreutils : ' *' # install(1), basename(1)
38- script :
39- # Generate per-target driver wrappers. Each <target>-<tool>
40- # script is a thin shim around pantry's llvm.org tools,
41- # configured for the Windows target via `--target=` and pointed
42- # at mingw-w64.org's install for headers + libs.
43- - run : |
44- set -e
45- mkdir -p "{{prefix}}/bin"
46- MINGW="{{deps.mingw-w64.org.prefix}}"
47- LLVM="{{deps.llvm.org.prefix}}"
48-
49- for T in x86_64-w64-mingw32 aarch64-w64-mingw32; do
50- echo "── generating driver wrappers for $T ──"
51-
52- # Compiler drivers. clang/clang++/cpp are clang frontends;
53- # gcc/g++ are aliases that autotools / Makefiles often
54- # hardcode.
55- for ENTRY in "clang:clang" "clang++:clang++" "cpp:clang" \
56- "gcc:clang" "g++:clang++"; do
57- DRIVER="${ENTRY%:*}"
58- REAL="${ENTRY#*:}"
59- cat > "{{prefix}}/bin/$T-$DRIVER" <<EOF
60- # !/bin/sh
61- exec "$LLVM/bin/$REAL" --target=$T --sysroot="$MINGW/$T" -fuse-ld=lld "\$@"
62- EOF
63- chmod 755 "{{prefix}}/bin/$T-$DRIVER"
64- done
65-
66- # Binutils-equivalent tools — LLVM ships replacements.
67- # Per-target aliases for autotools / Makefile compat.
68- for ENTRY in "ar:llvm-ar" "ranlib:llvm-ranlib" "strip:llvm-strip" \
69- " nm:llvm-nm" " objdump:llvm-objdump" " objcopy:llvm-objcopy" \
70- " windres:llvm-windres" " dlltool:llvm-dlltool" \
71- " ld:lld-link" ; do
72- DRIVER="${ENTRY%:*}"
73- REAL="${ENTRY#*:}"
74- cat > "{{prefix}}/bin/$T-$DRIVER" <<EOF
75- # !/bin/sh
76- exec "$LLVM/bin/$REAL" "\$@"
77- EOF
78- chmod 755 "{{prefix}}/bin/$T-$DRIVER"
79- done
80- done
81-
82- # Top-level convenience symlinks for format-specific LLVM tools.
83- # Build systems sometimes invoke these without a target prefix.
84- for TOOL in lld-link llvm-rc llvm-cvtres llvm-windres llvm-dlltool; do
85- if [ -e "$LLVM/bin/$TOOL" ]; then
86- ln -sf "$LLVM/bin/$TOOL" "{{prefix}}/bin/$TOOL"
87- fi
88- done
45+ cmake.org : " *"
46+ ninja-build.org : " *"
47+ git-scm.org : " *" # build-llvm.sh / build-mingw-w64.sh clone the sources
48+ python.org : " ~3.11" # LLVM's build tooling
49+ zlib.net : " *"
50+ facebook.com/zstd : " *"
51+ # no compiler dep declared on purpose: brewkit's default toolchain is
52+ # llvm, so the host bootstrap compiler is clang (cc/c++ shims → clang).
53+ env :
54+ # llvm-mingw builds per-target; we ship the x86_64 + aarch64 Windows
55+ # cross-compilers (the two brewkit CI cares about).
56+ TOOLCHAIN_ARCHS :
57+ - x86_64
58+ - aarch64
59+ # mstorsjo's orchestrator builds clang/lld, native compiler-rt, installs
60+ # the driver wrappers, builds the mingw-w64 runtime, then the Windows-target
61+ # compiler-rt + libunwind/libc++. Trim lldb + clang-tools-extra to the
62+ # cross-compiler essentials (still a full clang/lld build).
63+ script : ./build-all.sh "{{prefix}}"
64+ --disable-lldb
65+ --disable-lldb-mi
66+ --disable-clang-tools-extra
8967
9068test :
91- # Same end-to-end test as before: cross-compile hello.c for both
92- # target arches, verify PE/COFF magic, run x86_64 binary via wine.
9369 dependencies :
94- winehq.org : ' * '
70+ winehq.org : " * "
9571 env :
9672 WINEDEBUG : -all
9773 WINEDLLOVERRIDES : " mscoree=;mshtml="
9874 WINEPREFIX : $PWD/.wine
99- CLANG_X86_64 : " {{prefix}}/bin/x86_64-w64-mingw32-clang"
100- CLANG_AARCH64 : " {{prefix}}/bin/aarch64-w64-mingw32-clang"
10175 script :
102- # Diagnostics: confirm wrappers were generated + are executable.
103- - |
104- echo "── wrapper diagnostics ──"
105- ls -la "$CLANG_X86_64" 2>&1 || echo "(missing)"
106- ls -la "$CLANG_AARCH64" 2>&1 || echo "(missing)"
107- echo "── wrapper content ──"
108- cat "$CLANG_X86_64"
109-
110- # Cross-compile hello.c for both target arches.
76+ - x86_64-w64-mingw32-clang --version
11177 - run : cp $FIXTURE hello.c
11278 fixture : |
11379 #include <stdio.h>
114- int main(void) {
115- printf("Hello from native Windows cross-compile.\n");
116- return 0;
117- }
118- - $CLANG_X86_64 -o hello-x86_64.exe hello.c
119- - $CLANG_AARCH64 -o hello-aarch64.exe hello.c
120-
121- # PE/COFF magic-byte check.
122- - |
123- for f in hello-x86_64.exe hello-aarch64.exe; do
124- case "$(head -c 2 "$f")" in
125- MZ) echo "$f: PE/COFF DOS header OK" ;;
126- *) echo "$f: NOT a PE binary"; exit 1 ;;
127- esac
128- done
129-
130- # Runtime check via wine — soft-skip when wine isn't on PATH.
131- - |
132- if command -v wine64 >/dev/null 2>&1; then
133- WINE=wine64
134- elif command -v wine >/dev/null 2>&1; then
135- WINE=wine
136- else
137- echo "wine not available — compile + magic-check passed; skipping runtime test"
138- exit 0
139- fi
140-
141- - echo "running hello-x86_64.exe under $($WINE --version)"
142- - out=$($WINE hello-x86_64.exe)
143- - ' echo "wine stdout: $out"'
144- - |
145- case "$out" in
146- "Hello from native Windows cross-compile.") echo "RUN PASS" ;;
147- *) echo "RUN FAIL: unexpected output"; exit 1 ;;
148- esac
80+ int main(void) { printf("Hello from native Windows cross-compile.\n"); return 0; }
81+ - x86_64-w64-mingw32-clang -o hello-x86_64.exe hello.c
82+ - aarch64-w64-mingw32-clang -o hello-aarch64.exe hello.c
83+ - test "$(head -c 2 hello-x86_64.exe)" = "MZ"
84+ - test "$(head -c 2 hello-aarch64.exe)" = "MZ"
85+ - if ! command -v wine64 >/dev/null 2>&1; then exit 0; fi
86+ - test "$(wine64 hello-x86_64.exe | tr -d '\r')" = "Hello from native Windows cross-compile."
14987
15088provides :
151- # x86_64 cross drivers
15289 - bin/x86_64-w64-mingw32-clang
15390 - bin/x86_64-w64-mingw32-clang++
154- - bin/x86_64-w64-mingw32-cpp
15591 - bin/x86_64-w64-mingw32-gcc
15692 - bin/x86_64-w64-mingw32-g++
157- - bin/x86_64-w64-mingw32-ld
15893 - bin/x86_64-w64-mingw32-ar
15994 - bin/x86_64-w64-mingw32-ranlib
16095 - bin/x86_64-w64-mingw32-strip
@@ -163,13 +98,10 @@ provides:
16398 - bin/x86_64-w64-mingw32-objcopy
16499 - bin/x86_64-w64-mingw32-windres
165100 - bin/x86_64-w64-mingw32-dlltool
166- # aarch64 cross drivers (same set)
167101 - bin/aarch64-w64-mingw32-clang
168102 - bin/aarch64-w64-mingw32-clang++
169- - bin/aarch64-w64-mingw32-cpp
170103 - bin/aarch64-w64-mingw32-gcc
171104 - bin/aarch64-w64-mingw32-g++
172- - bin/aarch64-w64-mingw32-ld
173105 - bin/aarch64-w64-mingw32-ar
174106 - bin/aarch64-w64-mingw32-ranlib
175107 - bin/aarch64-w64-mingw32-strip
@@ -178,7 +110,9 @@ provides:
178110 - bin/aarch64-w64-mingw32-objcopy
179111 - bin/aarch64-w64-mingw32-windres
180112 - bin/aarch64-w64-mingw32-dlltool
181- # Top-level PE-aware tooling (symlinks to llvm.org's tools)
113+ # don't want to grab these.
114+ # - bin/clang
115+ # - bin/clang++
182116 - bin/lld-link
183117 - bin/llvm-rc
184118 - bin/llvm-cvtres
0 commit comments