-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Description
Description
If I have a Swift package that has an import Glibc (either explicit or implicit via other imports) and try to cross compile it with a swift-DEVELOPMENT-SNAPSHOT-2025-08-25-a Swift SDK, I get the following errors:
error: emit-module command failed with exit code 1 (use -v to see invocation)
~/Library/org.swift.swiftpm/swift-sdks/DEVELOPMENT-SNAPSHOT-2025-08-25-a_debian_bookworm_aarch64.artifactbundle/DEVELOPMENT-SNAPSHOT-2025-08-25-a_debian_bookworm_aarch64/aarch64-unknown-linux-gnu/debian-bookworm.sdk/usr/lib/swift/linux/Glibc.swiftmodule/aarch64-unknown-linux-gnu.private.swiftinterface:92:44: error: cannot use type alias '__sighandler_t' here; C++ types from imported module 'SwiftGlibc' do not support library evolution
90 | public func ioctl(_ fd: Swift.CInt, _ request: Swift.UInt, _ ptr: Swift.UnsafeMutableRawPointer) -> Swift.CInt
91 | public func ioctl(_ fd: Swift.CInt, _ request: Swift.UInt) -> Swift.CInt
92 | public typealias sighandler_t = SwiftGlibc.__sighandler_t
| `- error: cannot use type alias '__sighandler_t' here; C++ types from imported module 'SwiftGlibc' do not support library evolution
93 | public var SIG_DFL: Glibc.sighandler_t? {
94 | get
~/Library/org.swift.swiftpm/swift-sdks/DEVELOPMENT-SNAPSHOT-2025-08-25-a_debian_bookworm_aarch64.artifactbundle/DEVELOPMENT-SNAPSHOT-2025-08-25-a_debian_bookworm_aarch64/aarch64-unknown-linux-gnu/debian-bookworm.sdk/usr/include/signal.h:72:16: note: type alias declared here
70 |
71 | /* Type of a signal handler. */
72 | typedef void (*__sighandler_t) (int);
| `- note: type alias declared here
73 |
74 | /* The X/Open definition of `signal' specifies the SVID semantic. Use
~/Programming/tmp/swift-hello/Sources/swift-hello/swift_hello.swift:4:8: error: failed to build module 'Glibc'; this SDK is not supported by the compiler (the SDK is built with 'Swift version 6.2-dev effective-5.10 (LLVM 54eee003e08e203, Swift db8b8480e97e37f)', while this compiler is 'Apple Swift version 6.2-dev effective-5.10 (LLVM 54eee003e08e203, Swift db8b8480e97e37f)'). Please select a toolchain which matches the SDK.
2 | // https://docs.swift.org/swift-book
3 |
4 | import Glibc
| `- error: failed to build module 'Glibc'; this SDK is not supported by the compiler (the SDK is built with 'Swift version 6.2-dev effective-5.10 (LLVM 54eee003e08e203, Swift db8b8480e97e37f)', while this compiler is 'Apple Swift version 6.2-dev effective-5.10 (LLVM 54eee003e08e203, Swift db8b8480e97e37f)'). Please select a toolchain which matches the SDK.
5 |
6 | print("Hello, World!")
There appears to be some sort of bug in Glibc that causes it to fail cross-compilation when .Cxx interop is enabled. @MaxDesiatov
Reproduction
- Create a swift-hello package with the following contents:
import Glibc
print("Hello, World!")- Create a Swift SDK using the swift-sdk-generator:
swift run swift-sdk-generator make-linux-sdk --swift-branch development --swift-version DEVELOPMENT-SNAPSHOT-2025-08-25-a --target aarch64-unknown-linux-gnu --distribution-name debian --distribution-version 12 - Install the Swift SDK:
swift sdk install Bundles/DEVELOPMENT-SNAPSHOT-2025-08-25-a_debian_bookworm_aarch64.artifactbundle - Compile the swift-hello package using the Swift SDK and passing the
-cxx-interoperability-mode=defaultflag to swiftc:swift build --swift-sdk DEVELOPMENT-SNAPSHOT-2025-08-25-a_debian_bookworm_aarch64 -Xswiftc -cxx-interoperability-mode=default
Expected behavior
The exact same setup works fine with Swift versions from 5.9 all the way up to 6.1.2. So, I'd expect that cross-compiling with .Cxx interop in 6.2 and main would also work instead of throwing library evolution errors when Glibc is imported.
Environment
I get the same errors cross-compiling with the Swift SDK on macOS and Linux. Here are my environments:
macOS
Apple Swift version 6.2-dev (LLVM 54eee003e08e203, Swift db8b848)
Target: arm64-apple-macosx26.0
Build config: +assertions
Darwin Yang.local 25.0.0 Darwin Kernel Version 25.0.0: Thu Aug 14 21:59:19 PDT 2025; root:xnu-12377.1.8~5/RELEASE_ARM64_T6000 arm64
Linux
Swift version 6.2-dev (LLVM 54eee003e08e203, Swift db8b848)
Target: x86_64-unknown-linux-gnu
Build config: +assertions
Linux ella 6.14.0-27-generic #27~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 22 17:38:49 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
Additional information
This seems to also happen with much older 6.2 and main snapshots from several months ago as well. I will note, however, that I have a (proprietary) Swift package that enables C++ interop but mysteriously cross-compiles fine with the 6.2 and main snapshots. However, my package has lots of included C++11 code inside of it, so maybe that changes the behavior of compilation- or at least that is the theory.