-
Notifications
You must be signed in to change notification settings - Fork 18
Symlink libclang_rt.builtins.a
for Embedded Swift for WASI
#213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Embedded Swift looks up clang compiler-rt in a different path than non-embedded. These paths could be normalized in the future, but for now the easiest fix seems to be just to symlink this static library.
"usr/lib/swift/clang/lib/wasm32-unknown-wasip1" | ||
) | ||
|
||
try await generator.createDirectoryIfNeeded(at: embeddedCompilerRTPath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about symlinking the platform directly itself instead of for each individual file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It expects libclang_rt.builtins.a
, while the name of the symlinked file is libclang_rt.builtins-wasm32.a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC if we encode the arch name in the directory name, then it shouldn't be included in the file name, and vice versa. So different names for files are still needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I think the clang driver just prints error message while assuming the new per-target directory layout, but it also looks up the old layout. Could you try the directory symlink approach?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That doesn't seem to work if symlinking wasm32-unknown-wasip1
to wasi
is what you're suggesting:
> ls ~/.swiftpm/swift-sdks/swift-DEVELOPMENT-SNAPSHOT_wasm.artifactbundle/swift-DEVELOPMENT-SNAPSHOT_wasm/wasm32-unknown-wasi/swift.xctoolchain/usr/lib/swift/clang/lib/wasm32-unknown-wasip1
╭───┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬──────┬──────────┬─────────────╮
│ # │ name │ type │ size │ modified │
├───┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼──────┼──────────┼─────────────┤
│ 0 │ /home/mdesiatov/.swiftpm/swift-sdks/swift-DEVELOPMENT-SNAPSHOT_wasm.artifactbundle/swift-DEVELOPMENT-SNAPSHOT_wasm/wasm32-unknown-wasi/swift.xctoolchain/usr/lib/swift/clang/lib/wasm32-unknown-wasip1/libclang_rt.builtins-wasm32.a │ file │ 306.4 kB │ an hour ago │
╰───┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴──────┴──────────┴─────────────╯
> swift build --swift-sdk swift-DEVELOPMENT-SNAPSHOT_wasm-embedded -c release
Building for production...
wasm-ld: error: cannot open /home/mdesiatov/.swiftpm/swift-sdks/swift-DEVELOPMENT-SNAPSHOT_wasm.artifactbundle/swift-DEVELOPMENT-SNAPSHOT_wasm/wasm32-unknown-wasi/swift.xctoolchain/usr/lib/swift/clang/lib/wasm32-unknown-wasip1/libclang_rt.builtins.a: No such file or directory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I meant symlinking wasip1 to wasi.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that worked, thanks!
@swift-ci test |
@swift-ci test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Embedded Swift looks up Clang's compiler-rt static library in a different path than non-embedded. These paths could be normalized in the future, but for now the easiest fix seems to be just to symlink the directory the static library is located in.