Fixed bug 5232 - SDL2 configure script detects Apple Silicon Macs as iPhones; fails to build due to missing components

jackmacwindowslinux

I'm testing my application that uses SDL2 on the new Apple Silicon Macs. I set up the SDL 2.0.12 source code from the website and tried to build it. The first issue I ran into was that it was always building OpenGL ES, even if --disable-video-opengles was passed to configure. OpenGL ES headers do not seem to be present on the Apple Silicon macOS SDK, except for the iOS SDK headers. Then I had problems with the joystick driver, where some classes used on iOS were not available on macOS.

After looking through the configure.ac script a bit, I found that iOS targets are selected when the build host matches "arm*-apple-darwin*". Clang on macOS 11.0 on arm64 reports the host as "arm64-apple-darwin20.0.0", which matches the iOS target. This means that ARM Mac compilation will always be detected as iOS. Unfortunately, there doesn't seem to be an easy way to detect Mac vs. iOS targets, since they now both use the same triplet & compiler for building.

I'm not sure what the best way to fix this is, but maybe there could be an additional target flag to specify whether to build for macOS or iOS? This might break compatibility, though: with this approach, either all old scripts that used configure to build for iOS fail, or all new builds on macOS without a flag fail (silently?).
This commit is contained in:
Sam Lantinga 2020-07-15 16:12:44 -07:00
parent cab1a715f5
commit 968b830d14
2 changed files with 4 additions and 12 deletions

8
configure vendored
View File

@ -21775,10 +21775,6 @@ $as_echo_n "checking for Metal framework... " >&6; }
#import <Metal/Metal.h>
#import <QuartzCore/CAMetalLayer.h>
#if !TARGET_CPU_X86_64
#error Metal doesn't work on this configuration
#endif
int
main ()
{
@ -24254,7 +24250,7 @@ CheckHIDAPI()
# so we'll just use libusb when it's available.
case "$host" in
# libusb does not support iOS
arm*-apple-darwin* | *-ios-* )
*-ios-* )
skiplibusb=yes
;;
# On the other hand, *BSD specifically uses libusb only
@ -25154,7 +25150,7 @@ else
fi
;;
arm*-apple-darwin*|*-ios-*)
*-ios-*)
ARCH=ios
CheckVisibilityHidden

View File

@ -2156,10 +2156,6 @@ AS_HELP_STRING([--enable-render-metal], [enable the Metal render driver [[defaul
#import <Cocoa/Cocoa.h>
#import <Metal/Metal.h>
#import <QuartzCore/CAMetalLayer.h>
#if !TARGET_CPU_X86_64
#error Metal doesn't work on this configuration
#endif
],[
],[
have_metal=yes
@ -3289,7 +3285,7 @@ CheckHIDAPI()
# so we'll just use libusb when it's available.
case "$host" in
# libusb does not support iOS
arm*-apple-darwin* | *-ios-* )
*-ios-* )
skiplibusb=yes
;;
# On the other hand, *BSD specifically uses libusb only
@ -3872,7 +3868,7 @@ AS_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
# other spins, like x86-64, use a more standard "libstdc++.so.*"
AC_CHECK_FILE("/boot/system/lib/libstdc++.r4.so", EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lstdc++.r4", EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lstdc++")
;;
arm*-apple-darwin*|*-ios-*)
*-ios-*)
ARCH=ios
CheckVisibilityHidden