Skip to content

Attempt to fix cross-compilation (arm64-apple -> x86_64-w64-mingw32)#7811

Draft
twalker314 wants to merge 2 commits into
HandBrake:masterfrom
twalker314:mingw-applesi
Draft

Attempt to fix cross-compilation (arm64-apple -> x86_64-w64-mingw32)#7811
twalker314 wants to merge 2 commits into
HandBrake:masterfrom
twalker314:mingw-applesi

Conversation

@twalker314

@twalker314 twalker314 commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

Work in progress.

Part 1/N

contrib/lame/{P00-darwin-applesi-cross.patch => P00-mingw-applesi-cross.patch}
contrib: lame: fix patch name for cross compilation.
Build system:          arm64-apple-darwin25.3.0
Host system:           x86_64-w64-mingw32
Platform-specific patches are applied based on
the host system name, not the build system name.

Fixes:

set -e; /bin/mkdir -p ./contrib/lame/lame-3.100/; cd ./contrib/lame/lame-3.100/; CC=/opt/homebrew/bin/x86_64-w64-mingw32-gcc CFLAGS="-I/Users/timothy/excluded/handbrake/git-hub-hb/mingw-w64/contrib/include -std=gnu99 -mfpmath=sse -msse2 -mno-ms-bitfields -O3" CXX=/opt/homebrew/bin/x86_64-w64-mingw32-g++ CXXFLAGS="-I/Users/timothy/excluded/handbrake/git-hub-hb/mingw-w64/contrib/include -mfpmath=sse -msse2 -mno-ms-bitfields -O3" CPPFLAGS="-I/Users/timothy/excluded/handbrake/git-hub-hb/mingw-w64/contrib/include " LDFLAGS="-L/Users/timothy/excluded/handbrake/git-hub-hb/mingw-w64/contrib/lib " PKG_CONFIG_PATH="/Users/timothy/excluded/handbrake/git-hub-hb/mingw-w64/contrib/lib/pkgconfig:" ./configure --host=x86_64-w64-mingw32 --build=arm64-apple-darwin25.3.0 --prefix=/Users/timothy/excluded/handbrake/git-hub-hb/mingw-w64/contrib/ --disable-dependency-tracking --disable-shared --enable-static --disable-frontend
checking build system type... Invalid configuration `arm64-apple-darwin25.3.0': machine `arm64-apple' not recognized
configure: error: /bin/sh ./config.sub arm64-apple-darwin25.3.0 failed
make: *** [contrib/lame/.stamp.lame.configure] Error 1
time end: Sun Apr 12 13:30:29 2026
duration: 3 minutes, 15 seconds (195.52s)
result: �[31m�[1mFAILURE�[0m (code 2)

Platform-specific application logic seems to be in make/include/contrib.defs:

    ##
    ## target: patch
    ##
    $(1).PATCH.srcs = $$(sort $$(wildcard \
        $$($(1).src/)A??-*.patch \
        $$($(1).src/)P??-$$(HOST.system)*.patch ))

P00-darwin-applesi-cross.patch was added in 03bdef6

Not quite sure how it ever worked?

046eb04 introduced the current logic using $$($(1).src/)P??-$$(HOST.system)*.patch ))

@twalker314 twalker314 marked this pull request as draft April 12, 2026 13:38
@twalker314

Copy link
Copy Markdown
Contributor Author

I still have a linker issue at the end which I am not quite sure how to fix:

build.txt

/opt/homebrew/Cellar/mingw-w64/14.0.0/toolchain-x86_64/bin/x86_64-w64-mingw32-ld: ./contrib/lib/libfreetype.a(ftbzip2.o):ftbzip2.c:(.text+0x71): undefined reference to `BZ2_bzDecompressEnd'
/opt/homebrew/Cellar/mingw-w64/14.0.0/toolchain-x86_64/bin/x86_64-w64-mingw32-ld: ./contrib/lib/libfreetype.a(ftbzip2.o):ftbzip2.c:(.text+0x125): undefined reference to `BZ2_bzDecompress'
/opt/homebrew/Cellar/mingw-w64/14.0.0/toolchain-x86_64/bin/x86_64-w64-mingw32-ld: ./contrib/lib/libfreetype.a(ftbzip2.o):ftbzip2.c:(.text+0x357): undefined reference to `BZ2_bzDecompressEnd'
/opt/homebrew/Cellar/mingw-w64/14.0.0/toolchain-x86_64/bin/x86_64-w64-mingw32-ld: ./contrib/lib/libfreetype.a(ftbzip2.o):ftbzip2.c:(.text+0x3ae): undefined reference to `BZ2_bzDecompressInit'
/opt/homebrew/Cellar/mingw-w64/14.0.0/toolchain-x86_64/bin/x86_64-w64-mingw32-ld: ./contrib/lib/libfreetype.a(ftbzip2.o):ftbzip2.c:(.text+0x65e): undefined reference to `BZ2_bzDecompressInit'
collect2: error: ld returned 1 exit status
make: *** [libhb/hb.dll] Error 1
time end: Sun Apr 12 15:39:15 2026
duration: 25 minutes, 26 seconds (1526.97s)
result: �[31m�[1mFAILURE�[0m (code 2)

@bradleysepos

Copy link
Copy Markdown
Contributor

IIRC that patch was not originally intended for mingw, but for macOS Intel/Arm universal binaries.

Try configuring freetype with --without-bzip.

It is also required to target x86_64-w64-mingw32
hosts on Apple Silicon hardware, for example.
@twalker314

Copy link
Copy Markdown
Contributor Author

Building freetype without bzip allows the build to complete successfully indeed.

I would still like help to get to the cause of the issue if possible.

@sr55 sr55 added the Bug label May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

3 participants