Hi!
When I import Darwin
and try to use a symbol defined in stdlib/public/Platform/Platform.swift
, such as DarwinBoolean
, Semaphore
, or errno
, that symbol is not found when compiling in embedded mode on a Mac. Why? Am I holding it wrong? I thought the stdlib had (partial) embedded support, at least that's what I inferred based on the @_unavailableInEmbedded
attributes and #if !$Embedded
around some of the code in said stdlib/public/Platform/Platform.swift. See CMakeLists in stdlib/public/Platform
Even funnier, when I compile in debug mode instead of release, the entire Darwin module cannot be imported (same goes for Darwin.C).
Is this a bug or do I need to pass in additional flags...?
Same issue, regardless whether SPM or xcode. I am using a current main snapshot with
-enable-experimental-feature Embedded -wmo
, or, well, the SPM version of that (.enableExperimentalFeature("Embedded"), .unsafeFlags(["-wmo"])
)
$ TOOLCHAINS=org.swift.62202503131a swift build -c release
[1/1] Planning build
Building for production...
path/to/main.swift:8:11: error: cannot find type 'Semaphore' in scope
6 | import Darwin
7 |
8 | extension Semaphore {}
| `- error: cannot find type 'Semaphore' in scope
9 | extension Darwin.Semaphore {}
10 |
path/to/main.swift:9:18: error: no type named 'Semaphore' in module 'Darwin'
7 |
8 | extension Semaphore {}
9 | extension Darwin.Semaphore {}
| `- error: no type named 'Semaphore' in module 'Darwin'
$ TOOLCHAINS=org.swift.62202503131a swift build
[1/1] Planning build
Building for debugging...
error: emit-module command failed with exit code 1 (use -v to see invocation)
<unknown>:0: error: module '_errno' cannot be imported in embedded Swift mode
<unknown>:0: error: module '_time' cannot be imported in embedded Swift mode
<unknown>:0: error: module '_signal' cannot be imported in embedded Swift mode
<unknown>:0: error: module 'sys_time' cannot be imported in embedded Swift mode
<unknown>:0: error: module '_stdio' cannot be imported in embedded Swift mode
<unknown>:0: error: module 'unistd' cannot be imported in embedded Swift mode
<unknown>:0: error: module '_math' cannot be imported in embedded Swift mode
path/to/main.swift:6:8: error: module 'Darwin' cannot be imported in embedded Swift mode
4 | print("Hello, world! \(2) \(a)")
5 |
6 | import Darwin
| `- error: module 'Darwin' cannot be imported in embedded Swift mode
7 |
8 | extension Semaphore {}
<unknown>:0: error: module '_errno' cannot be imported in embedded Swift mode
<unknown>:0: error: module '_time' cannot be imported in embedded Swift mode
<unknown>:0: error: module '_signal' cannot be imported in embedded Swift mode
<unknown>:0: error: module 'sys_time' cannot be imported in embedded Swift mode
<unknown>:0: error: module '_stdio' cannot be imported in embedded Swift mode
<unknown>:0: error: module 'unistd' cannot be imported in embedded Swift mode
<unknown>:0: error: module '_math' cannot be imported in embedded Swift mode
path/to/main.swift:6:8: error: module 'Darwin' cannot be imported in embedded Swift mode
4 | print("Hello, world! \(2) \(a)")
5 |
6 | import Darwin
| `- error: module 'Darwin' cannot be imported in embedded Swift mode
7 |
8 | extension Semaphore {}