Swift Compilation Hangs on Release Builds

I'm getting an issue where compiling both my macOS and iOS frameworks in Release modes (i.e., Archive) in Xcode 10.2. This happens with both Swift 4.2 and with Swift 5. I can get it to stop hanging by either:

  • Changing Compilation Mode from Whole Module to Incremental
  • Changing Optimization Level from Optimize for Speed to either Optimize for Size or No Optimization


Does anyone know what may be going on here? Is there a likely culprit in my codebase or is this just a compiler bug?

Replies

Not fixed for me!

Same here, even with xcode 10.2.1 this is still broken for me.

Right, there seems to be multiple causes for problems like this. Which brings me back to my advice from 2 Apr.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Filed bug under 50086160. Xcode 10.2.1. Code optimization set to none/incremental compilation mode settings made no positive difference. Project uses a handful of frameworks: 1Password, AFNetworking, MQTTClient, Particle, Realm.

Filed radar 50164829 for Xcode 10.2.1

yohst wrote:

Filed bug under 50086160.

jesper wrote:

Filed radar 50164829 for Xcode 10.2.1

Thanks for filing those bugs!

Reading through the analysis so far, there’s a possibility that this is being trigger by the Exclusive Access to Memory (

SWIFT_ENFORCE_EXCLUSIVE_ACCESS
) build setting. The default value for this is Full Enforcement (Runtime Checks in All Builds). If you flip that to Full Enforcement (Runtime Checks in Debug Builds Only), do you still see the hang?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Hi!


Still seeing a hang by setting Exclusive Access to Memory to Full Enforcement (Runtime Checks in Debug Builds Only). Also have tried adjusting Optimization Level and Compilation Mode as suggested to no avail...

Bummer.

Have you filed your own bug about about this? If so, what was the bug number?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

For me turning off SWIFT_DISABLE_SAFETY_CHECKS for release builds allowed release builds to complete. (Kind of annoying because I got 100x speedup over some long heavy data processing 😀 )
I'm guessing these are all from the same family of bug?
Filed radar: 50286478

Filed radar: 50286478

Thanks!

I'm guessing these are all from the same family of bug?

I do not know enough about the internals of the compiler to offer an opinion on that.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

bb

Hi! I'm facing the same issue with release builds, and enabling runtime checks in debug builds only makes the build complete as usual. As far as I understand this is a workaround, but is there something I can do/investigate in my project/sources to fix it? Or is it something related to the build system I cannot do anything about?


Thanks!

We found that to be the case – changing the exclusive access to memory setting from Runtime Checks in All Builds to Runtime Checks in Debug Builds Only made our compiles finish again. We didn't see this issue in Xcode 10.1, but it might be because the setting wasn't enabled by default back then (see this nice table someone made).


Just figured I'd share – we tried a bunch of different combinations of optimization settings, and the exclusive access to memory definitely seemed to be the culprit (❌are stalling builds, ✅are passing)


❌wholemodule, -O, legacy build system, enforced exclusive memory access (runtime checks)
✅wholemodule, -O, legacy build system, enforced exclusive memory access (compile-time only)


❌wholemodule, -O, new build system, enforced exclusive memory access (runtime checks)
✅wholemodule, -O, new build system, enforced exclusive memory access (compile-time only)


❌incremental, -O, legacy build system, enforced exclusive memory access (runtime checks)
✅incremental, -O, legacy build system, enforced exclusive memory access (compile-time only)


❌incremental, -O, new build system, enforced exclusive memory access (runtime checks)
❌incremental, -O, new build system, enforced exclusive memory access (compile-time only)

Flipping SWIFT_ENFORCE_EXCLUSIVE_ACCESS to either of the non-default settings worked for me. Thank you!

Good morning,


i just tried to run our release process with Xcode 10.3 in the hopes of getting this resolved but the release build still gets stuck at the same position. We are still building our tvOS releases on Xcode 10.1. Looking forward to a fix for this hopefully soon.

I can confirm, it is still getting stuck here using Xcode 10.3