Skip to content

Commit 2ab4911

Browse files
committed
workaround for iOS simulator linking warnings
--- Workaround --- The REF_OS variable was introduced to workaround linking problems when compiler-rt is build for the iOS simulator. Without this workaround, trying to link compiler-rt into an executable for the iOS simulator would produce an error like ld: warning: URGENT: building for iOS simulator, but linking in object file built for OSX. Note: This will be an error in the future. The underlying reason is that the iOS simulator specific configuration is stored in variables named like DARWIN_iossim_SYSROOT and not DARWIN_macho_embedded_SYSROOT. Thus, with the current setup, compiler-rt would be compiled against the OS X SDK and not the iPhone Simulator SDK. As a workaround we manually override macho_embedded with iossim when accessing the DARWIN_*_SYSROOT and DARWIN_*_BUILTIN_MIN_VER_FLAG variables. This workaround probably break builds of compiler-rt for the watchOS and tvOS simulators (if they weren't broken already). See also rust-lang/rust#34617.
1 parent a1ef94b commit 2ab4911

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

cmake/Modules/CompilerRTDarwinUtils.cmake

+31-2
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,43 @@ macro(darwin_add_builtin_library name suffix)
169169
"PARENT_TARGET;OS;ARCH"
170170
"SOURCES;CFLAGS;DEFS"
171171
${ARGN})
172+
173+
# --- Workaround ---
174+
# The REF_OS variable was introduced to workaround linking problems when
175+
# compiler-rt is build for the iOS simulator.
176+
#
177+
# Without this workaround, trying to link compiler-rt into an executable for
178+
# the iOS simulator would produce an error like
179+
#
180+
# ld: warning: URGENT: building for iOS simulator, but linking in object
181+
# file built for OSX. Note: This will be an error in the future.
182+
#
183+
# The underlying reason is that the iOS simulator specific configuration is
184+
# stored in variables named like DARWIN_iossim_SYSROOT and not
185+
# DARWIN_macho_embedded_SYSROOT. Thus, with the current setup, compiler-rt
186+
# would be compiled against the OS X SDK and not the iPhone Simulator SDK.
187+
#
188+
# As a workaround we manually override macho_embedded with iossim when
189+
# accessing the DARWIN_*_SYSROOT and DARWIN_*_BUILTIN_MIN_VER_FLAG variables.
190+
#
191+
# This workaround probably break builds of compiler-rt for the watchOS and
192+
# tvOS simulators (if they weren't broken already).
193+
#
194+
# See also rust-lang/rust#34617.
195+
if(${LIB_OS} STREQUAL "macho_embedded")
196+
set(REF_OS iossim)
197+
else()
198+
set(REF_OS ${LIB_OS})
199+
endif()
200+
172201
set(libname "${name}.${suffix}_${LIB_ARCH}_${LIB_OS}")
173202
add_library(${libname} STATIC ${LIB_SOURCES})
174203
if(DARWIN_${LIB_OS}_SYSROOT)
175-
set(sysroot_flag -isysroot ${DARWIN_${LIB_OS}_SYSROOT})
204+
set(sysroot_flag -isysroot ${DARWIN_${REF_OS}_SYSROOT})
176205
endif()
177206
set_target_compile_flags(${libname}
178207
${sysroot_flag}
179-
${DARWIN_${LIB_OS}_BUILTIN_MIN_VER_FLAG}
208+
${DARWIN_${REF_OS}_BUILTIN_MIN_VER_FLAG}
180209
${LIB_CFLAGS})
181210
set_property(TARGET ${libname} APPEND PROPERTY
182211
COMPILE_DEFINITIONS ${LIB_DEFS})

0 commit comments

Comments
 (0)