Skip to content
This repository was archived by the owner on May 21, 2019. It is now read-only.

Commit 2f53859

Browse files
TimNNalexcrichton
authored andcommitted
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 73c18e6 commit 2f53859

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
@@ -179,14 +179,43 @@ macro(darwin_add_builtin_library name suffix)
179179
"PARENT_TARGET;OS;ARCH"
180180
"SOURCES;CFLAGS;DEFS"
181181
${ARGN})
182+
183+
# --- Workaround ---
184+
# The REF_OS variable was introduced to workaround linking problems when
185+
# compiler-rt is build for the iOS simulator.
186+
#
187+
# Without this workaround, trying to link compiler-rt into an executable for
188+
# the iOS simulator would produce an error like
189+
#
190+
# ld: warning: URGENT: building for iOS simulator, but linking in object
191+
# file built for OSX. Note: This will be an error in the future.
192+
#
193+
# The underlying reason is that the iOS simulator specific configuration is
194+
# stored in variables named like DARWIN_iossim_SYSROOT and not
195+
# DARWIN_macho_embedded_SYSROOT. Thus, with the current setup, compiler-rt
196+
# would be compiled against the OS X SDK and not the iPhone Simulator SDK.
197+
#
198+
# As a workaround we manually override macho_embedded with iossim when
199+
# accessing the DARWIN_*_SYSROOT and DARWIN_*_BUILTIN_MIN_VER_FLAG variables.
200+
#
201+
# This workaround probably break builds of compiler-rt for the watchOS and
202+
# tvOS simulators (if they weren't broken already).
203+
#
204+
# See also rust-lang/rust#34617.
205+
if(${LIB_OS} STREQUAL "macho_embedded")
206+
set(REF_OS iossim)
207+
else()
208+
set(REF_OS ${LIB_OS})
209+
endif()
210+
182211
set(libname "${name}.${suffix}_${LIB_ARCH}_${LIB_OS}")
183212
add_library(${libname} STATIC ${LIB_SOURCES})
184213
if(DARWIN_${LIB_OS}_SYSROOT)
185-
set(sysroot_flag -isysroot ${DARWIN_${LIB_OS}_SYSROOT})
214+
set(sysroot_flag -isysroot ${DARWIN_${REF_OS}_SYSROOT})
186215
endif()
187216
set_target_compile_flags(${libname}
188217
${sysroot_flag}
189-
${DARWIN_${LIB_OS}_BUILTIN_MIN_VER_FLAG}
218+
${DARWIN_${REF_OS}_BUILTIN_MIN_VER_FLAG}
190219
${LIB_CFLAGS})
191220
set_property(TARGET ${libname} APPEND PROPERTY
192221
COMPILE_DEFINITIONS ${LIB_DEFS})

0 commit comments

Comments
 (0)