diff --git a/projects/llvm.org/mingw-w64/package.yml b/projects/llvm.org/mingw-w64/package.yml new file mode 100644 index 0000000000..87fa311cb7 --- /dev/null +++ b/projects/llvm.org/mingw-w64/package.yml @@ -0,0 +1,184 @@ +# llvm-mingw: LLVM-based mingw-w64 cross-compiler toolchain. +# +# **Composition recipe** — wraps pantry's `llvm.org` (clang + lld +# + LLVM tools) with `mingw-w64.org` (Windows runtime: headers + CRT +# + winpthreads) to produce a self-contained from-source Windows +# cross-compiler. +# +# Build is trivial — just generates per-target driver scripts that +# shim clang with `--target=` + `--sysroot=`. +# All real compilation work happens upstream in the two component +# recipes. +# +# Previously this recipe vendored upstream mstorsjo/llvm-mingw's +# prebuilt tarballs. pkgx pantry policy is from-source over +# vendored — so we now compose pantry's own builds. See +# pkgxdev/pantry#13047 (mingw-w64.org runtime) for the runtime side. + +distributable: + url: https://github.com/mstorsjo/llvm-mingw/archive/refs/tags/{{ version.raw }}.tar.gz + strip-components: 1 + +versions: + github: mstorsjo/llvm-mingw + +platforms: + - linux/x86-64 + - linux/aarch64 + - darwin/x86-64 + - darwin/aarch64 + +dependencies: + llvm.org: '*' # clang + clang++ + lld-link + LLVM tools + mingw-w64.org: '*' # Windows runtime (headers + CRT + winpthreads) + +build: + dependencies: + gnu.org/coreutils: '*' # install(1), basename(1) + script: + # Generate per-target driver wrappers. Each - + # script is a thin shim around pantry's llvm.org tools, + # configured for the Windows target via `--target=` and pointed + # at mingw-w64.org's install for headers + libs. + - run: | + set -e + mkdir -p "{{prefix}}/bin" + MINGW="{{deps.mingw-w64.org.prefix}}" + LLVM="{{deps.llvm.org.prefix}}" + + for T in x86_64-w64-mingw32 aarch64-w64-mingw32; do + echo "── generating driver wrappers for $T ──" + + # Compiler drivers. clang/clang++/cpp are clang frontends; + # gcc/g++ are aliases that autotools / Makefiles often + # hardcode. + for ENTRY in "clang:clang" "clang++:clang++" "cpp:clang" \ + "gcc:clang" "g++:clang++"; do + DRIVER="${ENTRY%:*}" + REAL="${ENTRY#*:}" + cat > "{{prefix}}/bin/$T-$DRIVER" < "{{prefix}}/bin/$T-$DRIVER" <&1 || echo "(missing)" + ls -la "$CLANG_AARCH64" 2>&1 || echo "(missing)" + echo "── wrapper content ──" + cat "$CLANG_X86_64" + + # Cross-compile hello.c for both target arches. + - run: cp $FIXTURE hello.c + fixture: | + #include + int main(void) { + printf("Hello from native Windows cross-compile.\n"); + return 0; + } + - $CLANG_X86_64 -o hello-x86_64.exe hello.c + - $CLANG_AARCH64 -o hello-aarch64.exe hello.c + + # PE/COFF magic-byte check. + - | + for f in hello-x86_64.exe hello-aarch64.exe; do + case "$(head -c 2 "$f")" in + MZ) echo "$f: PE/COFF DOS header OK" ;; + *) echo "$f: NOT a PE binary"; exit 1 ;; + esac + done + + # Runtime check via wine — soft-skip when wine isn't on PATH. + - | + if command -v wine64 >/dev/null 2>&1; then + WINE=wine64 + elif command -v wine >/dev/null 2>&1; then + WINE=wine + else + echo "wine not available — compile + magic-check passed; skipping runtime test" + exit 0 + fi + + - echo "running hello-x86_64.exe under $($WINE --version)" + - out=$($WINE hello-x86_64.exe) + - 'echo "wine stdout: $out"' + - | + case "$out" in + "Hello from native Windows cross-compile.") echo "RUN PASS" ;; + *) echo "RUN FAIL: unexpected output"; exit 1 ;; + esac + +provides: + # x86_64 cross drivers + - bin/x86_64-w64-mingw32-clang + - bin/x86_64-w64-mingw32-clang++ + - bin/x86_64-w64-mingw32-cpp + - bin/x86_64-w64-mingw32-gcc + - bin/x86_64-w64-mingw32-g++ + - bin/x86_64-w64-mingw32-ld + - bin/x86_64-w64-mingw32-ar + - bin/x86_64-w64-mingw32-ranlib + - bin/x86_64-w64-mingw32-strip + - bin/x86_64-w64-mingw32-nm + - bin/x86_64-w64-mingw32-objdump + - bin/x86_64-w64-mingw32-objcopy + - bin/x86_64-w64-mingw32-windres + - bin/x86_64-w64-mingw32-dlltool + # aarch64 cross drivers (same set) + - bin/aarch64-w64-mingw32-clang + - bin/aarch64-w64-mingw32-clang++ + - bin/aarch64-w64-mingw32-cpp + - bin/aarch64-w64-mingw32-gcc + - bin/aarch64-w64-mingw32-g++ + - bin/aarch64-w64-mingw32-ld + - bin/aarch64-w64-mingw32-ar + - bin/aarch64-w64-mingw32-ranlib + - bin/aarch64-w64-mingw32-strip + - bin/aarch64-w64-mingw32-nm + - bin/aarch64-w64-mingw32-objdump + - bin/aarch64-w64-mingw32-objcopy + - bin/aarch64-w64-mingw32-windres + - bin/aarch64-w64-mingw32-dlltool + # Top-level PE-aware tooling (symlinks to llvm.org's tools) + - bin/lld-link + - bin/llvm-rc + - bin/llvm-cvtres