Open ShawnBaek opened 1 year ago
Hi ShawnBaek, I am having a very similar compiler error stack. I wonder how did you find out which swift files that can't be built?
I'm also experiencing this issue, it's working fine with 14.2. Every Xcode release is like a lottery now...
@ShawnBaek I'm also wondering how did you find the exact file causing the issue? As @fuermosi777 I'm also having a similar error stack but I can't find the root cause
Thank you
@ShawnBaek I cannot reproduce the crash with a Xcode 14.3 Swift 5.8 compiler. Are you sure the code in your example is not missing anything?
@fuermosi777 @corteggo The stack dump suggests that it tripped over whilst performing an optimization pass over a SIL module, which is roughly a lowered concatenation of all the files in a Swift module; I don’t know of a principled way to narrow in on this sort of crash, but if you manage to pinpoint the cause by chipping away at the codebase or have a project for us to reduce, that would be really helpful!
Thank you @AnthonyLatsis for taking the time to look into this issue, I understand this might be hard to reproduce.
After spending some time I managed to find the root cause for it, although I don't understand the exact reason of the failure.
Please find attached a project where the issue is reproducible when archiving (Release
build), so that you can try to find the root cause. If the SwiftRater
dependency is updated from 2.0.0
to 2.1.0
, the build error is gone. By comparing them (https://github.com/takecian/SwiftRater/compare/2.0.0...2.1.0) I don't see any significant difference 🤯
Please let me know if I can help somehow, although this issue seems to go far beyond my knowledge.
Sample project: OptimisationCrash.zip
I hope it helps...
I am also running into this issue with our app, and it is preventing us from archiving a build for the app store. Happy to provide logs and attempt to debug as well, but it looks exactly like the one the author posted. 14.2 archiving works fine, as already stated.
@fuermosi777 @corteggo
I found it in the Xcode build log. The compilation failed on the file, and when I removed the functions declared in the extension, the error at the time of compiling the file disappeared. However, the same compilation failure occurred in another extension file
@AnthonyLatsis Thanks for your answer
I think so. Because there was no problem with Xcode 14.2.
@corteggo @AnthonyLatsis
I can confirm the SwiftRater issue. My project is currently using SwiftRater, and I didn't realize it but we were still on version 1.9.0. After upgrading to 2.1.0, I am able to build the project with the -O flag again. Looking at the changes, the most significant i can see is that the min deployment version was added/updated.
@ShawnBaek is there any chance you are using SwiftRater in your project? If so, what version?
Thank you @AnthonyLatsis for taking the time to look into this issue, I understand this might be hard to reproduce.
After spending some time I managed to find the root cause for it, although I don't understand the exact reason of the failure.
Please find attached a project where the issue is reproducible when archiving (
Release
build), so that you can try to find the root cause. If theSwiftRater
dependency is updated from2.0.0
to2.1.0
, the build error is gone. By comparing them (takecian/SwiftRater@2.0.0...2.1.0) I don't see any significant difference 🤯Please let me know if I can help somehow, although this issue seems to go far beyond my knowledge.
Sample project: OptimisationCrash.zip
I hope it helps...
This worked for me. Thanks so much
We're running into a similar issue trying to create a RELEASE build for the App Store. In our case, we have no dependency on the SwiftRater project. Builds work fine with Xcode 14.2
I did a bit more digging around the different SwiftRater commits, and I narrowed it down. This is the first commit that works again. https://github.com/takecian/SwiftRater/commit/41725e21fc5bebeabfc5d210cabbed102f976277
In particular, if you comment out the block
@objc public enum SwiftRaterConditionsMetMode: Int {
case all
case any
}
In the SwiftRater file, it'll start throwing the compiler error. Hopefully that'll be enough to help narrow it down. I don't understand why that would cause the compiler to succeed but maybe someone more familiar with it will know. First time I've heard of adding code and the compiler works...
If you need, I can create a sample project pointing to a fork of the repo with a good commit and a bad commit.
@lilidotshi Thanks for sharing. But I don't use SwiftRater
@ShawnBaek I cannot reproduce the crash with a Xcode 14.3 Swift 5.8 compiler. Are you sure the code in your example is not missing anything?
@fuermosi777 @corteggo The stack dump suggests that it tripped over whilst performing an optimization pass over a SIL module, which is roughly a lowered concatenation of all the files in a Swift module; I don’t know of a principled way to narrow in on this sort of crash, but if you manage to pinpoint the cause by chipping away at the codebase or have a project for us to reduce, that would be really helpful!
@AnthonyLatsis I have an example https://github.com/pirder/OptimisationCrashDemo
Here's a swiftpm version of that repro case, repros with swift build -c release
crash.zip
I still haven't resolved the issue. There are a total of 286 unused functions in our project. Is this causing the problem?
Here is our build settings
OTHER_CPLUSPLUSFLAGS: >-
$(OTHER_CFLAGS)
"-fcxx-modules"
IPHONEOS_DEPLOYMENT_TARGET: 15.0
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS: YES
SWIFT_VERSION: 5.9
TARGETED_DEVICE_FAMILY: 1, 2
PRODUCT_MODULE_NAME: $(TARGET_NAME)
STRIP_INSTALLED_PRODUCT: YES
STRIPFLAGS: "-rSTx"
SWIFT_ACTIVE_COMPILATION_CONDITIONS: STORE
SWIFT_OPTIMIZATION_LEVEL: "-O"
DEBUG_INFORMATION_FORMAT: "dwarf-with-dsym"
Description I'm encountering problems while building the release version of my project. The debug version builds fine using the -Onone option, but when I try to build the release version using the -O option, I'm running into issues.
Specifically, there are a couple of Swift files that cannot be built with the -O option, such as those containing extension URL. I'm unsure of how to resolve this issue and would appreciate any advice or guidance on how to proceed.
Steps to reproduce
URL+Extension.swift <- can't build
log
Xcode 14.2 was working fine.
Expected behavior Build success
Screenshots
Environment