Skip to content

Commit d022f27

Browse files
committed
Symlink libclang_rt.builtins.a for Embedded Swift for WASI
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.
1 parent d45075e commit d022f27

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Sources/SwiftSDKGenerator/SwiftSDKRecipes/WebAssemblyRecipe.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ package struct WebAssemblyRecipe: SwiftSDKRecipe {
181181
)
182182
}
183183

184-
let autolinkExtractPath = generator.pathsConfiguration.toolchainBinDirPath.appending(
184+
let autolinkExtractPath = pathsConfiguration.toolchainBinDirPath.appending(
185185
"swift-autolink-extract"
186186
)
187187

@@ -195,6 +195,17 @@ package struct WebAssemblyRecipe: SwiftSDKRecipe {
195195
try await generator.createSymlink(at: autolinkExtractPath, pointingTo: "swift")
196196
}
197197

198+
// Embedded Swift looks up clang compiler-rt in a different path.
199+
let embeddedCompilerRTPath = pathsConfiguration.toolchainDirPath.appending(
200+
"usr/lib/swift/clang/lib/wasm32-unknown-wasip1"
201+
)
202+
203+
try await generator.createDirectoryIfNeeded(at: embeddedCompilerRTPath)
204+
try await generator.createSymlink(
205+
at: embeddedCompilerRTPath.appending("libclang_rt.builtins.a"),
206+
pointingTo: "../../../../swift_static/clang/lib/wasi/libclang_rt.builtins-wasm32.a"
207+
)
208+
198209
// Copy the WASI sysroot into the SDK bundle.
199210
let sdkDirPath = pathsConfiguration.swiftSDKRootPath.appending("WASI.sdk")
200211
try await generator.rsyncContents(from: self.wasiSysroot, to: sdkDirPath)

0 commit comments

Comments
 (0)