From 737b4fc32cc0fb96f771ccf7d8d69d7e29b4450f Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 11 May 2022 11:17:58 -0700 Subject: [PATCH] Added -fobjc-arc to support automatic reference counting on macOS --- configure | 35 +++++++++++++++++++++++++++++++++++ configure.ac | 21 +++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/configure b/configure index b5e5b7247..069b26324 100755 --- a/configure +++ b/configure @@ -20385,6 +20385,40 @@ $as_echo "#define SDL_ARM_NEON_BLITTERS 1" >>confdefs.h fi } +CheckObjectiveCARC() +{ + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for clang -fobjc-arc option" >&5 +$as_echo_n "checking for clang -fobjc-arc option... " >&6; } + have_clang_objc_arc=no + + save_CFLAGS="$CFLAGS" + CFLAGS="$save_CFLAGS -fobjc-arc" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + int x = 0; + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + have_clang_objc_arc=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_clang_objc_arc" >&5 +$as_echo "$have_clang_objc_arc" >&6; } + CFLAGS="$save_CFLAGS" + + if test x$have_clang_objc_arc = xyes; then + EXTRA_CFLAGS="$EXTRA_CFLAGS -fobjc-arc" + fi +} + CheckVisibilityHidden() { { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GCC -fvisibility=hidden option" >&5 @@ -26454,6 +26488,7 @@ $as_echo "#define SDL_VIDEO_RENDER_OGL_ES2 1" >>confdefs.h EXTRA_CFLAGS="$EXTRA_CFLAGS -DTARGET_API_MAC_CARBON" EXTRA_CFLAGS="$EXTRA_CFLAGS -DTARGET_API_MAC_OSX" + CheckObjectiveCARC CheckVisibilityHidden CheckDeclarationAfterStatement CheckDummyVideo diff --git a/configure.ac b/configure.ac index ed3405d37..2958d3a4f 100644 --- a/configure.ac +++ b/configure.ac @@ -1432,6 +1432,26 @@ CheckNEON() fi } +dnl See if clang's -fobjc-arc supported. +dnl Reference: https://github.com/libsdl-org/SDL/pull/5632 +CheckObjectiveCARC() +{ + AC_MSG_CHECKING(for clang -fobjc-arc option) + have_clang_objc_arc=no + + save_CFLAGS="$CFLAGS" + CFLAGS="$save_CFLAGS -fobjc-arc" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + int x = 0; + ]],[])], [have_clang_objc_arc=yes],[]) + AC_MSG_RESULT($have_clang_objc_arc) + CFLAGS="$save_CFLAGS" + + if test x$have_clang_objc_arc = xyes; then + EXTRA_CFLAGS="$EXTRA_CFLAGS -fobjc-arc" + fi +} + dnl See if GCC's -fvisibility=hidden is supported (gcc4 and later, usually). dnl Details of this flag are here: http://gcc.gnu.org/wiki/Visibility CheckVisibilityHidden() @@ -4197,6 +4217,7 @@ dnl BeOS support removed after SDL 2.0.1. Haiku still works. --ryan. EXTRA_CFLAGS="$EXTRA_CFLAGS -DTARGET_API_MAC_CARBON" EXTRA_CFLAGS="$EXTRA_CFLAGS -DTARGET_API_MAC_OSX" + CheckObjectiveCARC CheckVisibilityHidden CheckDeclarationAfterStatement CheckDummyVideo