swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.57k stars 10.36k forks source link

[SR-3009] Compiler crash when building SwiftPM with optimizations #45599

Open aciidgh opened 8 years ago

aciidgh commented 8 years ago
Previous ID SR-3009
Radar rdar://problem/30147357
Original Reporter @aciidb0mb3r
Type Bug

Attachment: Download

Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug, CompilerCrash, OptimizedOnly | |Assignee | None | |Priority | Medium | md5: 17b33f53a24ac42c15604a8c190e2c26

Issue Description:

There seems to be this compiler crash while building the module "PackageLoadingTests" of SwiftPM with "-O" flag

Compile Swift Module 'PackageLoadingTests' (8 sources)
Compile Swift Module 'PackageGraphTests' (4 sources)
Compile Swift Module 'GetTests' (4 sources)
Compile Swift Module 'FunctionalTests' (8 sources)
Compile Swift Module 'BasicTests' (27 sources)
Stack dump:
0.  Program arguments: /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-10-18-a.xctoolchain/usr/bin/swift -frontend -c /Users/ankit/workspace/swift.org/swiftpm/Tests/PackageLoadingTests/ConventionTests.swift /Users/ankit/workspace/swift.org/swiftpm/Tests/PackageLoadingTests/JSONSerializationTests.swift /Users/ankit/workspace/swift.org/swiftpm/Tests/PackageLoadingTests/ManifestTests.swift /Users/ankit/workspace/swift.org/swiftpm/Tests/PackageLoadingTests/ModuleDependencyTests.swift /Users/ankit/workspace/swift.org/swiftpm/Tests/PackageLoadingTests/ModuleMapGenerationTests.swift /Users/ankit/workspace/swift.org/swiftpm/Tests/PackageLoadingTests/SerializationTests.swift /Users/ankit/workspace/swift.org/swiftpm/Tests/PackageLoadingTests/WhitelistTests.swift /Users/ankit/workspace/swift.org/swiftpm/Tests/PackageLoadingTests/XCTestManifests.swift -target x86_64-apple-macosx10.10 -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -I /Users/ankit/workspace/swift.org/swiftpm/.build/release -F /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -enable-testing -module-cache-path /Users/ankit/workspace/swift.org/swiftpm/.build/release/ModuleCache -D SWIFT_PACKAGE -emit-module-doc-path /Users/ankit/workspace/swift.org/swiftpm/.build/release/PackageLoadingTests.swiftdoc -O -parse-as-library -module-name PackageLoadingTests -emit-module-path /Users/ankit/workspace/swift.org/swiftpm/.build/release/PackageLoadingTests.swiftmodule -emit-dependencies-path /Users/ankit/workspace/swift.org/swiftpm/.build/release/PackageLoadingTests.build/PackageLoadingTests.d -num-threads 8 -o /Users/ankit/workspace/swift.org/swiftpm/.build/release/PackageLoadingTests.build/ConventionTests.swift.o -o /Users/ankit/workspace/swift.org/swiftpm/.build/release/PackageLoadingTests.build/JSONSerializationTests.swift.o -o /Users/ankit/workspace/swift.org/swiftpm/.build/release/PackageLoadingTests.build/ManifestTests.swift.o -o /Users/ankit/workspace/swift.org/swiftpm/.build/release/PackageLoadingTests.build/ModuleDependencyTests.swift.o -o /Users/ankit/workspace/swift.org/swiftpm/.build/release/PackageLoadingTests.build/ModuleMapGenerationTests.swift.o -o /Users/ankit/workspace/swift.org/swiftpm/.build/release/PackageLoadingTests.build/SerializationTests.swift.o -o /Users/ankit/workspace/swift.org/swiftpm/.build/release/PackageLoadingTests.build/WhitelistTests.swift.o -o /Users/ankit/workspace/swift.org/swiftpm/.build/release/PackageLoadingTests.build/XCTestManifests.swift.o
1.  While running pass #​1414 SILModuleTransform "Mandatory Inlining".
2.  While deserializing decl #​21 (XREF)in 'TestSupport'
3.  Cross-reference to module 'Basic'
    ... AbsolutePath
    ... _impl
4.  While deserializing decl #​116 (XREF)in 'TestSupport'
5.  Cross-reference to module 'Basic'
    ... PathImpl
<unknown>:0: error: unable to execute command: Abort trap: 6
<unknown>:0: error: compile command failed due to signal (use -v to see invocation)
<unknown>:0: error: build had 1 command failures

How to reproduce:

$ xcrun --find swiftc
/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-10-18-a.xctoolchain/usr/bin/swiftc
$ git clone -b release-testable https://github.com/aciidb0mb3r/swift-package-manager.git
$ cd swift-package-manager
$ Utilities/bootstrap --release

belkadan commented 8 years ago

I'm...not sure things are set up such that we can deserialize new declarations during optimization passes, but I wouldn't expect it to outright fail.

aciidgh commented 8 years ago

is there a workaround to avoid this crash for now?

belkadan commented 8 years ago

Without looking into it, it's hard to even say what's wrong. Unless PathImpl got removed from Basic or something.

aciidgh commented 8 years ago

nah its there and compiles without -O flag

aciidgh commented 8 years ago

I don't know why but changing PathImpl (Basic/Path.swift) from private to internal fixes the issue.

ddunbar commented 7 years ago

Is this still an issue?

aciidgh commented 7 years ago

Not for package manager because of the workaround. Will see if I can figure out a smaller test case for compiler

aciidgh commented 7 years ago

Created a very small test case.

Unzip the crash.zip file and run

$ swift build -c release -Xswiftc -enable-testing

Crash.zip

belkadan commented 7 years ago

@swift-ci create

bscothern commented 6 years ago

I stumbled upon the TODO in SwiftPM to fix this. I tested it and the Crash.zip, both were able to build without issue using the latest trunk toolchain (DEVELOPMENT-SNAPSHOT-2018-10-03-a).

I have opened [this|https://github.com/apple/swift-package-manager/pull/1817] pull request making this private again.