summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2022-12-05 00:28:59 +0530
committerTim-Philipp Müller <tim@centricular.com>2023-01-10 17:06:55 +0000
commit7aa0baf4d6d46cb28c53b1e957a353cc0e7d5b92 (patch)
tree5f28a65c573b7094853ea879fcd1dcc653b40be0
parent589b3da817d8833c9090280b368c27c58bdd927b (diff)
macOS, iOS: Fix Xcode 14 ABI breakage with older Xcode
Starting with Xcode 14, clang emits `_objc_msgSend` stubs that are unsupported by older Xcode toolchains. This makes artifacts created with Xcode 14 unusable with older Xcode versions. Disable this for now. Other projects are doing the same thing: https://github.com/llvm/llvm-project/issues/56034 Part-of: <https://gitlab.freedesktop.org/gstreamer/cerbero/-/merge_requests/1070>
-rw-r--r--config/darwin.config11
-rw-r--r--config/ios.config13
2 files changed, 22 insertions, 2 deletions
diff --git a/config/darwin.config b/config/darwin.config
index 6d8a1177..c4be7401 100644
--- a/config/darwin.config
+++ b/config/darwin.config
@@ -49,6 +49,10 @@ if sdk_root is None:
elif not os.path.exists(sdk_root):
raise FatalError("Determined SDK path %s does not exist. Is your XCode installation broken?" % sdk_root);
+ret = shell.check_output(['xcodebuild', '-version']).strip()
+assert(ret.startswith('Xcode'))
+xcode_version = tuple(int(c) for c in ret.split()[1].split('.'))
+
min_osx_sdk_version = min_osx_sdk_version or '10.11'
sdk='-mmacosx-version-min=%s -isysroot %s' % (min_osx_sdk_version, sdk_root)
@@ -71,6 +75,11 @@ elif target_arch == Architecture.ARM64:
arch_ldflags += ' -arch arm64 -m64 -Wl,-arch,arm64'
arch_cflags += ' -Wno-error=format-nonliteral '
+# Starting with XCode 14, clang emits code that makes all binaries incompatible
+# with older XCode versions. Disable that feature.
+arch_objcflags = ''
+if xcode_version >= (14, 0):
+ arch_objcflags = ' -fno-objc-msgsend-selector-stubs '
incl_dir = os.path.join(prefix, 'include')
@@ -86,6 +95,8 @@ for f in ['CFLAGS', 'CCASFLAGS', 'CXXFLAGS', 'OBJCFLAGS', 'OBJCXXFLAGS']:
env[f] += ' %s ' % incflag
if sdk not in env[f]:
env[f] += ' %s ' % sdk
+env['OBJCFLAGS'] += arch_objcflags
+env['OBJCXXFLAGS'] += arch_objcflags
# To ensure that AC_CHECK_HEADER etc detect the right headers
if arch_cflags not in env['CPPFLAGS']:
diff --git a/config/ios.config b/config/ios.config
index e1a3ce11..eba34e62 100644
--- a/config/ios.config
+++ b/config/ios.config
@@ -66,6 +66,10 @@ elif _sdk_version is None:
else:
target_distro_version = _sdk_version
+ret = shell.check_output(['xcodebuild', '-version']).strip()
+assert(ret.startswith('Xcode'))
+xcode_version = tuple(int(c) for c in ret.split()[1].split('.'))
+
sysroot = version_array_to_sdk_location(best_version)
ccache = use_ccache and 'ccache ' or ''
@@ -104,6 +108,11 @@ else:
env['CC']= 'clang'
env['CXX']= 'clang++'
extra_cflags += ' -Wno-error=format-nonliteral -Wno-error=implicit-function-declaration '
+# Starting with XCode 14, clang emits code that makes all binaries incompatible
+# with older XCode versions. Disable that feature.
+extra_objcflags = ''
+if xcode_version >= (14, 0):
+ extra_objcflags += ' -fno-objc-msgsend-selector-stubs '
env['PATH'] = '%s:%s' % (toolchain_path, env['PATH'])
env['OBJC'] = env['CC']
@@ -130,8 +139,8 @@ else:
env['LDFLAGS'] += '-Wl,-ios_simulator_version_min,{0} '.format(ios_min_version)
env['CFLAGS'] += extra_cflags
env['LDFLAGS'] += extra_ldflags
-env['OBJCFLAGS'] = env['CFLAGS']
-env['OBJLDFLAGS'] = env['LDFLAGS']
+env['OBJCFLAGS'] = env['CFLAGS'] + extra_objcflags
+env['OBJLDFLAGS'] = env['LDFLAGS'] + extra_objcflags
env['CXXFLAGS'] =' -stdlib=libc++ ' + env['CFLAGS']
env['OBJCXXFLAGS'] =' -stdlib=libc++ ' + env['CFLAGS']