swiftlang / swift

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

Linux Observation crash. #75670

Open zaneenders opened 1 month ago

zaneenders commented 1 month ago

Description

➜  chroma-web git:(bug) ✗ swift build 
Building for debugging...
error: link command failed with exit code 1 (use -v to see invocation)
/home/zane/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift/linux/libswiftObservation.so: error: undefined reference to 'swift::threading::fatal(char const*, ...)'
clang-15: error: linker command failed with exit code 1 (use -v to see invocation)
error: fatalError
[1/2] Linking server

Reproduction

import Observation
@main
public struct Main {
    public static func main() async {
        let connection = await Connection()

    }
}

actor Connection {

    init() async {
    }
    var state = ""

    func startObservation(
    ) {
        withObservationTracking {
            let body = state
            print(body)
        } onChange: {
            Task(priority: .userInitiated) {
                await self.startObservation()
            }
        }
    }
}

// Package.swift
// swift-tools-version: 5.10

import PackageDescription

let package = Package(
    name: "chroma-web",
    platforms: [
        .macOS("14.0")
    ],
    products: [
        .executable(name: "server", targets: ["Test"])
    ],
    dependencies: [
        .package(
            url: "https://github.com/swift-server/async-http-client.git",
            from: "1.6.0"),
    ],
    targets: [
        .executableTarget(
            name: "Test",
            dependencies: [
                .product(name: "AsyncHTTPClient", package: "async-http-client"),
            ])
    ]
)

Stack dump

Don't have one

Expected behavior

Compile with out crashing.

Environment

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

Additional information

No response

zaneenders commented 1 month ago

Currently unable to reduce project down to a test example to share right now but happens pretty consistently.

zaneenders commented 1 month ago

Ok so the project compiles fine when I remove async-http-client as a dependencies. I also have no trouble compiling async-http-client` by its self.