swiftlang / swift-package-manager

The Package Manager for the Swift Programming Language
Apache License 2.0
9.74k stars 1.34k forks source link

[SR-1194] swift build crash (possibly as a result of extraneous files in main package directory) #5461

Open swift-ci opened 8 years ago

swift-ci commented 8 years ago
Previous ID SR-1194
Radar None
Original Reporter fishpesce (JIRA User)
Type Bug

Attachment: Download

Environment I am using a MacBook Pro 11,2 running ArchLinux. Swift version is DEVELOPMENT.SNAPSHOT.2016.03.24.a-1 from AUR repository package swift-development
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Package Manager | |Labels | Bug | |Assignee | None | |Priority | Medium | md5: ecb561cbe92f12c08e049abf2a0c89e2

Issue Description:

I have a swift program that relies on a c program which relies on two system libraries libgsl and libgslcblas and a custom c library. I am able to compile everything using command line (through make). I created two modules for the system libraries to use Swift Package Manager. When doing this swift build crashes with:

swift build
Cloning /home/greg/Dropbox/common_files/Programming/Swift_Programming/commercial/CIRRCalc
Resolved version: 1.0.0
Cloning /home/greg/Dropbox/common_files/Programming/Swift_Programming/commercial/CGSL
Resolved version: 2.1.0
fatal error: unexpectedly found nil while unwrapping an Optional value: file /tmp/yaourt-tmp-greg/aur-swift-development/src/swift/stdlib/public/core/Optional.swift, line 121
Current stack trace:
/usr/bin/../lib/swift/linux/x86_64/libswiftCore.so(swift_reportError+0x8b) [0x7fd767ef76bb]
/usr/bin/../lib/swift/linux/x86_64/libswiftCore.so(_swift_stdlib_reportFatalErrorInFile+0x67) [0x7fd767f0a7f7]
/usr/bin/../lib/swift/linux/x86_64/libswiftCore.so(+0x204d5c) [0x7fd767e4dd5c]
/usr/bin/../lib/swift/linux/x86_64/libswiftCore.so(+0x205088) [0x7fd767e4e088]
/usr/bin/../lib/swift/linux/x86_64/libswiftCore.so(function signature specialization \<Arg[0] = Exploded, Arg[1] = Exploded, Arg[2] = Exploded> of Swift._fatalErrorMessage (Swift.StaticString, Swift.StaticString, Swift.StaticString, Swift.UInt, flags : Swift.UInt32) -> () with unmangled suffix "_arg0_012_arg1_012_arg2_012"+0x62) [0x7fd767e4e262]
/usr/bin/swift-build() [0x44ba44]
/usr/bin/swift-build() [0x44bc1d]
/usr/bin/swift-build() [0x44bd19]
/usr/bin/../lib/swift/linux/x8664/libswiftCore.so((extension in Swift):Swift.Collection.map \<A> ((A.Iterator.Element) throws -> A1) throws -> Swift.Array\<A1>+0x3ae) [0x7fd767d4ff7e]
/usr/bin/swift-build() [0x44b4d3]
/usr/bin/swift-build() [0x41c545]
/usr/bin/swift-build() [0x41936f]
/usr/lib/libc.so.6(\
_libc_start_main+0xf0) [0x7fd7667a5610]
/usr/bin/swift-build() [0x40c499]
Illegal instruction (core dumped)

tar'd files are attached

mxcl commented 8 years ago

Can't reproduce.

Cloning /Users/mxcl/Downloads/CIRRCalc
Resolved version: 1.5.0
Cloning /Users/mxcl/Downloads/CGSL
Resolved version: 2.1.0
Compiling Swift Module 'WindFarmIRR' (2 sources)
/Users/mxcl/Downloads/linux/Packages/CIRRCalc-1.5.0/module.modulemap:2:12: error: header '/home/greg/mylocal/include/libirr_calc.h' not found
    header "/home/greg/mylocal/include/libirr_calc.h"
           ^
/Users/mxcl/Downloads/linux/Sources/main.swift:14:8: error: could not build Objective-C module 'CIRRCalc'
import CIRRCalc
       ^
/Users/mxcl/Downloads/linux/Packages/CIRRCalc-1.5.0/module.modulemap:2:12: error: header '/home/greg/mylocal/include/libirr_calc.h' not found
    header "/home/greg/mylocal/include/libirr_calc.h"
           ^
/Users/mxcl/Downloads/linux/Sources/main.swift:14:8: error: could not build Objective-C module 'CIRRCalc'
import CIRRCalc
       ^
