Skip to content

Runtimes: reorganise flags for swiftCore #80208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 24, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions Runtimes/Core/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,6 @@ if(NOT LINUX AND NOT ANDROID)
target_sources(swiftCore PRIVATE ObjectIdentifier+DebugDescription.swift)
endif()

set_target_properties(swiftCore PROPERTIES Swift_MODULE_NAME Swift)

if(SwiftCore_ENABLE_COMMANDLINE_SUPPORT)
target_sources(swiftCore PRIVATE CommandLine.swift)
target_link_libraries(swiftCore PRIVATE swiftCommandLineSupport)
Expand All @@ -271,11 +269,18 @@ if(SwiftCore_ENABLE_VECTOR_TYPES)
"${CMAKE_CURRENT_BINARY_DIR}/SIMDVectorTypes.swift")
endif()

if(APPLE AND BUILD_SHARED_LIBS)
target_link_options(swiftCore PRIVATE "SHELL:-Xlinker -headerpad_max_install_names")
endif()
set_target_properties(swiftCore PROPERTIES Swift_MODULE_NAME Swift)

target_compile_definitions(swiftCore
PRIVATE
$<$<BOOL:${SwiftCore_ENABLE_REFLECTION}>:-DSWIFT_ENABLE_REFLECTION>
$<$<BOOL:${SwiftCore_ENABLE_COMPACT_ABSOLUTE_FUNCTION_POINTERS}>:-DSWIFT_COMPACT_ABSOLUTE_FUNCTION_POINTER>
$<$<COMPILE_LANGUAGE:C,CXX>:-DSWIFT_TARGET_LIBRARY_NAME=swiftCore>
INTERFACE
$<$<BOOL:${SwiftCore_ENABLE_VECTOR_TYPES}>:-DSWIFT_STDLIB_ENABLE_VECTOR_TYPES>)

target_compile_options(swiftCore PRIVATE
"$<$<AND:$<COMPILE_LANGUAGE:Swift>,$<BOOL:${BUILD_SHARED_LIBS}>>:SHELL:-Xcc -DswiftCore_EXPORTS>"
# STAGING: Temporarily avoids having to write #fileID in Swift.swiftinterface.
# see also 327ea8bce2d1107a847d444651b19ca6a2901c9e
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -enable-experimental-concise-pound-file>"
Expand All @@ -293,16 +298,6 @@ if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "MinSizeRel")
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xllvm -sil-partial-specialization>")
endif()

target_compile_definitions(swiftCore
PRIVATE
$<$<BOOL:${SwiftCore_ENABLE_REFLECTION}>:-DSWIFT_ENABLE_REFLECTION>
$<$<BOOL:${SwiftCore_ENABLE_COMPACT_ABSOLUTE_FUNCTION_POINTERS}>:-DSWIFT_COMPACT_ABSOLUTE_FUNCTION_POINTER>
$<$<COMPILE_LANGUAGE:C,CXX>:-DSWIFT_TARGET_LIBRARY_NAME=swiftCore>
INTERFACE
$<$<BOOL:${SwiftCore_ENABLE_VECTOR_TYPES}>:-DSWIFT_STDLIB_ENABLE_VECTOR_TYPES>)
target_compile_options(swiftCore PRIVATE
"$<$<AND:$<BOOL:${BUILD_SHARED_LIBS}>,$<COMPILE_LANGUAGE:Swift>>:SHELL:-Xcc -DswiftCore_EXPORTS>")

target_link_libraries(swiftCore
PRIVATE
swiftRuntime
Expand All @@ -313,8 +308,7 @@ target_link_libraries(swiftCore
$<$<NOT:$<PLATFORM_ID:Darwin>>:swiftrt$<$<PLATFORM_ID:Windows>:T>>
PUBLIC
swiftShims)
target_link_options(swiftCore PUBLIC
$<$<LINK_LANGUAGE:Swift>:-nostartfiles>)

string(TOLOWER "${SwiftCore_OBJECT_FORMAT}" SwiftCore_OBJECT_FORMAT_lc)
if("${SwiftCore_OBJECT_FORMAT_lc}" STREQUAL "elf")
target_link_libraries(swiftCore INTERFACE
Expand All @@ -323,6 +317,10 @@ elseif("${SwiftCore_OBJECT_FORMAT_lc}" STREQUAL "coff")
target_link_libraries(swiftCore INTERFACE
swiftrt$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:T>)
endif()

target_link_options(swiftCore PUBLIC
$<$<LINK_LANGUAGE:Swift>:-nostartfiles>)

if(NOT POLICY CMP0157)
target_compile_options(swiftCore PRIVATE
$<TARGET_OBJECTS:swiftRuntime>
Expand All @@ -337,6 +335,10 @@ if(NOT ANDROID AND NOT APPLE AND NOT LINUX AND NOT WIN32 AND UNIX)
target_link_libraries(swiftCore PRIVATE "${EXECINFO_LIBRARY}")
endif()

if(APPLE AND BUILD_SHARED_LIBS)
target_link_options(swiftCore PRIVATE "SHELL:-Xlinker -headerpad_max_install_names")
endif()

install(TARGETS swiftCore
EXPORT SwiftCoreTargets
COMPONENT SwiftCore_runtime
Expand Down