Skip to content

Commit 124f115

Browse files
Fix iOS sdks build on Xcode 12 (#20574)
The new Xcode introduced functions like preadv/pwritev in the SDK that get erraneously detected by autoconf even though we can't use them. Disable these functions and also add a check for Xcode version to workaround #19393. Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
1 parent dfbfe5e commit 124f115

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

sdks/builds/ios.mk

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ _ios-$(1)_AC_VARS= \
6767
ac_cv_func_futimens=no \
6868
ac_cv_func_utimensat=no \
6969
ac_cv_func_shm_open_working_with_mmap=no \
70+
ac_cv_func_pthread_jit_write_protect_np=no \
71+
ac_cv_func_preadv=no \
72+
ac_cv_func_pwritev=no \
7073
mono_cv_sizeof_sunpath=104 \
7174
mono_cv_uscore=yes
7275

@@ -90,11 +93,15 @@ _ios-$(1)_CPPFLAGS= \
9093
-DSMALL_CONFIG -D_XOPEN_SOURCE -DHOST_IOS -DHAVE_LARGE_FILE_SUPPORT=1 \
9194

9295
_ios-$(1)_LDFLAGS= \
93-
-Wl,-no_weak_imports \
9496
-arch $(3) \
9597
-framework CoreFoundation \
9698
-lobjc -lc++
9799

100+
# Xcode 12 and later cause issues with no_weak_imports: https://github.com/mono/mono/issues/19393
101+
ifeq ($(XCODE_MAJOR_VERSION),$(filter $(XCODE_MAJOR_VERSION), 11 10 9))
102+
_ios-$(1)_LDFLAGS += -Wl,-no_weak_imports
103+
endif
104+
98105
_ios-$(1)_CONFIGURE_FLAGS = \
99106
--disable-boehm \
100107
--disable-btls \
@@ -296,6 +303,9 @@ _ios-$(1)_AC_VARS= \
296303
ac_cv_func_futimens=no \
297304
ac_cv_func_utimensat=no \
298305
ac_cv_func_shm_open_working_with_mmap=no \
306+
ac_cv_func_pthread_jit_write_protect_np=no \
307+
ac_cv_func_preadv=no \
308+
ac_cv_func_pwritev=no \
299309
mono_cv_uscore=yes
300310

301311
_ios-$(1)_CFLAGS= \

sdks/builds/mac.mk

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,12 @@ _mac-$(1)_CXXFLAGS= \
3636

3737
_mac-$(1)_CPPFLAGS=
3838

39-
_mac-$(1)_LDFLAGS= \
40-
-Wl,-no_weak_imports
39+
_mac-$(1)_LDFLAGS=
40+
41+
# Xcode 12 and later cause issues with no_weak_imports: https://github.com/mono/mono/issues/19393
42+
ifeq ($(XCODE_MAJOR_VERSION),$(filter $(XCODE_MAJOR_VERSION), 11 10 9))
43+
_mac-$(1)_LDFLAGS += -Wl,-no_weak_imports
44+
endif
4145

4246
_mac-$(1)_CONFIGURE_FLAGS= \
4347
--disable-boehm \

sdks/versions.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ ANDROID_SDK_VERSION_x86_64?=21
2020
# iOS
2121

2222
XCODE_DIR?=/Applications/Xcode.app/Contents/Developer
23+
XCODE_VERSION:=$(shell /usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" $(XCODE_DIR)/../version.plist)
24+
XCODE_MAJOR_VERSION:=$(word 1, $(subst ., ,$(XCODE_VERSION)))
2325

2426
# min versions of the targets
2527
MACOS_VERSION_MIN?=10.9

0 commit comments

Comments
 (0)