Skip to content

Commit d03731b

Browse files
committed
Match semantics of original code so we don't regress freestanding, fix typo
1 parent 29e2b18 commit d03731b

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

stdlib/cmake/modules/AddSwiftStdlib.cmake

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,18 +1346,6 @@ function(add_swift_target_library_single target name)
13461346
target_link_options(${target} PRIVATE
13471347
"LINKER:-current_version,${SWIFT_COMPILER_VERSION}")
13481348
endif()
1349-
1350-
# In the past, we relied on unsetting globally
1351-
# CMAKE_OSX_ARCHITECTURES to ensure that CMake
1352-
# would# not add the -arch flag. This is no longer
1353-
# the case when running on Apple Silicon, when
1354-
# CMake will enforce a default (see
1355-
# https://gitlab.kitware.com/cmake/cmake/-/merge_requests/5291)
1356-
set_property(TARGET ${target} PROPERTY OSX_ARCHITECTURES "${SWIFTLIB_SINGLE_ARCHITECTURE}")
1357-
if(TARGET "${target_static}")
1358-
set_property(TARGET ${target_static} PROPERTY OSX_ARCHITECTURES "${SWIFTLIB_SINGLE_ARCHITECTURE}")
1359-
endif()
1360-
13611349
# Include LLVM Bitcode slices for iOS, Watch OS, and Apple TV OS device libraries.
13621350
if(SWIFT_EMBED_BITCODE_SECTION AND NOT SWIFTLIB_SINGLE_DONT_EMBED_BITCODE)
13631351
if("${SWIFTLIB_SINGLE_SDK}" STREQUAL "IOS" OR
@@ -1383,6 +1371,20 @@ function(add_swift_target_library_single target name)
13831371
# emitting warnings about global initializers when it compiles the code.
13841372
list(APPEND swiftlib_link_flags_all "-Xlinker -no_warn_inits")
13851373
endif()
1374+
1375+
if(${SWIFTLIB_SINGLE_SDK} IN_LIST SWIFT_APPLE_PLATFORMS)
1376+
# In the past, we relied on unsetting globally
1377+
# CMAKE_OSX_ARCHITECTURES to ensure that CMake
1378+
# would not add the -arch flag. This is no longer
1379+
# the case when running on Apple Silicon, when
1380+
# CMake will enforce a default (see
1381+
# https://gitlab.kitware.com/cmake/cmake/-/merge_requests/5291)
1382+
set_property(TARGET ${target} PROPERTY OSX_ARCHITECTURES "${SWIFTLIB_SINGLE_ARCHITECTURE}")
1383+
if(TARGET "${target_static}")
1384+
set_property(TARGET ${target_static} PROPERTY OSX_ARCHITECTURES "${SWIFTLIB_SINGLE_ARCHITECTURE}")
1385+
endif()
1386+
endif()
1387+
13861388
target_link_libraries(${target} PRIVATE
13871389
${link_libraries})
13881390
target_link_directories(${target} PRIVATE

0 commit comments

Comments
 (0)