swift-server / swift-aws-lambda-runtime

Swift implementation of AWS Lambda Runtime
Apache License 2.0
1.12k stars 100 forks source link

Doesn't compile with the Linux Static SDK (aka musl) #330

Closed sebsto closed 1 week ago

sebsto commented 2 weeks ago

Expected behavior

Now that the Static Linux SDK has been released, it open the doors to cross-paltform compilation from Mac that doesn't require Docker or depend on Amazon Linux.
In theory the binary created with the Static Linux SDK should work "as is" on AWS Lambda.

To make this happen, the AWS Lambda Runtime must slightly adjust the way it detects Linux and import Glibc.

I'll send a PR to fix this in a moment.

Actual behavior

Compilation errors such as

swift-aws-lambda-runtime/Sources/AWSLambdaRuntimeCore/Lambda.swift:16:8: error: no such module 'Glibc'
 14 | 
 15 | #if os(Linux)
 16 | import Glibc
    |        `- error: no such module 'Glibc'
 17 | #else
 18 | import Darwin.C

Steps to reproduce

  1. Install the Linux Static SDK (doc)
  2. Apply the patch as described in this message
  3. Compile with swift build --swift-sdk aarch64-swift-linux-musl

If possible, minimal yet complete reproducer code (or URL to code)

No response

What version of this project (swift-aws-lambda-runtime) are you using?

1.0.0-alpha1

Swift version

✗ swift --version && uname -a 
Apple Swift version 6.0-dev (LLVM 6e13b8be259f20f, Swift 372de4670b9cd55)
Target: arm64-apple-macosx14.0
Darwin bcd07458a91c 23.5.0 Darwin Kernel Version 23.5.0: Wed May  1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000 arm64

Amazon Linux 2 docker image version

No response