<unknown>:0: error: build had 1 command failures
error: exit(1): /Users/mxcl/Library/Developer/Toolchains/swift-mxcl.xctoolchain/usr/bin/swift-build-tool -f /Users/mxcl/Downloads/linux/.build/debug.yaml default

Which gets further than your code, and fails as I don't have those C libraries.

swift-ci commented 8 years ago

Comment by Greg Jaczko (JIRA)

Here are my local libraries and header files. The gsl is GNU scientific library, a system library for which I was trying to make a swift module.

mxcl commented 8 years ago

Does it still happen with the latest snapshot released a few days ago?

swift-ci commented 8 years ago

Comment by Greg Jaczko (JIRA)

Still happens with 4-12 snapshot.

swift build
Cloning /home/greg/Dropbox/common_files/Programming/Swift_Programming/commercial/CIRRCalc
Resolved version: 1.0.0
Cloning /home/greg/Dropbox/common_files/Programming/Swift_Programming/commercial/CGSL
Resolved version: 2.1.0
fatal error: unexpectedly found nil while unwrapping an Optional value: file /tmp/yaourt-tmp-greg/aur-swift-development/src/swift/stdlib/public/core/Optional.swift, line 122
Current stack trace:
/usr/bin/../lib/swift/linux/x86_64/libswiftCore.so(swift_reportError+0x8b) [0x7f3c33a8a3cb]
/usr/bin/../lib/swift/linux/x86_64/libswiftCore.so(_swift_stdlib_reportFatalErrorInFile+0x67) [0x7f3c33a9dd57]
/usr/bin/../lib/swift/linux/x86_64/libswiftCore.so(+0x283a03) [0x7f3c33a4ba03]
/usr/bin/../lib/swift/linux/x86_64/libswiftCore.so(+0x283a5f) [0x7f3c33a4ba5f]
/usr/bin/../lib/swift/linux/x86_64/libswiftCore.so(+0x286b3e) [0x7f3c33a4eb3e]
/usr/bin/../lib/swift/linux/x86_64/libswiftCore.so(+0x13b45d) [0x7f3c3390345d]
/usr/bin/../lib/swift/linux/x86_64/libswiftCore.so(+0x284257) [0x7f3c33a4c257]
/usr/bin/../lib/swift/linux/x86_64/libswiftCore.so(+0x283a5f) [0x7f3c33a4ba5f]
/usr/bin/../lib/swift/linux/x86_64/libswiftCore.so(+0x286b1e) [0x7f3c33a4eb1e]
/usr/bin/../lib/swift/linux/x86_64/libswiftCore.so(+0x13b45d) [0x7f3c3390345d]
/usr/bin/../lib/swift/linux/x86_64/libswiftCore.so(+0x24a8c4) [0x7f3c33a128c4]
/usr/bin/../lib/swift/linux/x86_64/libswiftCore.so(Swift._fatalErrorMessage (Swift.StaticString, Swift.StaticString, Swift.StaticString, Swift.UInt, flags : Swift.UInt32) -> ()+0xd2) [0x7f3c33902972]
/usr/bin/swift-build() [0x444ee3]
/usr/bin/swift-build() [0x4450bd]
/usr/bin/swift-build() [0x4451b9]
/usr/bin/../lib/swift/linux/x8664/libswiftCore.so((extension in Swift):Swift.Collection.map \<A> ((A.Iterator.Element) throws -> A1) throws -> Swift.Array\<A1>+0x3ae) [0x7f3c338e39ce]
/usr/bin/swift-build() [0x444901]
/usr/bin/swift-build() [0x41ac15]
/usr/bin/swift-build() [0x4174c1]
/usr/lib/libc.so.6(\
_libc_start_main+0xf0) [0x7f3c322ed610]
/usr/bin/swift-build() [0x40c519]
Illegal instruction (core dumped)

swift-ci commented 8 years ago

Comment by Greg Jaczko (JIRA)

Using the latest snapshot release still caused problems. HOWEVER. I previously had non-swift package manager files in the same directory as the Package.swift and module.modulemap. After removing these, the build compiled and ran successfully. This build involved a custom c library, for which I created a module to use in a swift program. I put traditional make files and sources to build the c version of the library together with the Swift module files (Package.swift,module.modulemap) to have consolidated place for the library sources and swift module creation files. I was under the belief that swift-build would ignore directories that were not of specific names (Sources,src,etc). I named the other files with names all prefaced by "Make". My guess without further analysis is that somehow the swift-build system was trying to process these other files and found inappropriate files. Regardless there should be a cleaner exit for this or better documentation about the files swift-build will look at and those it will ignore.

mxcl commented 8 years ago

What were the suffixes of these other files?

abertelrud commented 8 years ago

Sounds as if one part of the solution here is better error checking and reporting.