Skip to content

Core: specify the threading package that is in use #78144

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
Dec 13, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions Runtimes/Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ option(SwiftCore_ENABLE_RUNTIME_LEAK_CHECKER "" OFF)
option(SwiftCore_ENABLE_INTERNAL_CHECKS "" OFF)

defaulted_set(SwiftCore_OBJECT_FORMAT STRING "Object format: ELF COFF")
defaulted_set(SwiftCore_THREADING_PACKAGE STRING "Threading Package: C11 Linux PThreads Win32")

# TODO: Most of these should be attached to specific targets rather than applied
# globally. They can be applied as part of the library interface if they
Expand All @@ -118,6 +119,7 @@ add_compile_definitions(
$<$<BOOL:${SwiftCore_ENABLE_UNICODE_DATA}>:-DSWIFT_STDLIB_ENABLE_UNICODE_DATA> # Stubs
$<$<BOOL:${SwiftCore_ENABLE_ENVIRONMENT}>:-DSWIFT_STDLIB_HAS_ENVIRON> # Concurrency, runtime, shims, platform overlay
$<$<BOOL:${SwiftCore_ENABLE_BACKDEPLOYMENT_SUPPORT}>:-DSWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT> # Concurrency, Compatibility override, magic symbols
$<$<COMPILE_LANGUAGE:C,CXX>:-DSWIFT_THREADING_${SwiftCore_THREADING_PACKAGE}>
$<$<COMPILE_LANGUAGE:C,CXX>:-DSWIFT_RUNTIME_ENABLE_LEAK_CHECKER=$<BOOL:${SwiftCore_ENABLE_RUNTIME_LEAK_CHECKER}>>
$<$<COMPILE_LANGUAGE:C,CXX>:-DSWIFT_RUNTIME_CLOBBER_FREED_OBJECTS=$<BOOL:${SwiftCore_ENABLE_CLOBBER_FREED_OBJECTS}>>)

Expand Down
8 changes: 8 additions & 0 deletions Runtimes/Core/cmake/modules/DefaultSettings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,20 @@ if(APPLE)
set(SwiftCore_ENABLE_REFLECTION_default ON)
set(SwiftCore_ENABLE_RUNTIME_OS_VERSIONING ON)
set(SwiftCore_ENABLE_OVERRIDABLE_RETAIN_RELEASE ON)
set(SwiftCore_THREADING_PACKAGE "DARWIN")
elseif(CMAKE_SYSTEM_NAME STREQUAL "WASM")
set(SwiftCore_OBJECT_FORMAT_default "elf")
set(SwiftCore_THREADING_PACKAGE "NONE")
elseif(LINUX OR ANDROID OR BSD)
set(SwiftCore_OBJECT_FORMAT_default "elf")
if(LINUX)
set(SwiftCore_THREADING_PACKAGE "LINUX")
else()
set(SwiftCore_THREADING_PACKAGE "PTHREADS")
endif()
elseif(WIN32)
set(SwiftCore_OBJECT_FORMAT_default "coff")
set(SwiftCore_THREADING_PACKAGE "WIN32")
endif()

include("${SwiftCore_VENDOR_MODULE_DIR}/DefaultSettings.cmake" OPTIONAL)