swiftlang / swift

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

[SR-3211] Compiling a source at Linux environment #45799

Open swift-ci opened 8 years ago

swift-ci commented 8 years ago
Previous ID SR-3211
Radar None
Original Reporter bernardobreder (JIRA User)
Type Bug
Environment Linux breder 2.6.32-042stab113.21 \#1 SMP Wed Mar 23 11:05:25 MSK 2016 x86_64 x86_64 x86_64 GNU/Linux Swift version 3.0.1 (swift-3.0.1-RELEASE) Target: x86_64-unknown-linux-gnu Swift Package Manager - Swift 3.0.1
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug, CompilerCrash | |Assignee | None | |Priority | Medium | md5: bc21e6c2e78a02e7b47e4dc263c041d2

Issue Description:

I have a error from swift compiler at linux in my swift project using package manager:

~$ mkdir test ~$ cd test/ ~/test$ swift package init Creating library package: test Creating Package.swift Creating .gitignore Creating Sources/ Creating Sources/test.swift Creating Tests/ Creating Tests/LinuxMain.swift Creating Tests/testTests/ Creating Tests/testTests/testTests.swift ~/test$ vi Sources/test.swift ~/test$ cat Sources/test.swift public protocol A {

}

public protocol A1 {

}

open class B: A {

init(c: C) {

}

}

open class C: B, A1 {

} ~/test$ swift build Compile Swift Module 'test' (1 sources) swift: /home/buildnode/disk2/workspace/oss-swift-3.0-package-linux-ubuntu-16_04/swift/lib/AST/Decl.cpp:1661: void swift::ValueDecl::setType(swift::Type): Assertion `!hasType() && "changing type of declaration"' failed. 0 swift 0x0000000003350548 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40 1 swift 0x000000000334ed46 llvm::sys::RunSignalHandlers() + 54 2 swift 0x0000000003351076 3 libpthread.so.0 0x00007f4d289b83e0 4 libc.so.6 0x00007f4d27300428 gsignal + 56 5 libc.so.6 0x00007f4d2730202a abort + 362 6 libc.so.6 0x00007f4d272f8bd7 7 libc.so.6 0x00007f4d272f8c82 8 swift 0x00000000010faffc swift::ValueDecl::setType(swift::Type) + 92 9 swift 0x0000000000eccadd swift::configureConstructorType(swift::ConstructorDecl*, swift::Type, swift::Type) + 365 10 swift 0x0000000000edf7f5 11 swift 0x0000000000ed15cd 12 swift 0x0000000000edd9eb 13 swift 0x0000000000ed159d 14 swift 0x0000000000ed1406 swift::TypeChecker::typeCheckDecl(swift::Decl*, bool) + 150 15 swift 0x0000000000ef4bc2 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int) + 1026 16 swift 0x0000000000c7ee1b swift::CompilerInstance::performSema() + 3515 17 swift 0x00000000007dbeaf 18 swift 0x00000000007daf81 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2833 19 swift 0x00000000007a7a1b main + 2603 20 libc.so.6 0x00007f4d272eb830 __libc_start_main + 240 21 swift 0x00000000007a5599 _start + 41 Stack dump:

  1. Program arguments: /home/git/swift-3.0.1/usr/bin/swift -frontend -c -primary-file /home/git/test/Sources/test.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -I /home/git/test/.build/debug -enable-testing -g -module-cache-path /home/git/test/.build/debug/ModuleCache -D SWIFT_PACKAGE -emit-module-doc-path /home/git/test/.build/debug/test.build/test~partial.swiftdoc -Onone -parse-as-library -module-name test -emit-module-path /home/git/test/.build/debug/test.build/test~partial.swiftmodule -emit-dependencies-path /home/git/test/.build/debug/test.build/test.d -emit-reference-dependencies-path /home/git/test/.build/debug/test.build/test.swiftdeps -num-threads 8 -o /home/git/test/.build/debug/test.build/test.swift.o
  2. While type-checking 'B' at /home/git/test/Sources/test.swift:9:6 :0: error: unable to execute command: Aborted :0: error: compile command failed due to signal (use -v to see invocation) :0: error: build had 1 command failures error: exit(1): /home/git/swift-3.0.1/usr/bin/swift-build-tool -f /home/git/test/.build/debug.yaml

To resolve the problem and continue to work, i make a change at construtor of classe B:

~/test$ vi Sources/test.swift ~/test$ cat Sources/test.swift public protocol A {

}

public protocol A1 {

}

open class B: A {

init(c: **<font color="red">A1</font>**) {

}

}

open class C: B, A1 {

} git@breder:~/test$ swift build Compile Swift Module 'test' (1 sources)

belkadan commented 7 years ago

I'm not seeing this on master on a Mac, and I don't see anything Linux-specific, so it's possible this has been fixed.

swift-ci commented 7 years ago

Comment by Terry Latanville (JIRA)

If you declare a RawRepresentable initializer the problem presents itself on Linux using the swiftdocker/swift container (while compiling correctly on Mac):

public struct Foo: OptionSet, RawRepresentable {
    public let rawValue: Int

    public init(rawValue: Foo.RawValue) {
        self.rawValue = rawValue
    }
}

Changing the initializer's type to "Int" causes it to compile OK on Linux.

belkadan commented 7 years ago

Huh, I can't see what would be different about that on Linux.

belkadan commented 7 years ago

What version of Swift is in the swiftdocker container? "fixed on master" in December would mean "fixed in 3.1" now, and 3.1 just came out, so it wouldn't be surprising if you're still seeing this.

swift-ci commented 7 years ago

Comment by Terry Latanville (JIRA)

Seems to be 3.1, but I'll give it another try.

ARG SWIFT_PLATFORM=ubuntu16.04
ARG SWIFT_BRANCH=swift-3.1-release
ARG SWIFT_VERSION=swift-3.1-RELEASE

https://hub.docker.com/r/swiftdocker/swift/~/dockerfile/

swift-ci commented 7 years ago

Comment by Terry Latanville (JIRA)

OK if you specify swiftdocker/swift:latest you get the following version:

Swift version 3.0.2 (swift-3.0.2-RELEASE)
Target: x86_64-unknown-linux-gnu

If you specify swiftdocker/swift:swift-3.1

Swift version 3.1-dev (LLVM a7c680da51, Clang 9772bf511a, Swift ce937d9373)
Target: x86_64-unknown-linux-gnu

If you use the swift-3.1 branch the build completes successfully.