Skip to content

Commit d731aa2

Browse files
authored
Merge pull request #38415 from edymtt/explicitly-set-osx-architecture-macos
[build] explicitly set OSX_ARCHITECTURES for targets in stdlib
2 parents 0441183 + 66bd9f8 commit d731aa2

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

stdlib/cmake/modules/AddSwiftStdlib.cmake

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2055,6 +2055,15 @@ function(add_swift_target_library name)
20552055
list(APPEND THIN_INPUT_TARGETS ${VARIANT_NAME})
20562056
endif()
20572057
endif()
2058+
2059+
if(sdk IN_LIST SWIFT_APPLE_PLATFORMS)
2060+
# In the past, we relied on unsetting globally
2061+
# CMAKE_OSX_ARCHITECTURES to ensure that CMake would
2062+
# not add the -arch flag
2063+
# This is no longer the case when running on Apple Silicon,
2064+
# when CMake will enforce a default (see https://gitlab.kitware.com/cmake/cmake/-/merge_requests/5291)
2065+
set_property(TARGET ${VARIANT_NAME} PROPERTY OSX_ARCHITECTURES "${arch}")
2066+
endif()
20582067
endforeach()
20592068

20602069
# Configure module-only targets
@@ -2493,6 +2502,13 @@ function(add_swift_target_executable name)
24932502
endif()
24942503

24952504
if(${sdk} IN_LIST SWIFT_APPLE_PLATFORMS)
2505+
# In the past, we relied on unsetting globally
2506+
# CMAKE_OSX_ARCHITECTURES to ensure that CMake would
2507+
# not add the -arch flag
2508+
# This is no longer the case when running on Apple Silicon,
2509+
# when CMake will enforce a default (see https://gitlab.kitware.com/cmake/cmake/-/merge_requests/5291)
2510+
set_property(TARGET ${VARIANT_NAME} PROPERTY OSX_ARCHITECTURES "${arch}")
2511+
24962512
add_custom_command_target(unused_var2
24972513
COMMAND "codesign" "-f" "-s" "-" "${SWIFT_RUNTIME_OUTPUT_INTDIR}/${VARIANT_NAME}"
24982514
CUSTOM_TARGET_NAME "${VARIANT_NAME}_signed"

0 commit comments

Comments
 (0)