From ebfeae3589292fa3509aace69f575982260c956d Mon Sep 17 00:00:00 2001 From: Cristian Magherusan-Stanciu Date: Wed, 23 Sep 2026 06:43:51 +0200 Subject: [PATCH 1/2] build: allow cross toolchains without typed allocation flags --- Package.swift | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Package.swift b/Package.swift index 44368603..89368c18 100644 --- a/Package.swift +++ b/Package.swift @@ -148,23 +148,25 @@ let useLocalDeps = envBoolValue("USE_LOCAL_DEPS") let danceUIGraphCondition = envBoolValue("OPENATTRIBUTESHIMS_DANCEUIGRAPH", default: false) let computeCondition = envBoolValue("OPENATTRIBUTESHIMS_COMPUTE", default: false) let attributeGraphCondition = envBoolValue("OPENATTRIBUTESHIMS_ATTRIBUTEGRAPH", default: false) +// Cross-compiling for Darwin can use a Clang without Apple's typed-allocation flags. +let typedMemoryOperations = envBoolValue("TYPED_MEMORY_OPERATIONS", default: true) // MARK: - Shared Settings var sharedCSettings: [CSetting] = [ .define("NDEBUG", .when(configuration: .release)), - // Rewrite malloc() to malloc_type_malloc() for type-isolated allocation buckets (xzone malloc). - .unsafeFlags(["-ftyped-memory-operations"], .when(platforms: .darwinPlatforms)), ] var sharedCxxSettings: [CXXSetting] = [ .define("NDEBUG", .when(configuration: .release)), - // Rewrite malloc() to malloc_type_malloc() for type-isolated allocation buckets (xzone malloc). - .unsafeFlags(["-ftyped-memory-operations"], .when(platforms: .darwinPlatforms)), - // Rewrite operator new/delete to typed variants (operator new(size_t, std::__type_descriptor_t)). - .unsafeFlags(["-ftyped-cxx-new-delete"], .when(platforms: .darwinPlatforms)), ] +if typedMemoryOperations { + // Keep Apple's typed allocation behavior by default for native builds. + sharedCSettings.append(.unsafeFlags(["-ftyped-memory-operations"], .when(platforms: .darwinPlatforms))) + sharedCxxSettings.append(.unsafeFlags(["-ftyped-memory-operations", "-ftyped-cxx-new-delete"], .when(platforms: .darwinPlatforms))) +} + var sharedSwiftSettings: [SwiftSetting] = [ .enableUpcomingFeature("InternalImportsByDefault"), .enableExperimentalFeature("Extern"), From 4086eb1e18e010089dabc1517257b419876437a8 Mon Sep 17 00:00:00 2001 From: Cristian Magherusan-Stanciu Date: Wed, 23 Sep 2026 08:07:33 +0200 Subject: [PATCH 2/2] Build: allow an external Swift source checkout --- Package.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index 89368c18..1e16ff26 100644 --- a/Package.swift +++ b/Package.swift @@ -136,7 +136,10 @@ let isXcodeEnv = envStringValue("__CFBundleIdentifier", searchInDomain: false) = let development = envBoolValue("DEVELOPMENT", default: false) let warningsAsErrorsCondition = envBoolValue("WERROR", default: isXcodeEnv && development) -let swiftCheckoutPath = "\(Context.packageDirectory)/Checkouts/swift" +let swiftCheckoutPath = envStringValue( + "SWIFT_CHECKOUT_PATH", + default: "\(Context.packageDirectory)/Checkouts/swift" +) let swiftCorelibsPath = envStringValue("LIB_SWIFT_PATH") ?? "\(Context.packageDirectory)/Sources/SwiftCorelibs/include" let releaseVersion = envIntValue("TARGET_RELEASE", default: 2024)