Skip to content
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

Fix NSLock/Thread subclassing issues #5122

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
20 changes: 17 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,25 @@ if(CMAKE_SYSTEM_NAME STREQUAL Linux)
endif()

# Precompute module triple for installation
if(NOT SwiftFoundation_MODULE_TRIPLE)
if(NOT SwiftFoundation_MODULE_TRIPLE OR NOT SwiftFoundation_GLIBC_MODULE_PATHS)
set(module_triple_command "${CMAKE_Swift_COMPILER}" -print-target-info)
if(CMAKE_Swift_COMPILER_TARGET)
list(APPEND module_triple_command -target ${CMAKE_Swift_COMPILER_TARGET})
endif()
execute_process(COMMAND ${module_triple_command} OUTPUT_VARIABLE target_info_json)
string(JSON module_triple GET "${target_info_json}" "target" "moduleTriple")
set(SwiftFoundation_MODULE_TRIPLE "${module_triple}" CACHE STRING "swift module triple used for installed swiftmodule and swiftinterface files")
mark_as_advanced(SwiftFoundation_MODULE_TRIPLE)
if (NOT SwiftFoundation_GLIBC_MODULE_PATHS)
string(JSON glibc_module_path_length LENGTH "${target_info_json}" "paths" "runtimeLibraryImportPaths")
MATH(EXPR glibc_module_path_length "${glibc_module_path_length} - 1")
foreach(i RANGE ${glibc_module_path_length})
string(JSON value GET "${target_info_json}" "paths" "runtimeLibraryImportPaths" ${i})
list(APPEND SwiftFoundation_GLIBC_MODULE_PATHS "${value}")
endforeach()
endif()
if(NOT SwiftFoundation_MODULE_TRIPLE)
set(SwiftFoundation_MODULE_TRIPLE "${module_triple}" CACHE STRING "swift module triple used for installed swiftmodule and swiftinterface files")
mark_as_advanced(SwiftFoundation_MODULE_TRIPLE)
endif()
endif()

# System dependencies
Expand Down Expand Up @@ -171,6 +181,10 @@ list(APPEND _Foundation_common_build_flags
"-Wno-switch"
"-fblocks")

foreach(path ${SwiftFoundation_GLIBC_MODULE_PATHS})
list(APPEND _Foundation_common_build_flags "-I${path}")
endforeach()

if(NOT CMAKE_SYSTEM_NAME STREQUAL "WASI")
list(APPEND _Foundation_common_build_flags
"-DDEPLOYMENT_ENABLE_LIBDISPATCH"
Expand Down
3 changes: 0 additions & 3 deletions Sources/CoreFoundation/include/CFPriv.h
Original file line number Diff line number Diff line change
Expand Up @@ -592,9 +592,6 @@ CF_EXPORT CFMessagePortRef _CFMessagePortCreateLocalEx(CFAllocatorRef allocator,
#if __has_include(<unistd.h>)
#include <unistd.h>
#endif
#if _POSIX_THREADS
#include <pthread.h>
#endif
#include <time.h>

CF_INLINE CFAbsoluteTime _CFAbsoluteTimeFromFileTimeSpec(struct timespec ts) {
Expand Down
4 changes: 4 additions & 0 deletions Sources/CoreFoundation/include/ForSwiftFoundationOnly.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
#include <unistd.h>
#endif
#if _POSIX_THREADS
#if __has_include(<SwiftGlibc.h>)
// Import SwiftGlibc.h before pthread.h (when available) to ensure the compiler understands that pthread.h is not owned by CoreFoundation
#include <SwiftGlibc.h>
#endif
#include <pthread.h>
#endif
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__wasi__)
Expand Down