Something I've been working on lately is cross-compiling Wine for 32-bit Mac from newer 64-bit-only macOS versions (10.15 and newer). This should be especially useful for anyone packaging Wine for macOS.
The first part needed is a toolchain. Apple's last official toolchain to support targeting i386 is Xcode 9.4.1 and the 10.13 SDK, but this is unable to run on any OS newer than 10.14.
To fix this, I've created a hack that allows the Xcode 9.4.1 toolchain to be used on newer OSes: https://github.com/mrpippy/XcodeNueve
With the toolchain working, building i386 with it is now a cross-compile. Apple does not prefix the commands with the host triplet though (i.e. 'i386-apple-darwin'), which Wine seems to expect for cross-compiling.
Specifically, configure adds "-b <host triplet>" to TARGETFLAGS, causing winebuild to search for commands like ld and nm prefixed with that host triplet, which fails.
This is a patch which only sets that TARGETFLAGS when the host triplet appears in $CC. I'm open to a different approach to fixing this though.
Here's the command I use to configure, assuming the modified Xcode 9.4.1 is at /Applications/Xcode9.app:
DEVELOPER_DIR="/Applications/Xcode9.app" \ SDKROOT="/Applications/Xcode9.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk" \ ../configure --host=i386-apple-darwin \ --with-wine-tools=<path to wine64 build> --with-wine64=<path to wine64 build> \ CC="clang -arch i386" TARGETFLAGS="-m32"
Make also needs to be run with DEVELOPER_DIR and SDKROOT set. And this also works on Apple Silicon, just run with 'arch -x86_64'
Brendan Shanks (1): configure: Only set TARGETFLAGS when cross-compiling with host-prefixed tools.
configure.ac | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
Signed-off-by: Brendan Shanks bshanks@codeweavers.com --- configure.ac | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac index 3f1d50a4dfc..61e772b21b1 100644 --- a/configure.ac +++ b/configure.ac @@ -257,7 +257,11 @@ else fi if test -n "$host_alias" -a "$host_alias" != "$build_alias" then - TARGETFLAGS="-b $host_alias $TARGETFLAGS" + case "$CC" in + *$host_alias*) + TARGETFLAGS="-b $host_alias $TARGETFLAGS" + ;; + esac fi
dnl Check for flex
Did Xcode13 now break i386 targets?, as Xcode12 on my M1 Mac Mini had compiled i386 target wine for me when using MacOSX10.13.SDK
The proposed patch reminds me of a change to meson a while back that removed this as it caused issues on Linux when cross-compiling for other distros/archs.
On Thu, Oct 21, 2021 at 1:15 AM Brendan Shanks bshanks@codeweavers.com wrote:
Something I've been working on lately is cross-compiling Wine for 32-bit Mac from newer 64-bit-only macOS versions (10.15 and newer). This should be especially useful for anyone packaging Wine for macOS.
The first part needed is a toolchain. Apple's last official toolchain to support targeting i386 is Xcode 9.4.1 and the 10.13 SDK, but this is unable to run on any OS newer than 10.14.
To fix this, I've created a hack that allows the Xcode 9.4.1 toolchain to be used on newer OSes: https://github.com/mrpippy/XcodeNueve
With the toolchain working, building i386 with it is now a cross-compile. Apple does not prefix the commands with the host triplet though (i.e. 'i386-apple-darwin'), which Wine seems to expect for cross-compiling.
Specifically, configure adds "-b <host triplet>" to TARGETFLAGS, causing winebuild to search for commands like ld and nm prefixed with that host triplet, which fails.
This is a patch which only sets that TARGETFLAGS when the host triplet appears in $CC. I'm open to a different approach to fixing this though.
Here's the command I use to configure, assuming the modified Xcode 9.4.1 is at /Applications/Xcode9.app:
DEVELOPER_DIR="/Applications/Xcode9.app" \ SDKROOT="/Applications/Xcode9.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk" \ ../configure --host=i386-apple-darwin \ --with-wine-tools=<path to wine64 build> --with-wine64=<path to wine64 build> \ CC="clang -arch i386" TARGETFLAGS="-m32"
Make also needs to be run with DEVELOPER_DIR and SDKROOT set. And this also works on Apple Silicon, just run with 'arch -x86_64'
Brendan Shanks (1): configure: Only set TARGETFLAGS when cross-compiling with host-prefixed tools.
configure.ac | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
-- 2.30.1 (Apple Git-130)
Brendan Shanks bshanks@codeweavers.com writes:
With the toolchain working, building i386 with it is now a cross-compile. Apple does not prefix the commands with the host triplet though (i.e. 'i386-apple-darwin'), which Wine seems to expect for cross-compiling.
Specifically, configure adds "-b <host triplet>" to TARGETFLAGS, causing winebuild to search for commands like ld and nm prefixed with that host triplet, which fails.
This is a patch which only sets that TARGETFLAGS when the host triplet appears in $CC. I'm open to a different approach to fixing this though.
It seems to me that this should be done the same way we do it on Linux: if we are on an x86_64 host and --enable-win64 is not specified, we add -m32 and set host_cpu=i386. Passing --host is not required in this configuration.
It seems to me that this should be done the same way we do it on Linux:
if we are on an x86_64 host and --enable-win64 is not specified, we add -m32 and set host_cpu=i386. Passing --host is not required in this configuration.
If the compile is being done via an Intel Mac that’s not required, when compiling via an Apple Silicon Mac just launching the session via Rosetta2 will allow you to skip setting -m32 & host_cpu.
On Thu, Oct 21, 2021 at 3:35 PM Alexandre Julliard julliard@winehq.org wrote:
Brendan Shanks bshanks@codeweavers.com writes:
With the toolchain working, building i386 with it is now a cross-compile. Apple does not prefix the commands with the host triplet though (i.e. 'i386-apple-darwin'), which Wine seems to expect for
cross-compiling.
Specifically, configure adds "-b <host triplet>" to TARGETFLAGS, causing winebuild to search for commands like ld and nm prefixed with that host triplet, which fails.
This is a patch which only sets that TARGETFLAGS when the host triplet appears in $CC. I'm open to a different approach to fixing this though.
It seems to me that this should be done the same way we do it on Linux: if we are on an x86_64 host and --enable-win64 is not specified, we add -m32 and set host_cpu=i386. Passing --host is not required in this configuration.
-- Alexandre Julliard julliard@winehq.org
On Oct 21, 2021, at 12:35 PM, Alexandre Julliard julliard@winehq.org wrote:
Brendan Shanks bshanks@codeweavers.com writes:
With the toolchain working, building i386 with it is now a cross-compile. Apple does not prefix the commands with the host triplet though (i.e. 'i386-apple-darwin'), which Wine seems to expect for cross-compiling.
Specifically, configure adds "-b <host triplet>" to TARGETFLAGS, causing winebuild to search for commands like ld and nm prefixed with that host triplet, which fails.
This is a patch which only sets that TARGETFLAGS when the host triplet appears in $CC. I'm open to a different approach to fixing this though.
It seems to me that this should be done the same way we do it on Linux: if we are on an x86_64 host and --enable-win64 is not specified, we add -m32 and set host_cpu=i386. Passing --host is not required in this configuration.
Thanks Alexandre, that does work correctly and without any changes needed. This patch can be disregarded.
For a WOW64 build, running configure like this works:
DEVELOPER_DIR="/Applications/Xcode9.app" \ SDKROOT="/Applications/Xcode9.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk" \ ../configure --with-wine64=<path to wine64 build>
Or for a standalone 32-bit build:
DEVELOPER_DIR="/Applications/Xcode9.app" \ SDKROOT="/Applications/Xcode9.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk" \ ../configure --with-wine-tools=<path to wine64 build>
Brendan
I’m still not getting why your using Xcode9 in this manner when. XCode10/11/12 compiled 32Bit wine without issue as long as SDKROOT is set to MacOSX10.13.SDK
On Thu, Oct 21, 2021 at 5:22 PM Brendan Shanks bshanks@codeweavers.com wrote:
On Oct 21, 2021, at 12:35 PM, Alexandre Julliard julliard@winehq.org
wrote:
Brendan Shanks bshanks@codeweavers.com writes:
With the toolchain working, building i386 with it is now a
cross-compile.
Apple does not prefix the commands with the host triplet though (i.e. 'i386-apple-darwin'), which Wine seems to expect for
cross-compiling.
Specifically, configure adds "-b <host triplet>" to TARGETFLAGS, causing winebuild to search for commands like ld and nm prefixed with that host triplet, which fails.
This is a patch which only sets that TARGETFLAGS when the host triplet appears in $CC. I'm open to a different approach to fixing this though.
It seems to me that this should be done the same way we do it on Linux: if we are on an x86_64 host and --enable-win64 is not specified, we add -m32 and set host_cpu=i386. Passing --host is not required in this configuration.
Thanks Alexandre, that does work correctly and without any changes needed. This patch can be disregarded.
For a WOW64 build, running configure like this works:
DEVELOPER_DIR="/Applications/Xcode9.app" \ SDKROOT="/Applications/Xcode9.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk" \ ../configure --with-wine64=<path to wine64 build>
Or for a standalone 32-bit build:
DEVELOPER_DIR="/Applications/Xcode9.app" \ SDKROOT="/Applications/Xcode9.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk" \ ../configure --with-wine-tools=<path to wine64 build>
Brendan
True, looks like even Xcode 13.1 RC is still able to build for i386 with the 10.13 SDK. For CrossOver though we build an i386 .app, which requires xcodebuild, etc. I would also prefer to stick with the toolchain that Apple tested/supported for i386 (and that we’ve already been using).
On Oct 21, 2021, at 2:27 PM, Dean Greer gcenx83@gmail.com wrote:
I’m still not getting why your using Xcode9 in this manner when. XCode10/11/12 compiled 32Bit wine without issue as long as SDKROOT is set to MacOSX10.13.SDK
On Thu, Oct 21, 2021 at 5:22 PM Brendan Shanks <bshanks@codeweavers.com mailto:bshanks@codeweavers.com> wrote:
On Oct 21, 2021, at 12:35 PM, Alexandre Julliard <julliard@winehq.org mailto:julliard@winehq.org> wrote:
Brendan Shanks <bshanks@codeweavers.com mailto:bshanks@codeweavers.com> writes:
With the toolchain working, building i386 with it is now a cross-compile. Apple does not prefix the commands with the host triplet though (i.e. 'i386-apple-darwin'), which Wine seems to expect for cross-compiling.
Specifically, configure adds "-b <host triplet>" to TARGETFLAGS, causing winebuild to search for commands like ld and nm prefixed with that host triplet, which fails.
This is a patch which only sets that TARGETFLAGS when the host triplet appears in $CC. I'm open to a different approach to fixing this though.
It seems to me that this should be done the same way we do it on Linux: if we are on an x86_64 host and --enable-win64 is not specified, we add -m32 and set host_cpu=i386. Passing --host is not required in this configuration.
Thanks Alexandre, that does work correctly and without any changes needed. This patch can be disregarded.
For a WOW64 build, running configure like this works:
DEVELOPER_DIR="/Applications/Xcode9.app" \ SDKROOT="/Applications/Xcode9.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk" \ ../configure --with-wine64=<path to wine64 build>
Or for a standalone 32-bit build:
DEVELOPER_DIR="/Applications/Xcode9.app" \ SDKROOT="/Applications/Xcode9.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk" \ ../configure --with-wine-tools=<path to wine64 build>
Brendan
I might have a cleaner solution for you.
Copy the following; Xcode9.4.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain
Rename XcodeDefault.xctoolchain > Xcode9.xctoolchain
Open ToolchainsInfo.plist Remove the current contents and add the following; CompatibilityVersion Number 2 DisplayName String Xcode 9.4.1 Bundle identifier String Xcode9.toolchain
Now move to ~/Library/Developer/Toolchains/
The toolchain is now visible within Xcode, it can also be used by setting; export TOOLCHAINS="Xcode9.toolchain"
Just need to set SDKROOT as appropriate.
On Thu, Oct 21, 2021 at 7:46 PM Brendan Shanks bshanks@codeweavers.com wrote:
True, looks like even Xcode 13.1 RC is still able to build for i386 with the 10.13 SDK. For CrossOver though we build an i386 .app, which requires xcodebuild, etc. I would also prefer to stick with the toolchain that Apple tested/supported for i386 (and that we’ve already been using).
On Oct 21, 2021, at 2:27 PM, Dean Greer gcenx83@gmail.com wrote:
I’m still not getting why your using Xcode9 in this manner when. XCode10/11/12 compiled 32Bit wine without issue as long as SDKROOT is set to MacOSX10.13.SDK
On Thu, Oct 21, 2021 at 5:22 PM Brendan Shanks bshanks@codeweavers.com wrote:
On Oct 21, 2021, at 12:35 PM, Alexandre Julliard julliard@winehq.org
wrote:
Brendan Shanks bshanks@codeweavers.com writes:
With the toolchain working, building i386 with it is now a
cross-compile.
Apple does not prefix the commands with the host triplet though (i.e. 'i386-apple-darwin'), which Wine seems to expect for
cross-compiling.
Specifically, configure adds "-b <host triplet>" to TARGETFLAGS,
causing
winebuild to search for commands like ld and nm prefixed with that host triplet, which fails.
This is a patch which only sets that TARGETFLAGS when the host triplet appears in $CC. I'm open to a different approach to fixing this though.
It seems to me that this should be done the same way we do it on Linux: if we are on an x86_64 host and --enable-win64 is not specified, we add -m32 and set host_cpu=i386. Passing --host is not required in this configuration.
Thanks Alexandre, that does work correctly and without any changes needed. This patch can be disregarded.
For a WOW64 build, running configure like this works:
DEVELOPER_DIR="/Applications/Xcode9.app" \ SDKROOT="/Applications/Xcode9.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk" \ ../configure --with-wine64=<path to wine64 build>
Or for a standalone 32-bit build:
DEVELOPER_DIR="/Applications/Xcode9.app" \ SDKROOT="/Applications/Xcode9.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk" \ ../configure --with-wine-tools=<path to wine64 build>
Brendan