SDL_image: Need to turn off optimizations so weak framework load check works

From a9564af3ca69a23dc7d48fdcf832e0d4b109237e Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Wed, 29 Nov 2023 17:21:16 -0800
Subject: [PATCH] Need to turn off optimizations so weak framework load check
 works

---
 src/IMG_avif.c | 4 ++++
 src/IMG_jxl.c  | 4 ++++
 src/IMG_webp.c | 4 ++++
 3 files changed, 12 insertions(+)

diff --git a/src/IMG_avif.c b/src/IMG_avif.c
index d020ec31..2d7795cd 100644
--- a/src/IMG_avif.c
+++ b/src/IMG_avif.c
@@ -53,6 +53,10 @@ static struct {
 #endif
 
 int IMG_InitAVIF()
+#ifdef __APPLE__
+    /* Need to turn off optimizations so weak framework load check works */
+    __attribute__ ((optnone))
+#endif
 {
     if ( lib.loaded == 0 ) {
 #ifdef LOAD_AVIF_DYNAMIC
diff --git a/src/IMG_jxl.c b/src/IMG_jxl.c
index d6b42d07..7ebc22d2 100644
--- a/src/IMG_jxl.c
+++ b/src/IMG_jxl.c
@@ -52,6 +52,10 @@ static struct {
 #endif
 
 int IMG_InitJXL()
+#ifdef __APPLE__
+    /* Need to turn off optimizations so weak framework load check works */
+    __attribute__ ((optnone))
+#endif
 {
     if ( lib.loaded == 0 ) {
 #ifdef LOAD_JXL_DYNAMIC
diff --git a/src/IMG_webp.c b/src/IMG_webp.c
index 8b918c67..ea8e4a64 100644
--- a/src/IMG_webp.c
+++ b/src/IMG_webp.c
@@ -72,6 +72,10 @@ static struct {
 #endif
 
 int IMG_InitWEBP()
+#ifdef __APPLE__
+    /* Need to turn off optimizations so weak framework load check works */
+    __attribute__ ((optnone))
+#endif
 {
     if (lib.loaded == 0) {
 #if defined(LOAD_WEBP_DYNAMIC) && defined(LOAD_WEBPDEMUX_DYNAMIC)