From a038b511c18dc59f372a18aa6aa955c4705edf77 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Wed, 28 May 2025 12:58:19 +0100 Subject: [PATCH 1/2] Fix broken symlink in `WebAssemblyRecipe.swift` (#216) `usr/lib/swift/clang/lib/wasi` directory doesn't exist in Swift SDKs for WASI, for `libclang_rt.*-wasm32.a` we should symlink to `../../../swift_static/clang/lib/wasi` instead. --- .../SwiftSDKRecipes/WebAssemblyRecipe.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sources/SwiftSDKGenerator/SwiftSDKRecipes/WebAssemblyRecipe.swift b/Sources/SwiftSDKGenerator/SwiftSDKRecipes/WebAssemblyRecipe.swift index 8497f9b..836b9f5 100644 --- a/Sources/SwiftSDKGenerator/SwiftSDKRecipes/WebAssemblyRecipe.swift +++ b/Sources/SwiftSDKGenerator/SwiftSDKRecipes/WebAssemblyRecipe.swift @@ -200,7 +200,10 @@ package struct WebAssemblyRecipe: SwiftSDKRecipe { "usr/lib/swift/clang/lib/wasip1" ) - try await generator.createSymlink(at: embeddedCompilerRTPath, pointingTo: "wasi") + try await generator.createSymlink( + at: embeddedCompilerRTPath, + pointingTo: "../../../swift_static/clang/lib/wasi" + ) // Copy the WASI sysroot into the SDK bundle. let sdkDirPath = pathsConfiguration.swiftSDKRootPath.appending("WASI.sdk") From 8b074b1a1b73274861ea36d0ea043e4e984443ad Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Fri, 18 Jul 2025 20:35:25 +0900 Subject: [PATCH 2/2] [WebAssembly] Create `clang/lib/wasip1` symlink only if it doesn't exist (#229) We are renaming `wasm32-unknown-wasi` to `wasm32-unknown-wasip1` for non-Embedded targets, so we will no longer have the `clang/lib/wasi`. --- .../SwiftSDKRecipes/WebAssemblyRecipe.swift | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Sources/SwiftSDKGenerator/SwiftSDKRecipes/WebAssemblyRecipe.swift b/Sources/SwiftSDKGenerator/SwiftSDKRecipes/WebAssemblyRecipe.swift index 836b9f5..6256f70 100644 --- a/Sources/SwiftSDKGenerator/SwiftSDKRecipes/WebAssemblyRecipe.swift +++ b/Sources/SwiftSDKGenerator/SwiftSDKRecipes/WebAssemblyRecipe.swift @@ -195,15 +195,17 @@ package struct WebAssemblyRecipe: SwiftSDKRecipe { try await generator.createSymlink(at: autolinkExtractPath, pointingTo: "swift") } + // TODO: Remove this once we drop support for Swift 6.2 // Embedded Swift looks up clang compiler-rt in a different path. let embeddedCompilerRTPath = pathsConfiguration.toolchainDirPath.appending( "usr/lib/swift/clang/lib/wasip1" ) - - try await generator.createSymlink( - at: embeddedCompilerRTPath, - pointingTo: "../../../swift_static/clang/lib/wasi" - ) + if await !generator.doesFileExist(at: embeddedCompilerRTPath) { + try await generator.createSymlink( + at: embeddedCompilerRTPath, + pointingTo: "../../../swift_static/clang/lib/wasi" + ) + } // Copy the WASI sysroot into the SDK bundle. let sdkDirPath = pathsConfiguration.swiftSDKRootPath.appending("WASI.sdk")