Skip to content

Commit 37cdca9

Browse files
authored
Re-Add Synchronization Import on non-Darwin (swiftlang#742)
* Allow importing Synchronization in the toolchain * Autolink Synchronization for static swift build * Fix static swift build failures
1 parent 523ffcb commit 37cdca9

File tree

4 files changed

+13
-15
lines changed

4 files changed

+13
-15
lines changed

Sources/FoundationEssentials/CMakeLists.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,13 @@ if(NOT BUILD_SHARED_LIBS)
7777
"SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -public-autolink-library -Xfrontend _FoundationCShims>")
7878
target_compile_options(FoundationEssentials PRIVATE
7979
"SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -public-autolink-library -Xfrontend _FoundationCollections>")
80+
target_compile_options(FoundationEssentials PRIVATE
81+
"SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -public-autolink-library -Xfrontend swiftSynchronization>")
8082
endif()
8183

82-
target_link_options(FoundationEssentials PRIVATE
83-
"SHELL:-no-toolchain-stdlib-rpath")
84-
8584
set_target_properties(FoundationEssentials PROPERTIES
86-
INSTALL_RPATH "$ORIGIN")
85+
INSTALL_RPATH "$ORIGIN"
86+
INSTALL_REMOVE_ENVIRONMENT_RPATH ON)
8787

8888
set_property(GLOBAL APPEND PROPERTY SWIFT_FOUNDATION_EXPORTS FoundationEssentials)
8989
_swift_foundation_install_target(FoundationEssentials)

Sources/FoundationEssentials/Predicate/PredicateExpression.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#if FOUNDATION_FRAMEWORK
13+
#if canImport(Synchronization) && (!canImport(Darwin) || FOUNDATION_FRAMEWORK)
1414
internal import Synchronization
1515
#endif
1616

@@ -85,14 +85,14 @@ public struct PredicateError: Error, Hashable, CustomDebugStringConvertible {
8585
extension PredicateExpressions {
8686
public struct VariableID: Hashable, Codable, Sendable {
8787
let id: UInt
88-
#if FOUNDATION_FRAMEWORK
88+
#if canImport(Synchronization) && (!canImport(Darwin) || FOUNDATION_FRAMEWORK)
8989
private static let nextID = Atomic<UInt>(0)
9090
#else
9191
private static let nextID = LockedState(initialState: UInt(0))
9292
#endif
9393

9494
init() {
95-
#if FOUNDATION_FRAMEWORK
95+
#if canImport(Synchronization) && (!canImport(Darwin) || FOUNDATION_FRAMEWORK)
9696
self.id = Self.nextID.wrappingAdd(1, ordering: .relaxed).oldValue
9797
#else
9898
self.id = Self.nextID.withLock { value in

Sources/FoundationInternationalization/CMakeLists.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ if(NOT BUILD_SHARED_LIBS)
4545
"SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -public-autolink-library -Xfrontend _FoundationCShims>")
4646
target_compile_options(FoundationInternationalization PRIVATE
4747
"SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -public-autolink-library -Xfrontend _FoundationICU>")
48+
target_compile_options(FoundationEssentials PRIVATE
49+
"SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -public-autolink-library -Xfrontend swiftSynchronization>")
4850
endif()
4951

50-
target_link_options(FoundationInternationalization PRIVATE
51-
"SHELL:-no-toolchain-stdlib-rpath")
52-
5352
set_target_properties(FoundationInternationalization PROPERTIES
54-
INSTALL_RPATH "$ORIGIN")
53+
INSTALL_RPATH "$ORIGIN"
54+
INSTALL_REMOVE_ENVIRONMENT_RPATH ON)
5555

5656
set_property(GLOBAL APPEND PROPERTY SWIFT_FOUNDATION_EXPORTS FoundationInternationalization)
5757
_swift_foundation_install_target(FoundationInternationalization)

Sources/FoundationMacros/CMakeLists.txt

+2-4
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,9 @@ target_link_libraries(FoundationMacros PUBLIC
4343
SwiftSyntax::SwiftSyntaxBuilder
4444
)
4545

46-
target_link_options(FoundationMacros PRIVATE
47-
"SHELL:-no-toolchain-stdlib-rpath")
48-
4946
set_target_properties(FoundationMacros PROPERTIES
50-
INSTALL_RPATH "$ORIGIN")
47+
INSTALL_RPATH "$ORIGIN"
48+
INSTALL_REMOVE_ENVIRONMENT_RPATH ON)
5149

5250
target_compile_options(FoundationMacros PRIVATE -parse-as-library)
5351
target_compile_options(FoundationMacros PRIVATE

0 commit comments

Comments
 (0)