Also, I'm running the latest Mojave beta OS. Builds fail using the development snapshot on any project except Playgrounds and MacOS command line projects. I always get these 2 errors when building for cocoa or cocoatouch projects with the new build system:
Segmentation Fault: 11
** Command compile Swift failed with a nonzero exit code**
Everything builds fine with the default toolchain.
Is anyone else seeing this or have an idea where to look for the problem?
There should be more information in the full log, both a standard backtrace with addresses and a list of lines starting with "While…" that describe what the compiler was doing at the time. There's one case where that won't appear, though, and that's if the compiler ends up in unbounded recursion and overflows its stack. In that case there's no real way to debug other than finding the problematic input code.
This is one of the reasons we post development snapshots, so we definitely want to get to the bottom of this!
Thanks for the help!
Here is the "While..." part. I can post the rest of the trace if you like.
- While walking into decl 'AppDelegate' at /Users/charleslane/Documents/SWDevelopment/SwiftStuff/AppDevWithSwift/EmojiDictionary/EmojiDictionary/AppDelegate.swift:12:1
0 swift 0x000000010af39068 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1 swift 0x000000010af382f5 llvm::sys::RunSignalHandlers() + 85
2 swift 0x000000010af39672 SignalHandler(int) + 258
3 libsystem_platform.dylib 0x00007fff60ebab3d _sigtramp + 29
4 libsystem_platform.dylib 0x00007ffee876dda8 _sigtramp + 2274046600
5 swift 0x00000001081281f3 (anonymous namespace)::IndexSwiftASTWalker::startEntity(swift::Decl*, swift::index::IndexSymbol&, bool) + 371
6 swift 0x000000010812640f (anonymous namespace)::IndexSwiftASTWalker::walkToDeclPre(swift::Decl*, swift::CharSourceRange) + 1119
7 swift 0x00000001080e1989 (anonymous namespace)::SemaAnnotator::walkToDeclPre(swift::Decl*) + 1209
8 swift 0x00000001086ac99b (anonymous namespace)::Traversal::doIt(swift::Decl*) + 171
9 swift 0x00000001086ac8db swift::Decl::walk(swift::ASTWalker&) + 27
10 swift 0x0000000108765dea swift::SourceFile::walk(swift::ASTWalker&) + 170
11 swift 0x00000001080dfc89 swift::SourceEntityWalker::walk(swift::SourceFile&) + 201
12 swift 0x0000000108125d08 (anonymous namespace)::IndexSwiftASTWalker::visitModule(swift::ModuleDecl&, llvm::StringRef) + 248
13 swift 0x0000000108125b64 swift::index::indexSourceFile(swift::SourceFile*, llvm::StringRef, swift::index::IndexDataConsumer&) + 500
14 swift 0x000000010812e979 recordSourceFileUnit(swift::SourceFile*, llvm::StringRef, llvm::StringRef, bool, bool, llvm::StringRef, llvm::ArrayRef<clang::FileEntry const*>, clang::CompilerInstance const&, swift::DiagnosticEngine&) + 1657
15 swift 0x000000010812e2ea swift::index::indexAndRecord(swift::SourceFile*, llvm::StringRef, llvm::StringRef, bool, bool, llvm::StringRef, swift::DependencyTracker const&) + 298
16 swift 0x00000001074e4a5c emitIndexDataIfNeeded(swift::SourceFile*, swift::CompilerInvocation const&, swift::CompilerInstance&) + 284
17 swift 0x00000001074dfc55 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 14677
18 swift 0x00000001074db2b4 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2932
19 swift 0x00000001074905ad main + 685
20 libdyld.dylib 0x00007fff60cd1085 start + 1
error: Segmentation fault: 11
Cool. This might be a known issue—CC @blangmuir, @Nathan_Hawes.
Also getting crashes for swift (trunk) master builds since at least 2018-09-10. Both on the beta Xcode 10 as well as the GM. It used to build fine on master and still builds fine on default toolchain in Xcode.
If needed, you can get the source code from here: https://github.com/Moximillian/ProtoKit/blob/master/Sources/UnifiedCollection.swift
- While walking into decl 'TableDataSource' at ..../ProtoKit/Sources/UnifiedCollection.swift:124:19
0 swift 0x0000000104d31068 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1 swift 0x0000000104d302f5 llvm::sys::RunSignalHandlers() + 85
2 swift 0x0000000104d31672 SignalHandler(int) + 258
3 libsystem_platform.dylib 0x00007fff77fc7f5a _sigtramp + 26
4 libsystem_platform.dylib 0x00007ffeee976108 _sigtramp + 1989861832
5 swift 0x0000000101f201f3 (anonymous namespace)::IndexSwiftASTWalker::startEntity(swift::Decl*, swift::index::IndexSymbol&, bool) + 371
6 swift 0x0000000101f1e40f (anonymous namespace)::IndexSwiftASTWalker::walkToDeclPre(swift::Decl*, swift::CharSourceRange) + 1119
7 swift 0x0000000101ed9989 (anonymous namespace)::SemaAnnotator::walkToDeclPre(swift::Decl*) + 1209
8 swift 0x00000001024a499b (anonymous namespace)::Traversal::doIt(swift::Decl*) + 171
9 swift 0x00000001024a48db swift::Decl::walk(swift::ASTWalker&) + 27
10 swift 0x000000010255ddea swift::SourceFile::walk(swift::ASTWalker&) + 170
11 swift 0x0000000101ed7c89 swift::SourceEntityWalker::walk(swift::SourceFile&) + 201
12 swift 0x0000000101f1dd08 (anonymous namespace)::IndexSwiftASTWalker::visitModule(swift::ModuleDecl&, llvm::StringRef) + 248
13 swift 0x0000000101f1db64 swift::index::indexSourceFile(swift::SourceFile*, llvm::StringRef, swift::index::IndexDataConsumer&) + 500
14 swift 0x0000000101f26979 recordSourceFileUnit(swift::SourceFile*, llvm::StringRef, llvm::StringRef, bool, bool, llvm::StringRef, llvm::ArrayRef<clang::FileEntry const*>, clang::CompilerInstance const&, swift::DiagnosticEngine&) + 1657
15 swift 0x0000000101f262ea swift::index::indexAndRecord(swift::SourceFile*, llvm::StringRef, llvm::StringRef, bool, bool, llvm::StringRef, swift::DependencyTracker const&) + 298
16 swift 0x00000001012dca5c emitIndexDataIfNeeded(swift::SourceFile*, swift::CompilerInvocation const&, swift::CompilerInstance&) + 284
17 swift 0x00000001012d7c55 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 14677
18 swift 0x00000001012d32b4 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2932
19 swift 0x00000001012885ad main + 685
20 libdyld.dylib 0x00007fff77cb9015 start + 1
error: Segmentation fault: 11
Sorry you're having trouble too, but I was beginning to think that I was the only person on Earth with this problem!
I think I have a solution, the development toolchain now compiles just fine.
Go to Build Settings, search for "whole", the Compilation Mode can be either incremental or whole module. The Optimization Level for Debug MUST be set to either Optimize for speed or Optimize for size. It it's set to No Optimization it will fail to compile.
Try it, let me know if it works for you too.
The trunk (master) build from 2018-09-22 fixes the crasher for me, without any changes to code or configuration.
Ditto! The 09-22 toolchain fixed it.