Skip to content

Build errors when building against a Static Linux SDK #773

Closed
@briancoyner

Description

@briancoyner

Expected behavior

An application with a dependency on async-http-client successfully builds with a Swift 6 OSS toolchain + Static Linux SDK.

Note: The swift-6.0-DEVELOPMENT-SNAPSHOT-2024-09-17-a toolchain is used vs the swift-6.0-RELEASE because of another issue with swift-collections. That issue is fixed in the "09-17" toolchain release.

Note: The main branch of SwiftNIO is used because it contains a fix needed to compile SwiftNIO.

Note: Xcode 15.4.0 vs Xcode 16.0.0 because of an issue described here:

Actual behavior

main branch error and 1.22.2 error

$ xcrun --toolchain org.swift.600202409171a swift build --swift-sdk aarch64-swift-linux-musl
Building for debugging...
/Users/someuser/Developer/Temp/demo/.build/checkouts/async-http-client/Sources/AsyncHTTPClient/HTTPClient+HTTPCookie.swift:241:31: error: cannot find 'errno' in scope
239 |     }
240 |     let timestamp = Int64(timegm(&timeComponents))
241 |     return timestamp == -1 && errno == EOVERFLOW ? nil : timestamp
    |                               `- error: cannot find 'errno' in scope
242 | }
243 | 

/Users/someuser/Developer/Temp/demo/.build/checkouts/async-http-client/Sources/AsyncHTTPClient/HTTPClient+HTTPCookie.swift:241:40: error: cannot find 'EOVERFLOW' in scope
239 |     }
240 |     let timestamp = Int64(timegm(&timeComponents))
241 |     return timestamp == -1 && errno == EOVERFLOW ? nil : timestamp
    |                                        `- error: cannot find 'EOVERFLOW' in scope
242 | }

Steps to reproduce

  1. Install the Swift 6 OSS toolchain + SDK (swift-6.0-DEVELOPMENT-SNAPSHOT-2024-09-17-a).
  2. A simple application using SPM with a dependency on async-http-client (main or 1.22.2) and SwiftNIO (main).
  3. Execute the following to build the application.
$ xcrun --toolchain org.swift.600202409171a swift build --swift-sdk aarch64-swift-linux-musl
See errors noted above (for both `main` and `1.22.2`)

Also, building without the Static Linux SDK succeeds:

$ xcrun --toolchain org.swift.600202409171a swift build                                     
Building for debugging...
[977/977] Applying Demo
Build complete! (52.28s)

Example Swift Package

Here's a basic Package.swift manifest that can be used:

// swift-tools-version: 6.0
import PackageDescription

let package = Package(
    name: "Demo",
    platforms: [
       .macOS(.v14)
    ],
    dependencies: [
        // `main` fixes bug: https://github.com/apple/swift-nio/issues/2893
        .package(url: "https://github.com/apple/swift-nio.git", branch: "main"),
        .package(url: "https://github.com/swift-server/async-http-client.git", branch: "1.22.2")
        // .package(url: "https://github.com/swift-server/async-http-client.git", branch: "main")
    ],
    targets: [
        .executableTarget(
            name: "Demo",
            dependencies: [
                .product(name: "NIOPosix", package: "swift-nio"),
                .product(name: "AsyncHTTPClient", package: "async-http-client")
            ],
            swiftSettings: swiftSettings
        ),
    ],
    swiftLanguageModes: [
        .v6
    ]
)

// MARK: - Swift Settings

var swiftSettings: [SwiftSetting] {
    return [
        .enableUpcomingFeature("ExistentialAny")
    ]
}

System & version information

Sonoma 14.6.1

*****
***** Swift Toolchain
*****   Name: swift-6.0-DEVELOPMENT-SNAPSHOT-2024-09-17-a
*****   Path: /Library/Developer/Toolchains/swift-6.0-DEVELOPMENT-SNAPSHOT-2024-09-17-a.xctoolchain
*****     ID: org.swift.600202409171a
*****    SDK: aarch64-swift-linux-musl
*****    SPM: Swift Package Manager - Swift 6.0.0-dev
*****  Xcode: /Applications/Xcode15.4.0.app/Contents/Developer
*****

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions