apple / swift-atomics

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

Swift atomics fails to compile running `xcodebuild` with `OTHER_SWIFT_FLAGS` #111

Closed winston-riley-zocdoc closed 5 months ago

winston-riley-zocdoc commented 8 months ago

Problem

Swift atomics fails to compile running xcodebuild with OTHER_SWIFT_FLAGS.

For example:

$ xcodebuild build OTHER_SWIFT_FLAGS="-suppress-warnings"
...
<SNIP>/Sources/Atomics/Conformances/autogenerated/AtomicBool.swift:22:8: error: no such module 'Builtin'
import Builtin
       ^

** BUILD FAILED **

The following build commands failed:
    CompileSwift normal arm64 (in target 'Atomics' from project 'swift-atomics')
...

However removing OTHER_SWIFT_FLAGS succeeds, the target depending on swift-atomics compiles successfully.

The following command works:

$ xcodebuild build
...
** BUILD SUCCEEDED **

FWIW, any value for OTHER_SWIFT_FLAGS fails in the above way. For example xcodebuild build OTHER_SWIFT_FLAGS="baz" also fails.

Information

$ xcodebuild -version
Xcode 15.1
Build version 15C65

$ swift -version 
swift-driver version: 1.87.3 Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)

Resolved source packages:
  swift-atomics: https://github.com/apple/swift-atomics.git @ 1.2.0

Checklist

Steps to Reproduce

  1. Using the above version of Xcode create a new iOS app project
  2. Add swift atomics as a dependancy (File > Add Package Dependencies > swift-atomics)
  3. Run xcodebuild build OTHER_SWIFT_FLAGS="-suppress-warnings" 💥 , get the above error.

Expected behavior

Project compiles

Actual behavior

Project fails to compile with the following error:

<SNIP>/Sources/Atomics/Conformances/autogenerated/AtomicBool.swift:22:8: error: no such module 'Builtin'
import Builtin
       ^

** BUILD FAILED **

The following build commands failed:
    CompileSwift normal arm64 (in target 'Atomics' from project 'swift-atomics')

Thanks in advance for any help.

nicolascabaret commented 6 months ago

Hi there, we have the exact same problem and removing OTHER_SWIFT_FLAGS is non possible for us. Any update from the team ?

nicolas-christe commented 5 months ago

This is because the OTHER_SWIFT_FLAGS passed to xcodebuild replace the one internally defined in the package. You must add inherited to your command line to keep the internal flags:

xcodebuild build OTHER_SWIFT_FLAGS='$(inherited) -suppress-warnings'

winston-riley-zocdoc commented 5 months ago

Thank you for the info!