diff --git a/.github/actions/build-swift-project-macos/action.yml b/.github/actions/build-swift-project-macos/action.yml deleted file mode 100644 index 20fe020..0000000 --- a/.github/actions/build-swift-project-macos/action.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Build Swift Project - -inputs: - checkout-scheme: - description: The schema passed to utils/update-checkout - required: true - -runs: - using: "composite" - steps: - - uses: actions/checkout@v4 - with: - repository: swiftlang/swift - path: swift-project/swift - - name: Install dependencies - run: brew install ninja sccache - shell: bash - - name: Update checkout - run: | - utils/update-checkout --clone --scheme $CHECKOUT_SCHEME \ - --skip-history \ - --skip-repository swift-foundation-icu - shell: bash - working-directory: ./swift-project/swift - env: - CHECKOUT_SCHEME: ${{ inputs.checkout-scheme }} - - name: Run sccache-cache - uses: mozilla-actions/sccache-action@v0.0.9 - - name: Build Swift - run: | - utils/build-script --skip-build-benchmarks \ - --swift-darwin-supported-archs "$(uname -m)" \ - --release --swift-disable-dead-stripping \ - --bootstrapping=hosttools \ - --sccache - shell: bash - working-directory: ./swift-project/swift - env: - SCCACHE_GHA_ENABLED: "true" - - name: Create symbolic links to build directories - run: | - mkdir -p build/Default - ln -s ../Ninja-ReleaseAssert/swift-macosx-arm64 build/Default/swift - ln -s ../Ninja-ReleaseAssert/llvm-macosx-arm64 build/Default/llvm - shell: bash - working-directory: ./swift-project diff --git a/.github/actions/checkout-swift-headers/action.yml b/.github/actions/checkout-swift-headers/action.yml new file mode 100644 index 0000000..970206b --- /dev/null +++ b/.github/actions/checkout-swift-headers/action.yml @@ -0,0 +1,43 @@ +name: Checkout Swift Headers +description: | + This action checks-out certain header files from the swiftlang/swift + repository. + +inputs: + path: + description: Relative path under $GITHUB_WORKSPACE to place the repository + required: true + swift-version-major: + description: The Swift toolchain major version. + required: true + swift-version-minor: + description: The Swift toolchain minor version. + required: true + +runs: + using: "composite" + steps: + - uses: actions/checkout@v4 + with: + repository: swiftlang/swift + path: ${{ inputs.path }} + ref: release/${{ inputs.swift-version-major }}.${{ inputs.swift-version-minor }} + sparse-checkout: | + include/swift + stdlib/include + stdlib/public/SwiftShims + stdlib/public/runtime/MetadataAllocatorTags.def + - name: Write CMakeConfig.h file + run: | + cat > include/swift/Runtime/CMakeConfig.h << EOF + #ifndef SWIFT_RUNTIME_CMAKECONFIG_H + #define SWIFT_RUNTIME_CMAKECONFIG_H + #define SWIFT_VERSION_MAJOR "${SWIFT_VERSION_MAJOR}" + #define SWIFT_VERSION_MINOR "${SWIFT_VERSION_MINOR}" + #endif + EOF + shell: bash + working-directory: ${{ inputs.path }} + env: + SWIFT_VERSION_MAJOR: ${{ inputs.swift-version-major }} + SWIFT_VERSION_MINOR: ${{ inputs.swift-version-minor }} diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index d6f4a43..b590784 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -15,11 +15,10 @@ jobs: steps: - uses: actions/checkout@v4 + - uses: ./.github/actions/checkout-swift-headers with: - path: Compute - - uses: ./Compute/.github/actions/build-swift-project-macos - with: - checkout-scheme: release/6.2 + path: Checkouts/swift + swift-version-major: 6 + swift-version-minor: 2 - name: Build run: swift build - working-directory: ./Compute diff --git a/.gitignore b/.gitignore index 4533008..307a868 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,6 @@ # Swift .build .swiftpm + +# Dependencies +Checkouts \ No newline at end of file diff --git a/CompatibilityTesting/Package.resolved b/CompatibilityTesting/Package.resolved new file mode 100644 index 0000000..d464acd --- /dev/null +++ b/CompatibilityTesting/Package.resolved @@ -0,0 +1,42 @@ +{ + "originHash" : "99b9ec1488c0b4ba695beea55b0592bae3ae146eb56306a8661f37dd36b69cad", + "pins" : [ + { + "identity" : "darwinprivateframeworks", + "kind" : "remoteSourceControl", + "location" : "https://github.com/OpenSwiftUIProject/DarwinPrivateFrameworks", + "state" : { + "revision" : "5eb0f26ea5a5bbd5068f6b3daf3a97dd3682b234", + "version" : "0.0.4" + } + }, + { + "identity" : "semaphore", + "kind" : "remoteSourceControl", + "location" : "https://github.com/groue/Semaphore", + "state" : { + "revision" : "2543679282aa6f6c8ecf2138acd613ed20790bc2", + "version" : "0.1.0" + } + }, + { + "identity" : "swift-algorithms", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-algorithms", + "state" : { + "revision" : "87e50f483c54e6efd60e885f7f5aa946cee68023", + "version" : "1.2.1" + } + }, + { + "identity" : "swift-numerics", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-numerics.git", + "state" : { + "revision" : "0c0290ff6b24942dadb83a929ffaaa1481df04a2", + "version" : "1.1.1" + } + } + ], + "version" : 3 +} diff --git a/CompatibilityTesting/Package.swift b/CompatibilityTesting/Package.swift new file mode 100644 index 0000000..7e4c23a --- /dev/null +++ b/CompatibilityTesting/Package.swift @@ -0,0 +1,68 @@ +// swift-tools-version: 6.2 + +import PackageDescription + +let swiftCheckoutPath = "\(Context.packageDirectory)/Checkouts/swift" + +var dependencies: [Package.Dependency] = [ + .package(name: "Compute", path: ".."), + .package(url: "https://github.com/apple/swift-algorithms", from: "1.2.0"), + .package(url: "https://github.com/groue/Semaphore", from: "0.1.0"), +] + +if let useLocalDepsEnv = Context.environment["COMPUTE_USE_LOCAL_DEPS"], !useLocalDepsEnv.isEmpty { + let root: String + if useLocalDepsEnv == "1" { + root = ".." + } else { + root = useLocalDepsEnv + } + dependencies += + [ + .package( + name: "DarwinPrivateFrameworks", + path: "\(root)/DarwinPrivateFrameworks" + ) + ] +} else { + dependencies += + [ + .package( + url: "https://github.com/OpenSwiftUIProject/DarwinPrivateFrameworks", + from: "0.0.4" + ) + ] +} + +let package = Package( + name: "CompatibilityTesting", + platforms: [.macOS(.v26)], + dependencies: dependencies, + targets: [ + .target(name: "CompatibilityTesting"), + .testTarget( + name: "ComputeCompatibilityTests", + dependencies: [ + .product(name: "_ComputeTestSupport", package: "Compute"), + .product(name: "AttributeGraph", package: "DarwinPrivateFrameworks"), + .product(name: "Algorithms", package: "swift-algorithms"), + .product(name: "Semaphore", package: "Semaphore"), + ], + swiftSettings: [ + .interoperabilityMode(.Cxx), + .enableExperimentalFeature("Extern"), + ], + linkerSettings: [.linkedLibrary("swiftDemangle")] + ), + .testTarget( + name: "ComputeLayoutDescriptorCompatibilityTests", + dependencies: [ + .product(name: "AttributeGraph", package: "DarwinPrivateFrameworks") + ], + swiftSettings: [ + .enableExperimentalFeature("Extern") + ], + linkerSettings: [.linkedLibrary("swiftDemangle")] + ) + ] +) diff --git a/CompatibilityTesting/Sources/CompatibilityTesting/empty.swift b/CompatibilityTesting/Sources/CompatibilityTesting/empty.swift new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/CompatibilityTesting/Sources/CompatibilityTesting/empty.swift @@ -0,0 +1 @@ + diff --git a/CompatibilityTesting/Tests/ComputeCompatibilityTests/Shared b/CompatibilityTesting/Tests/ComputeCompatibilityTests/Shared new file mode 120000 index 0000000..c0a9b32 --- /dev/null +++ b/CompatibilityTesting/Tests/ComputeCompatibilityTests/Shared @@ -0,0 +1 @@ +../../../Tests/ComputeTests/Shared \ No newline at end of file diff --git a/Tests/ComputeCompatibilityTests/Shims.swift b/CompatibilityTesting/Tests/ComputeCompatibilityTests/Shims.swift similarity index 100% rename from Tests/ComputeCompatibilityTests/Shims.swift rename to CompatibilityTesting/Tests/ComputeCompatibilityTests/Shims.swift diff --git a/CompatibilityTesting/Tests/ComputeLayoutDescriptorCompatibilityTests/Shared b/CompatibilityTesting/Tests/ComputeLayoutDescriptorCompatibilityTests/Shared new file mode 120000 index 0000000..1b1117c --- /dev/null +++ b/CompatibilityTesting/Tests/ComputeLayoutDescriptorCompatibilityTests/Shared @@ -0,0 +1 @@ +../../../Tests/ComputeLayoutDescriptorTests/Shared \ No newline at end of file diff --git a/Tests/ComputeLayoutDescriptorCompatibilityTests/Shims.swift b/CompatibilityTesting/Tests/ComputeLayoutDescriptorCompatibilityTests/Shims.swift similarity index 100% rename from Tests/ComputeLayoutDescriptorCompatibilityTests/Shims.swift rename to CompatibilityTesting/Tests/ComputeLayoutDescriptorCompatibilityTests/Shims.swift diff --git a/Package.resolved b/Package.resolved index cdce0b4..7953144 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,15 +1,6 @@ { - "originHash" : "4cf189cb4efdb66c68fe77b7823a66ab1b93e0017d80eccbae8ac327811f76ec", + "originHash" : "926e2fd9fc565c75f905ebf94506371af15cd1c2e0580b57c97fb499241158be", "pins" : [ - { - "identity" : "darwinprivateframeworks", - "kind" : "remoteSourceControl", - "location" : "https://github.com/OpenSwiftUIProject/DarwinPrivateFrameworks", - "state" : { - "revision" : "5eb0f26ea5a5bbd5068f6b3daf3a97dd3682b234", - "version" : "0.0.4" - } - }, { "identity" : "semaphore", "kind" : "remoteSourceControl", diff --git a/Package.swift b/Package.swift index a66f1a3..848c855 100644 --- a/Package.swift +++ b/Package.swift @@ -2,76 +2,22 @@ import PackageDescription -let swiftProjectPath = "\(Context.packageDirectory)/../swift-project" +let swiftCheckoutPath = "\(Context.packageDirectory)/Checkouts/swift" var dependencies: [Package.Dependency] = [ .package(url: "https://github.com/apple/swift-algorithms", from: "1.2.0"), .package(url: "https://github.com/groue/Semaphore", from: "0.1.0"), ] -if let useLocalDepsEnv = Context.environment["COMPUTE_USE_LOCAL_DEPS"], !useLocalDepsEnv.isEmpty { - let root: String - if useLocalDepsEnv == "1" { - root = ".." - } else { - root = useLocalDepsEnv - } - dependencies += - [ - .package( - name: "DarwinPrivateFrameworks", - path: "\(root)/DarwinPrivateFrameworks" - ) - ] -} else { - dependencies += - [ - .package( - url: "https://github.com/OpenSwiftUIProject/DarwinPrivateFrameworks", - from: "0.0.4" - ) - ] -} - -extension Target { - fileprivate static func swiftRuntimeTarget( - name: String, - dependencies: [Dependency] = [], - path: String? = nil, - sources: [String]? = nil, - cxxSettings: [CXXSetting] = [] - ) -> Target { - .target( - name: name, - dependencies: dependencies, - path: path ?? "Sources/\(name)", - sources: sources, - cxxSettings: [ - .unsafeFlags([ - "-static", - "-DCOMPILED_WITH_SWIFT", - "-DPURE_BRIDGING_MODE", - "-UIBOutlet", "-UIBAction", "-UIBInspectable", - "-isystem", "\(swiftProjectPath)/swift/include", - "-isystem", "\(swiftProjectPath)/swift/stdlib/public/SwiftShims", - "-isystem", "\(swiftProjectPath)/swift/stdlib/public/runtime", - "-isystem", "\(swiftProjectPath)/llvm-project/llvm/include", - "-isystem", "\(swiftProjectPath)/llvm-project/clang/include", - "-isystem", "\(swiftProjectPath)/build/Default/swift/include", - "-isystem", "\(swiftProjectPath)/build/Default/llvm/include", - "-isystem", "\(swiftProjectPath)/build/Default/llvm/tools/clang/include", - "-DLLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING", - ]) - ] + cxxSettings - ) - } -} - let package = Package( name: "Compute", platforms: [.macOS(.v26)], products: [ - .library(name: "Compute", targets: ["Compute"]) + .library(name: "Compute", targets: ["Compute"]), + .library(name: "_ComputeTestSupport", targets: ["_ComputeTestSupport"]) + ], + traits: [ + .trait(name: "CompatibilityModeAttributeGraphV6") ], dependencies: dependencies, targets: [ @@ -109,20 +55,6 @@ let package = Package( ], linkerSettings: [.linkedLibrary("swiftDemangle")] ), - .testTarget( - name: "ComputeCompatibilityTests", - dependencies: [ - "_ComputeTestSupport", - .product(name: "AttributeGraph", package: "DarwinPrivateFrameworks"), - .product(name: "Algorithms", package: "swift-algorithms"), - .product(name: "Semaphore", package: "Semaphore"), - ], - swiftSettings: [ - .interoperabilityMode(.Cxx), - .enableExperimentalFeature("Extern"), - ], - linkerSettings: [.linkedLibrary("swiftDemangle")] - ), .testTarget( name: "ComputeLayoutDescriptorTests", dependencies: [ @@ -133,20 +65,21 @@ let package = Package( ], linkerSettings: [.linkedLibrary("swiftDemangle")] ), - .testTarget( - name: "ComputeLayoutDescriptorCompatibilityTests", - dependencies: [ - .product(name: "AttributeGraph", package: "DarwinPrivateFrameworks") - ], - swiftSettings: [ - .enableExperimentalFeature("Extern") - ], - linkerSettings: [.linkedLibrary("swiftDemangle")] - ), - .swiftRuntimeTarget( + .target( name: "ComputeCxx", dependencies: ["Utilities", "ComputeCxxSwiftSupport"], - cxxSettings: [.headerSearchPath(""), .unsafeFlags(["-Wno-elaborated-enum-base"])] + cxxSettings: [ + .headerSearchPath(""), + .unsafeFlags([ + "-Wno-elaborated-enum-base", + "-static", + "-DCOMPILED_WITH_SWIFT", + "-DPURE_BRIDGING_MODE", + "-isystem", "\(swiftCheckoutPath)/include", + "-isystem", "\(swiftCheckoutPath)/stdlib/include", + "-isystem", "\(swiftCheckoutPath)/stdlib/public/SwiftShims" + ]) + ] ), .target(name: "ComputeCxxSwiftSupport"), .target(name: "_ComputeTestSupport"), diff --git a/Sources/Compute/Attribute/AnyAttribute.swift b/Sources/Compute/Attribute/AnyAttribute.swift index f552712..1c9e32f 100644 --- a/Sources/Compute/Attribute/AnyAttribute.swift +++ b/Sources/Compute/Attribute/AnyAttribute.swift @@ -10,7 +10,7 @@ extension Graph { _ attribute: AnyAttribute, type: Metadata, invalidating: Bool, - modify: (UnsafeMutableRawPointer) -> Void + modify: @escaping (UnsafeMutableRawPointer) -> Void ) } @@ -35,8 +35,10 @@ extension AnyAttribute { } public func mutateBody(as type: Body.Type, invalidating: Bool, _ mutator: (inout Body) -> Void) { - Graph.mutateAttribute(self, type: Metadata(type), invalidating: invalidating) { pointer in - mutator(&pointer.assumingMemoryBound(to: Body.self).pointee) + withoutActuallyEscaping(mutator) { escapingMutator in + Graph.mutateAttribute(self, type: Metadata(type), invalidating: invalidating) { pointer in + escapingMutator(&pointer.assumingMemoryBound(to: Body.self).pointee) + } } } diff --git a/Sources/Compute/Attribute/Attribute.swift b/Sources/Compute/Attribute/Attribute.swift index 10b5895..443ea44 100644 --- a/Sources/Compute/Attribute/Attribute.swift +++ b/Sources/Compute/Attribute/Attribute.swift @@ -45,9 +45,15 @@ public struct Attribute { let typeID = graphContext.internAttributeType( type: Metadata(Body.self) ) { + let bodyType: _AttributeBody.Type + #if CompatibilityModeAttributeGraphV6 + bodyType = Body.self + #else + bodyType = flags.contains(.external) ? _External.self : Body.self + #endif let attributeType = _AttributeType( - selfType: flags.contains(.external) ? _External.self : Body.self, + selfType: bodyType, valueType: Value.self, flags: flags, update: update() diff --git a/Sources/ComputeCxx/Graph/Graph.cpp b/Sources/ComputeCxx/Graph/Graph.cpp index c629df8..a562962 100644 --- a/Sources/ComputeCxx/Graph/Graph.cpp +++ b/Sources/ComputeCxx/Graph/Graph.cpp @@ -801,7 +801,7 @@ void Graph::indirect_attribute_set(data::ptr indirect_node, Attrib } uint64_t source_subgraph_id = source && !source.is_nil() ? source.subgraph()->subgraph_id() : 0; - indirect_node->modify(WeakAttributeID(source, source_subgraph_id), resolved_source.offset()); + indirect_node->modify(WeakAttributeID(source, uint32_t(source_subgraph_id)), resolved_source.offset()); indirect_node->set_traverses_contexts(AttributeID(indirect_node).subgraph()->context_id() != source.subgraph()->context_id()); diff --git a/Sources/ComputeCxx/Swift/Metadata.cpp b/Sources/ComputeCxx/Swift/Metadata.cpp index 9562463..f6b9688 100644 --- a/Sources/ComputeCxx/Swift/Metadata.cpp +++ b/Sources/ComputeCxx/Swift/Metadata.cpp @@ -2,7 +2,6 @@ #include #include -#include #include #include #include @@ -273,12 +272,11 @@ const equatable_witness_table *metadata::equatable() const { if (!nsobject_metadata) { return nullptr; } - auto witness_table = - swift_conformsToProtocol(nsobject_metadata, &::swift::equatable_support::EquatableProtocolDescriptor); + auto witness_table = swift_conformsToProtocol(nsobject_metadata, EquatableProtocolDescriptor); return reinterpret_cast(witness_table); }(); auto conformance = reinterpret_cast( - swift_conformsToProtocol(this, &::swift::equatable_support::EquatableProtocolDescriptor)); + swift_conformsToProtocol(this, &EquatableProtocolDescriptor)); if (conformance == nsobject_conformance) { return nullptr; } @@ -288,7 +286,7 @@ const equatable_witness_table *metadata::equatable() const { case ::swift::MetadataKind::Enum: case ::swift::MetadataKind::Optional: case ::swift::MetadataKind::Tuple: { - auto witness_table = swift_conformsToProtocol(this, &::swift::equatable_support::EquatableProtocolDescriptor); + auto witness_table = swift_conformsToProtocol(this, &EquatableProtocolDescriptor); return reinterpret_cast(witness_table); } default: diff --git a/Sources/ComputeCxx/Swift/Metadata.h b/Sources/ComputeCxx/Swift/Metadata.h index aa85da1..a6366fc 100644 --- a/Sources/ComputeCxx/Swift/Metadata.h +++ b/Sources/ComputeCxx/Swift/Metadata.h @@ -1,18 +1,24 @@ #pragma once #include -#include +#include #include #include "Comparison/LayoutDescriptor.h" CF_ASSUME_NONNULL_BEGIN +CF_EXPORT +const void *PROTOCOL_DESCR_SYM(SQ); + namespace AG { namespace swift { +static constexpr auto &EquatableProtocolDescriptor = PROTOCOL_DESCR_SYM(SQ); + +struct equatable_witness_table; + using opaque_value = ::swift::OpaqueValue; -using equatable_witness_table = ::swift::equatable_support::EquatableWitnessTable; class metadata_visitor; class context_descriptor; diff --git a/Sources/ComputeCxx/Swift/SwiftShims.h b/Sources/ComputeCxx/Swift/SwiftShims.h index 1749209..e9031e0 100644 --- a/Sources/ComputeCxx/Swift/SwiftShims.h +++ b/Sources/ComputeCxx/Swift/SwiftShims.h @@ -3,7 +3,6 @@ #include #include #include -#include #include "ComputeCxx/AGSwiftSupport.h" @@ -13,7 +12,7 @@ CF_EXTERN_C_BEGIN AG_SWIFT_CC(swift) bool AGDispatchEquatable(const void *lhs_value, const void *rhs_value, const ::swift::Metadata *type, - const ::swift::equatable_support::EquatableWitnessTable *wt); + const AG::swift::equatable_witness_table *wt); #ifdef __OBJC__ AG_SWIFT_CC(swift) diff --git a/Tests/ComputeCompatibilityTests/Shared b/Tests/ComputeCompatibilityTests/Shared deleted file mode 120000 index 4b2f6a9..0000000 --- a/Tests/ComputeCompatibilityTests/Shared +++ /dev/null @@ -1 +0,0 @@ -../ComputeTests/Shared \ No newline at end of file diff --git a/Tests/ComputeLayoutDescriptorCompatibilityTests/Shared b/Tests/ComputeLayoutDescriptorCompatibilityTests/Shared deleted file mode 120000 index 775a806..0000000 --- a/Tests/ComputeLayoutDescriptorCompatibilityTests/Shared +++ /dev/null @@ -1 +0,0 @@ -../ComputeLayoutDescriptorTests/Shared \ No newline at end of file diff --git a/Tests/ComputeLayoutDescriptorTests/Shared/PrefetchCompareValuesTests.swift b/Tests/ComputeLayoutDescriptorTests/Shared/PrefetchCompareValuesTests.swift index bbc6712..4f3e952 100644 --- a/Tests/ComputeLayoutDescriptorTests/Shared/PrefetchCompareValuesTests.swift +++ b/Tests/ComputeLayoutDescriptorTests/Shared/PrefetchCompareValuesTests.swift @@ -57,7 +57,6 @@ struct PrefetchCompareValuesTests { @Test func layoutForNever() async { - setenv("AG_PREFETCH_LAYOUTS", "1", 1) setenv("AG_ASYNC_LAYOUTS", "0", 1) setenv("AG_PRINT_LAYOUTS", "1", 1) @@ -105,7 +104,6 @@ struct PrefetchCompareValuesTests { @Test(arguments: allOptions) func layoutForVoid(with options: ComparisonOptions) { - setenv("AG_PREFETCH_LAYOUTS", "1", 1) setenv("AG_ASYNC_LAYOUTS", "0", 1) let layout = prefetchCompareValues(of: Void.self, options: options, priority: 0) @@ -114,7 +112,6 @@ struct PrefetchCompareValuesTests { @Test func layoutForBool() async { - setenv("AG_PREFETCH_LAYOUTS", "1", 1) setenv("AG_ASYNC_LAYOUTS", "0", 1) setenv("AG_PRINT_LAYOUTS", "1", 1) @@ -168,7 +165,6 @@ struct PrefetchCompareValuesTests { ] as [(Any.Type, Int)] ) func layoutForNumericNonEquatable(of type: Any.Type, size: Int) async { - setenv("AG_PREFETCH_LAYOUTS", "1", 1) setenv("AG_ASYNC_LAYOUTS", "0", 1) setenv("AG_PRINT_LAYOUTS", "1", 1) @@ -188,7 +184,6 @@ struct PrefetchCompareValuesTests { @Test func layoutForIntEquatable() async { - setenv("AG_PREFETCH_LAYOUTS", "1", 1) setenv("AG_ASYNC_LAYOUTS", "0", 1) setenv("AG_PRINT_LAYOUTS", "1", 1) @@ -211,7 +206,6 @@ struct PrefetchCompareValuesTests { @Test func layoutForDoubleEquatable() async { - setenv("AG_PREFETCH_LAYOUTS", "1", 1) setenv("AG_ASYNC_LAYOUTS", "0", 1) setenv("AG_PRINT_LAYOUTS", "1", 1) @@ -238,7 +232,6 @@ struct PrefetchCompareValuesTests { @Test func layoutForFloatEquatable() async { - setenv("AG_PREFETCH_LAYOUTS", "1", 1) setenv("AG_ASYNC_LAYOUTS", "0", 1) setenv("AG_PRINT_LAYOUTS", "1", 1) @@ -265,7 +258,6 @@ struct PrefetchCompareValuesTests { @Test func layoutForString() async { - setenv("AG_PREFETCH_LAYOUTS", "1", 1) setenv("AG_ASYNC_LAYOUTS", "0", 1) setenv("AG_PRINT_LAYOUTS", "1", 1) @@ -326,7 +318,6 @@ struct PrefetchCompareValuesTests { @Test(arguments: allOptions) func layoutForStaticString(with options: ComparisonOptions) { - setenv("AG_PREFETCH_LAYOUTS", "1", 1) setenv("AG_ASYNC_LAYOUTS", "0", 1) let layout = prefetchCompareValues(of: StaticString.self, options: options, priority: 0) @@ -348,7 +339,6 @@ struct PrefetchCompareValuesTests { @Test("Layout for struct enclosing single element equals the layout of the enclosed element") func layoutForStructEnclosingSingleElement() async { - setenv("AG_PREFETCH_LAYOUTS", "1", 1) setenv("AG_ASYNC_LAYOUTS", "0", 1) struct StructEnclosingSingleElement { @@ -395,7 +385,6 @@ struct PrefetchCompareValuesTests { @Test func layoutForTrivialStruct() async { - setenv("AG_PREFETCH_LAYOUTS", "1", 1) setenv("AG_ASYNC_LAYOUTS", "0", 1) setenv("AG_PRINT_LAYOUTS", "1", 1) @@ -455,7 +444,6 @@ struct PrefetchCompareValuesTests { @Test func layoutForStructWithAlignedElement() async { - setenv("AG_PREFETCH_LAYOUTS", "1", 1) setenv("AG_ASYNC_LAYOUTS", "0", 1) setenv("AG_PRINT_LAYOUTS", "1", 1) @@ -566,7 +554,6 @@ struct PrefetchCompareValuesTests { @Test func layoutForStructWithComplexProperty() async { - setenv("AG_PREFETCH_LAYOUTS", "1", 1) setenv("AG_ASYNC_LAYOUTS", "0", 1) setenv("AG_PRINT_LAYOUTS", "1", 1) @@ -701,7 +688,6 @@ struct PrefetchCompareValuesTests { @Test(arguments: allOptions) func layoutForEmptyClass(with options: ComparisonOptions) { - setenv("AG_PREFETCH_LAYOUTS", "1", 1) setenv("AG_ASYNC_LAYOUTS", "0", 1) class EmptyClass {} @@ -712,7 +698,6 @@ struct PrefetchCompareValuesTests { @Test(arguments: allOptions) func layoutForTrivialClass(with options: ComparisonOptions) { - setenv("AG_PREFETCH_LAYOUTS", "1", 1) setenv("AG_ASYNC_LAYOUTS", "0", 1) class TrivialClass { @@ -725,7 +710,6 @@ struct PrefetchCompareValuesTests { @Test(arguments: allOptions) func layoutForStructWithWeakVar(with options: ComparisonOptions) { - setenv("AG_PREFETCH_LAYOUTS", "1", 1) setenv("AG_ASYNC_LAYOUTS", "0", 1) class EmptyClass {} @@ -744,7 +728,6 @@ struct PrefetchCompareValuesTests { @Test(arguments: allOptions) func layoutForEmptyEnum(with options: ComparisonOptions) { - setenv("AG_PREFETCH_LAYOUTS", "1", 1) setenv("AG_ASYNC_LAYOUTS", "0", 1) enum EmptyEnum {} @@ -755,7 +738,6 @@ struct PrefetchCompareValuesTests { @Test func layoutForBasicEnum() async { - setenv("AG_PREFETCH_LAYOUTS", "1", 1) setenv("AG_ASYNC_LAYOUTS", "0", 1) setenv("AG_PRINT_LAYOUTS", "1", 1) @@ -808,7 +790,6 @@ struct PrefetchCompareValuesTests { @Test func layoutForIntEnum() async { - setenv("AG_PREFETCH_LAYOUTS", "1", 1) setenv("AG_ASYNC_LAYOUTS", "0", 1) setenv("AG_PRINT_LAYOUTS", "1", 1) @@ -861,7 +842,6 @@ struct PrefetchCompareValuesTests { @Test func layoutForTaggedUnionEnum() async { - setenv("AG_PREFETCH_LAYOUTS", "1", 1) setenv("AG_ASYNC_LAYOUTS", "0", 1) setenv("AG_PRINT_LAYOUTS", "1", 1) @@ -987,7 +967,6 @@ struct PrefetchCompareValuesTests { @Test func layoutForIndirectEnum() async { - setenv("AG_PREFETCH_LAYOUTS", "1", 1) setenv("AG_ASYNC_LAYOUTS", "0", 1) setenv("AG_PRINT_LAYOUTS", "1", 1) @@ -1095,7 +1074,6 @@ struct PrefetchCompareValuesTests { @Test func layoutForIndirectEnumCase() async { - setenv("AG_PREFETCH_LAYOUTS", "1", 1) setenv("AG_ASYNC_LAYOUTS", "0", 1) setenv("AG_PRINT_LAYOUTS", "1", 1) @@ -1208,7 +1186,6 @@ struct PrefetchCompareValuesTests { @Test func layoutForTuple() async { - setenv("AG_PREFETCH_LAYOUTS", "1", 1) setenv("AG_ASYNC_LAYOUTS", "0", 1) setenv("AG_PRINT_LAYOUTS", "1", 1) @@ -1288,7 +1265,6 @@ struct PrefetchCompareValuesTests { @Test func layoutForTupleWithAlignedElement() async { - setenv("AG_PREFETCH_LAYOUTS", "1", 1) setenv("AG_ASYNC_LAYOUTS", "0", 1) setenv("AG_PRINT_LAYOUTS", "1", 1) @@ -1399,7 +1375,6 @@ struct PrefetchCompareValuesTests { @Test func layoutForArray() async { - setenv("AG_PREFETCH_LAYOUTS", "1", 1) setenv("AG_ASYNC_LAYOUTS", "0", 1) setenv("AG_PRINT_LAYOUTS", "1", 1) @@ -1460,7 +1435,6 @@ struct PrefetchCompareValuesTests { @Test(arguments: allOptions) func layoutForArrayOfNotEquatable(with options: ComparisonOptions) { - setenv("AG_PREFETCH_LAYOUTS", "1", 1) setenv("AG_ASYNC_LAYOUTS", "0", 1) class NotEquatable {} @@ -1471,7 +1445,6 @@ struct PrefetchCompareValuesTests { @Test func layoutForDictionary() async { - setenv("AG_PREFETCH_LAYOUTS", "1", 1) setenv("AG_ASYNC_LAYOUTS", "0", 1) setenv("AG_PRINT_LAYOUTS", "1", 1) @@ -1532,7 +1505,6 @@ struct PrefetchCompareValuesTests { @Test(arguments: allOptions) func layoutForDictionaryOfNotEquatable(with options: ComparisonOptions) { - setenv("AG_PREFETCH_LAYOUTS", "1", 1) setenv("AG_ASYNC_LAYOUTS", "0", 1) class NotEquatable {} @@ -1547,7 +1519,6 @@ struct PrefetchCompareValuesTests { @Test func layoutForSet() async { - setenv("AG_PREFETCH_LAYOUTS", "1", 1) setenv("AG_ASYNC_LAYOUTS", "0", 1) setenv("AG_PRINT_LAYOUTS", "1", 1) @@ -1613,7 +1584,6 @@ struct PrefetchCompareValuesTests { @Test func layoutForEquatableStruct() async { - setenv("AG_PREFETCH_LAYOUTS", "1", 1) setenv("AG_ASYNC_LAYOUTS", "0", 1) setenv("AG_PRINT_LAYOUTS", "1", 1) @@ -1668,7 +1638,6 @@ struct PrefetchCompareValuesTests { @Test func layoutForEquatableClass() async { - setenv("AG_PREFETCH_LAYOUTS", "1", 1) setenv("AG_ASYNC_LAYOUTS", "0", 1) setenv("AG_PRINT_LAYOUTS", "1", 1) @@ -1741,7 +1710,6 @@ struct PrefetchCompareValuesTests { @Test func layoutForAny() async { - setenv("AG_PREFETCH_LAYOUTS", "1", 1) setenv("AG_ASYNC_LAYOUTS", "0", 1) setenv("AG_PRINT_LAYOUTS", "1", 1) @@ -1803,7 +1771,6 @@ struct PrefetchCompareValuesTests { @Test func layoutForAnyError() async { - setenv("AG_PREFETCH_LAYOUTS", "1", 1) setenv("AG_ASYNC_LAYOUTS", "0", 1) setenv("AG_PRINT_LAYOUTS", "1", 1) @@ -1882,7 +1849,6 @@ struct PrefetchCompareValuesTests { @Test func layoutForFunction() async { - setenv("AG_PREFETCH_LAYOUTS", "1", 1) setenv("AG_ASYNC_LAYOUTS", "0", 1) setenv("AG_PRINT_LAYOUTS", "1", 1) diff --git a/Tests/ComputeTests/Shared/Attribute/AttributeTests.swift b/Tests/ComputeTests/Shared/Attribute/AttributeTests.swift index c75f50f..db8ec0c 100644 --- a/Tests/ComputeTests/Shared/Attribute/AttributeTests.swift +++ b/Tests/ComputeTests/Shared/Attribute/AttributeTests.swift @@ -34,17 +34,28 @@ struct AttributeTests { ) let attributeType = attribute.identifier.info.type.pointee - #expect(attributeType.self_id == Metadata(_External.self)) + #if CompatibilityModeAttributeGraphV6 + #expect(attributeType.self_id == Metadata(External.self)) + #else + #expect(attributeType.self_id == Metadata(_External.self)) + #endif #expect(attributeType.value_id == Metadata(Int.self)) #expect(attributeType.flags == [.external, .comparisonModeEquatableAlways]) #expect(attributeType.internal_offset == 28) #expect(attributeType.value_layout == expectedlayout) - let attributeBody = unsafeBitCast( - _External.self as any _AttributeBody.Type, - to: (type: Metadata, witnessTable: UnsafeRawPointer).self - ) + #if CompatibilityModeAttributeGraphV6 + let attributeBody = unsafeBitCast( + External.self as any _AttributeBody.Type, + to: (type: Metadata, witnessTable: UnsafeRawPointer).self + ) + #else + let attributeBody = unsafeBitCast( + _External.self as any _AttributeBody.Type, + to: (type: Metadata, witnessTable: UnsafeRawPointer).self + ) + #endif #expect(attributeType.body_conformance.type_id == attributeBody.type) #expect(attributeType.body_conformance.witness_table == attributeBody.witnessTable) } @@ -69,17 +80,28 @@ struct AttributeTests { ) let attributeType = attribute.identifier.info.type.pointee - #expect(attributeType.self_id == Metadata(_External.self)) + #if CompatibilityModeAttributeGraphV6 + #expect(attributeType.self_id == Metadata(External.self)) + #else + #expect(attributeType.self_id == Metadata(_External.self)) + #endif #expect(attributeType.value_id == Metadata(Int.self)) #expect(attributeType.flags == [.external, .comparisonModeEquatableAlways]) #expect(attributeType.internal_offset == 28) #expect(attributeType.value_layout == expectedlayout) - let attributeBody = unsafeBitCast( - _External.self as any _AttributeBody.Type, - to: (type: Metadata, witnessTable: UnsafeRawPointer).self - ) + #if CompatibilityModeAttributeGraphV6 + let attributeBody = unsafeBitCast( + External.self as any _AttributeBody.Type, + to: (type: Metadata, witnessTable: UnsafeRawPointer).self + ) + #else + let attributeBody = unsafeBitCast( + _External.self as any _AttributeBody.Type, + to: (type: Metadata, witnessTable: UnsafeRawPointer).self + ) + #endif #expect(attributeType.body_conformance.type_id == attributeBody.type) #expect(attributeType.body_conformance.witness_table == attributeBody.witnessTable) } diff --git a/Tests/ComputeTests/Shared/Graph/GraphTests.swift b/Tests/ComputeTests/Shared/Graph/GraphTests.swift index 0a39792..c27f60d 100644 --- a/Tests/ComputeTests/Shared/Graph/GraphTests.swift +++ b/Tests/ComputeTests/Shared/Graph/GraphTests.swift @@ -301,7 +301,7 @@ struct GraphTests { @Test func initialDescription() async throws { - await try #require(processExitsWith: .success) { + try await #require(processExitsWith: .success) { let description = try #require( Graph.description(nil, options: [DescriptionOption.format: "graph/dict"] as NSDictionary) @@ -336,7 +336,7 @@ struct GraphTests { // which we can't predict deterministically. @Test func graphDescription() async throws { - await try #require(processExitsWith: .success) { + try await #require(processExitsWith: .success) { let graph = Graph() let subgraph = Subgraph(graph: graph) diff --git a/Tests/ComputeTests/Shared/Runtime/MetadataTests.swift b/Tests/ComputeTests/Shared/Runtime/MetadataTests.swift index cc65771..aa505fa 100644 --- a/Tests/ComputeTests/Shared/Runtime/MetadataTests.swift +++ b/Tests/ComputeTests/Shared/Runtime/MetadataTests.swift @@ -17,7 +17,7 @@ struct MetadataTests { (TestTuple.self, "(String, Int)"), (TestFunction.self, "(String) -> Int"), (TestExistential.self, "Hashable"), - (TestConstrainedExistential.self, "<<< invalid type >>>"), + (TestConstrainedExistential.self, "any Sequence"), (TestComposedExistential.self, "CustomStringConvertible & Hashable"), (TestMetatype.self, "TestClass.Type"), (TestObjCClass.self, "NSDate"),