apple / swift-atomics

Low-level atomic operations for Swift
Apache License 2.0
1.06k stars 50 forks source link

Atomics cannot be used in a Swift Package Index package with AtomicReference enabled. #64

Closed tayloraswift closed 1 year ago

tayloraswift commented 1 year ago

see https://forums.swift.org/t/swift-atomics-no-way-to-enable-atomicreference-on-linux/63169 for a more detailed explanation.

currently it is not possible to publish a valid package on the swiftpackageindex.com that depends on swift-atomics with AtomicReference enabled, because doing so requires unsafe build flags. there is no reason to require these build flags to be passed, because the swift runtime now guarantees support for doublewide compare-and-exchange anyway.

it is currently not possible to work-around the issue by patching and vendoring the swift-atomics libraries, because _AtomicShims is a C target, and cannot be aliased to a different name. therefore, the patched _AtomicShims module will always conflict with the original module during compilation. this conflict occurs because other packages, such as swift-nio, also depend on swift-atomics.

if swift-atomics were to enable AtomicReference by default and tag a minor release in the canonical apple/swift-atomics repository, libraries that depend on both swift-atomics and swift-nio would be instantly unblocked, because swift-nio specifies an open swift-atomics requirement.