From 4d5865d562088707b475e012a34ae3dddc4b373d Mon Sep 17 00:00:00 2001 From: Jeremy Schonfeld Date: Wed, 17 Jul 2024 18:06:21 -0700 Subject: [PATCH 1/3] Allow importing Synchronization in the toolchain --- Sources/FoundationEssentials/CMakeLists.txt | 6 ++---- .../Predicate/PredicateExpression.swift | 6 +++--- Sources/FoundationInternationalization/CMakeLists.txt | 6 ++---- Sources/FoundationMacros/CMakeLists.txt | 6 ++---- 4 files changed, 9 insertions(+), 15 deletions(-) diff --git a/Sources/FoundationEssentials/CMakeLists.txt b/Sources/FoundationEssentials/CMakeLists.txt index df86c256d..dd7563075 100644 --- a/Sources/FoundationEssentials/CMakeLists.txt +++ b/Sources/FoundationEssentials/CMakeLists.txt @@ -79,11 +79,9 @@ if(NOT BUILD_SHARED_LIBS) "SHELL:$<$:-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) diff --git a/Sources/FoundationEssentials/Predicate/PredicateExpression.swift b/Sources/FoundationEssentials/Predicate/PredicateExpression.swift index 3e8520ea8..160a00959 100644 --- a/Sources/FoundationEssentials/Predicate/PredicateExpression.swift +++ b/Sources/FoundationEssentials/Predicate/PredicateExpression.swift @@ -10,7 +10,7 @@ // //===----------------------------------------------------------------------===// -#if FOUNDATION_FRAMEWORK +#if canImport(Synchronization) && (!canImport(Darwin) || FOUNDATION_FRAMEWORK) internal import Synchronization #endif @@ -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(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 diff --git a/Sources/FoundationInternationalization/CMakeLists.txt b/Sources/FoundationInternationalization/CMakeLists.txt index b3e6feb11..3255e6a09 100644 --- a/Sources/FoundationInternationalization/CMakeLists.txt +++ b/Sources/FoundationInternationalization/CMakeLists.txt @@ -46,11 +46,9 @@ if(NOT BUILD_SHARED_LIBS) "SHELL:$<$:-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) diff --git a/Sources/FoundationMacros/CMakeLists.txt b/Sources/FoundationMacros/CMakeLists.txt index bbc7bd628..0cc31c299 100644 --- a/Sources/FoundationMacros/CMakeLists.txt +++ b/Sources/FoundationMacros/CMakeLists.txt @@ -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 From 6201c21ca0f41fbb684ad020f6dd93c4993ab833 Mon Sep 17 00:00:00 2001 From: Jeremy Schonfeld Date: Thu, 18 Jul 2024 08:40:17 -0700 Subject: [PATCH 2/3] Autolink Synchronization for static swift build --- Sources/FoundationEssentials/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sources/FoundationEssentials/CMakeLists.txt b/Sources/FoundationEssentials/CMakeLists.txt index dd7563075..ad32fe78b 100644 --- a/Sources/FoundationEssentials/CMakeLists.txt +++ b/Sources/FoundationEssentials/CMakeLists.txt @@ -77,6 +77,8 @@ if(NOT BUILD_SHARED_LIBS) "SHELL:$<$:-Xfrontend -public-autolink-library -Xfrontend _FoundationCShims>") target_compile_options(FoundationEssentials PRIVATE "SHELL:$<$:-Xfrontend -public-autolink-library -Xfrontend _FoundationCollections>") + target_compile_options(FoundationEssentials PRIVATE + "SHELL:$<$:-Xfrontend -public-autolink-library -Xfrontend Synchronization>") endif() set_target_properties(FoundationEssentials PROPERTIES From 911c5b86731b8cd3aaa15f30f0bf42c3d5fbd62b Mon Sep 17 00:00:00 2001 From: Jeremy Schonfeld Date: Thu, 18 Jul 2024 10:29:28 -0700 Subject: [PATCH 3/3] Fix static swift build failures --- Sources/FoundationEssentials/CMakeLists.txt | 2 +- Sources/FoundationInternationalization/CMakeLists.txt | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/FoundationEssentials/CMakeLists.txt b/Sources/FoundationEssentials/CMakeLists.txt index ad32fe78b..d9ebc2ebb 100644 --- a/Sources/FoundationEssentials/CMakeLists.txt +++ b/Sources/FoundationEssentials/CMakeLists.txt @@ -78,7 +78,7 @@ if(NOT BUILD_SHARED_LIBS) target_compile_options(FoundationEssentials PRIVATE "SHELL:$<$:-Xfrontend -public-autolink-library -Xfrontend _FoundationCollections>") target_compile_options(FoundationEssentials PRIVATE - "SHELL:$<$:-Xfrontend -public-autolink-library -Xfrontend Synchronization>") + "SHELL:$<$:-Xfrontend -public-autolink-library -Xfrontend swiftSynchronization>") endif() set_target_properties(FoundationEssentials PROPERTIES diff --git a/Sources/FoundationInternationalization/CMakeLists.txt b/Sources/FoundationInternationalization/CMakeLists.txt index 3255e6a09..c58f42639 100644 --- a/Sources/FoundationInternationalization/CMakeLists.txt +++ b/Sources/FoundationInternationalization/CMakeLists.txt @@ -44,6 +44,8 @@ if(NOT BUILD_SHARED_LIBS) "SHELL:$<$:-Xfrontend -public-autolink-library -Xfrontend _FoundationCShims>") target_compile_options(FoundationInternationalization PRIVATE "SHELL:$<$:-Xfrontend -public-autolink-library -Xfrontend _FoundationICU>") + target_compile_options(FoundationEssentials PRIVATE + "SHELL:$<$:-Xfrontend -public-autolink-library -Xfrontend swiftSynchronization>") endif() set_target_properties(FoundationInternationalization PROPERTIES