From 34d14a0676929bb59c5791ee39baddc6bceb71d6 Mon Sep 17 00:00:00 2001 From: Jeremy Schonfeld Date: Wed, 3 Dec 2025 15:04:40 -0800 Subject: [PATCH 1/2] Only rename __DataStorage.replaceBytes symbol on FOUNDATION_FRAMEWORK --- .../FoundationEssentials/Data/Representations/DataStorage.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sources/FoundationEssentials/Data/Representations/DataStorage.swift b/Sources/FoundationEssentials/Data/Representations/DataStorage.swift index 146da906a..5415dfe5b 100644 --- a/Sources/FoundationEssentials/Data/Representations/DataStorage.swift +++ b/Sources/FoundationEssentials/Data/Representations/DataStorage.swift @@ -345,7 +345,9 @@ internal final class __DataStorage : @unchecked Sendable { // This ABI entrypoint was original written using NSRange instead of Range. The ABI contract of this function must continue to accept NSRange values from code inlined into callers // To avoid using the real NSRange type at the source level, we use a tuple that is layout-compatible with NSRange instead and use @_silgen_name to preserve the original symbol name that includes "NSRange" @usableFromInline + #if FOUNDATION_FRAMEWORK @_silgen_name("$s10Foundation13__DataStorageC12replaceBytes2in4with6lengthySo8_NSRangeV_SVSgSitF") + #endif internal func replaceBytes(in range_: (location: Int, length: Int), with replacementBytes: UnsafeRawPointer?, length replacementLength: Int) { let range = (location: range_.location - _offset, length: range_.length) let currentLength = _length From f1aabe9d157bfee068b62946180552a2b68080aa Mon Sep 17 00:00:00 2001 From: Jeremy Schonfeld Date: Wed, 3 Dec 2025 16:08:32 -0800 Subject: [PATCH 2/2] Update Sources/FoundationEssentials/Data/Representations/DataStorage.swift Co-authored-by: Guillaume Lessard --- .../Data/Representations/DataStorage.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/FoundationEssentials/Data/Representations/DataStorage.swift b/Sources/FoundationEssentials/Data/Representations/DataStorage.swift index 5415dfe5b..bd5f055fe 100644 --- a/Sources/FoundationEssentials/Data/Representations/DataStorage.swift +++ b/Sources/FoundationEssentials/Data/Representations/DataStorage.swift @@ -342,8 +342,8 @@ internal final class __DataStorage : @unchecked Sendable { self.replaceBytes(in: (range_.lowerBound, range_.upperBound &- range_.lowerBound), with: replacementBytes, length: replacementLength) } - // This ABI entrypoint was original written using NSRange instead of Range. The ABI contract of this function must continue to accept NSRange values from code inlined into callers - // To avoid using the real NSRange type at the source level, we use a tuple that is layout-compatible with NSRange instead and use @_silgen_name to preserve the original symbol name that includes "NSRange" + // This utility function was originally written in terms of NSRange instead of Range. On Darwin platforms, it is also an ABI entry point so we need to continue accepting NSRange values from code that has been inlined into callers. + // To avoid requiring the use of NSRange in source, we instead use a tuple that is layout-compatible with NSRange. On Darwin platforms, we can use `@_silgen_name to preserve the original symbol name that refers to NSRange. @usableFromInline #if FOUNDATION_FRAMEWORK @_silgen_name("$s10Foundation13__DataStorageC12replaceBytes2in4with6lengthySo8_NSRangeV_SVSgSitF")