Giter VIP home page Giter VIP logo

Comments (4)

csantanapr avatar csantanapr commented on June 2, 2024

Here is a simpler reproduce:

Create the two following files

./Package.swift
./Sources/Action/main.swift

Content of Package.swift

// swift-tools-version:4.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "Action",
    products: [
      .executable(
        name: "Action",
        targets:  ["Action"]
      )
    ],
    targets: [
      .target(
        name: "Action"
      )
    ]
)

Create Sources/Action/main.swift

import Foundation
func _run_main<Out: Encodable>(mainFunction: ( @escaping (Out?, Error?) -> Void) -> Void) {
    let resultHandler = { (out: Out?, error: Error?) in
        let encoder = JSONEncoder()
        do {
            let jsonData = try encoder.encode(out)
            let jsonString = String(data: jsonData, encoding: .utf8)
            print("\(jsonString!)")
        } catch {
            print("{\"error\":\"Error encoding result\"}")
        }
    }
    let _ = mainFunction(resultHandler)
}
struct Output: Codable {
    let greeting: String
    let group: String
}
func main(completion: (Output?, Error?) -> Void) -> Void {
    let result = Output(greeting: "Hello OpenWhisk!", group: "Avoid")
    completion(result, nil)
}
_run_main(mainFunction:main)

Use Swift Docker image to compile

docker run --rm -it -v $(pwd):/owexec swift:4.1 bash
root@15fe743675c1:/# cd /owexec

Try to compile in debug mode

root@15fe743675c1:/owexec# swift build
Compile Swift Module 'Action' (1 sources)
Linking ./.build/x86_64-unknown-linux/debug/Action

As you can see no issues
Then try to compile in release mode

root@15fe743675c1:/owexec# swift build -c release
Compile Swift Module 'Action' (1 sources)
swift: /home/buildnode/jenkins/workspace/oss-swift-4.1-package-linux-ubuntu-16_04/swift/lib/IRGen/IRGenSIL.cpp:1928: void emitApplyArgument((anonymous namespace)::IRGenSILFunction &, swift::SILValue, swift::SILType, swift::irgen::Explosion &): Assertion `arg->getType().isObject()' failed.
/usr/bin/swift[0x3f24d54]
/usr/bin/swift[0x3f25096]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f721a60d390]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x38)[0x7f7218d4c428]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x16a)[0x7f7218d4e02a]
/lib/x86_64-linux-gnu/libc.so.6(+0x2dbd7)[0x7f7218d44bd7]
/lib/x86_64-linux-gnu/libc.so.6(+0x2dc82)[0x7f7218d44c82]
/usr/bin/swift[0x5f2bd1]
/usr/bin/swift[0x5f1873]
/usr/bin/swift[0x5d6202]
/usr/bin/swift[0x5d3cfb]
/usr/bin/swift[0x4e5ae5]
/usr/bin/swift[0x5ac229]
/usr/bin/swift[0x4c3780]
/usr/bin/swift[0x4beecc]
/usr/bin/swift[0x4778c4]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f7218d37830]
/usr/bin/swift[0x475179]
Stack dump:
0.	Program arguments: /usr/bin/swift -frontend -c /owexec/Sources/Action/main.swift -target x86_64-unknown-linux -disable-objc-interop -sdk / -I /owexec/.build/x86_64-unknown-linux/release -module-cache-path /owexec/.build/x86_64-unknown-linux/release/ModuleCache -swift-version 4 -O -D SWIFT_PACKAGE -color-diagnostics -emit-module-doc-path /owexec/.build/x86_64-unknown-linux/release/Action.swiftdoc -module-name Action -emit-module-path /owexec/.build/x86_64-unknown-linux/release/Action.swiftmodule -emit-dependencies-path /owexec/.build/x86_64-unknown-linux/release/Action.build/Action.d -num-threads 4 -o /owexec/.build/x86_64-unknown-linux/release/Action.build/main.swift.o
1.	While emitting IR SIL function "@main".
<unknown>:0: error: unable to execute command: Aborted
<unknown>:0: error: compile command failed due to signal 6 (use -v to see invocation)
error: terminated(1): /usr/bin/swift-build-tool -f /owexec/.build/release.yaml main output:

Now try to workaround by compiling with Optimization off, and compiles with no errors

root@15fe743675c1:/owexec# swift build -c release -Xswiftc -Onone
Compile Swift Module 'Action' (1 sources)
Linking ./.build/x86_64-unknown-linux/release/Action

from openwhisk-runtime-swift.

csantanapr avatar csantanapr commented on June 2, 2024

I created a bug in swift bug tracker here: https://bugs.swift.org/browse/SR-7696

from openwhisk-runtime-swift.

csantanapr avatar csantanapr commented on June 2, 2024

More data points from today
I was able to compile the code with no errors in 4.2 and development snapshots
https://swift.org/builds/swift-4.2-branch/ubuntu1404/swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-14-a/swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-14-a-ubuntu14.04.tar.gz

https://swift.org/builds/development/ubuntu1604/swift-DEVELOPMENT-SNAPSHOT-2018-05-14-a/swift-DEVELOPMENT-SNAPSHOT-2018-05-14-a-ubuntu16.04.tar.gz

So it looks like the problem is already fixed in the swift-4.2 branch.

from openwhisk-runtime-swift.

dgrove-oss avatar dgrove-oss commented on June 2, 2024

Closing a fixed in Swift4.2

from openwhisk-runtime-swift.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.