Skip to content

Commit

Permalink
Allow importing Synchronization in the toolchain
Browse files Browse the repository at this point in the history
  • Loading branch information
jmschonfeld committed Jul 22, 2024
1 parent c0a485e commit 4d5865d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
6 changes: 2 additions & 4 deletions Sources/FoundationEssentials/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,9 @@ if(NOT BUILD_SHARED_LIBS)
"SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -public-autolink-library -Xfrontend _FoundationCollections>")
endif()

target_link_options(FoundationEssentials PRIVATE
"SHELL:-no-toolchain-stdlib-rpath")

set_target_properties(FoundationEssentials PROPERTIES
INSTALL_RPATH "$ORIGIN")
INSTALL_RPATH "$ORIGIN"
INSTALL_REMOVE_ENVIRONMENT_RPATH ON)

set_property(GLOBAL APPEND PROPERTY SWIFT_FOUNDATION_EXPORTS FoundationEssentials)
_swift_foundation_install_target(FoundationEssentials)
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//
//===----------------------------------------------------------------------===//

#if FOUNDATION_FRAMEWORK
#if canImport(Synchronization) && (!canImport(Darwin) || FOUNDATION_FRAMEWORK)
internal import Synchronization
#endif

Expand Down Expand Up @@ -85,14 +85,14 @@ public struct PredicateError: Error, Hashable, CustomDebugStringConvertible {
extension PredicateExpressions {
public struct VariableID: Hashable, Codable, Sendable {
let id: UInt
#if FOUNDATION_FRAMEWORK
#if canImport(Synchronization) && (!canImport(Darwin) || FOUNDATION_FRAMEWORK)
private static let nextID = Atomic<UInt>(0)
#else
private static let nextID = LockedState(initialState: UInt(0))
#endif

init() {
#if FOUNDATION_FRAMEWORK
#if canImport(Synchronization) && (!canImport(Darwin) || FOUNDATION_FRAMEWORK)
self.id = Self.nextID.wrappingAdd(1, ordering: .relaxed).oldValue
#else
self.id = Self.nextID.withLock { value in
Expand Down
6 changes: 2 additions & 4 deletions Sources/FoundationInternationalization/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,9 @@ if(NOT BUILD_SHARED_LIBS)
"SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -public-autolink-library -Xfrontend _FoundationICU>")
endif()

target_link_options(FoundationInternationalization PRIVATE
"SHELL:-no-toolchain-stdlib-rpath")

set_target_properties(FoundationInternationalization PROPERTIES
INSTALL_RPATH "$ORIGIN")
INSTALL_RPATH "$ORIGIN"
INSTALL_REMOVE_ENVIRONMENT_RPATH ON)

set_property(GLOBAL APPEND PROPERTY SWIFT_FOUNDATION_EXPORTS FoundationInternationalization)
_swift_foundation_install_target(FoundationInternationalization)
6 changes: 2 additions & 4 deletions Sources/FoundationMacros/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,9 @@ target_link_libraries(FoundationMacros PUBLIC
SwiftSyntax::SwiftSyntaxBuilder
)

target_link_options(FoundationMacros PRIVATE
"SHELL:-no-toolchain-stdlib-rpath")

set_target_properties(FoundationMacros PROPERTIES
INSTALL_RPATH "$ORIGIN")
INSTALL_RPATH "$ORIGIN"
INSTALL_REMOVE_ENVIRONMENT_RPATH ON)

target_compile_options(FoundationMacros PRIVATE -parse-as-library)
target_compile_options(FoundationMacros PRIVATE
Expand Down

0 comments on commit 4d5865d

Please sign in to comment.