From 164ec0adaa80e7a29d2a10fb31ee72baddeda6b2 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Wed, 7 Aug 2024 03:59:06 +0000 Subject: [PATCH] [wasm] Fix ambiguous `errno` error when importing WASILibc module This commit fixes an ambiguous `errno` error when importing WASILibc module and SwiftWASILibc Clang module. The error is caused by the fact that we define a shim for `errno` in `Platform.swift` file, but wasi-libc defines `errno` in a way ClangImporter can understand. We don't need to define shims for it, otherwise we get two candidates for `errno` identifier. --- stdlib/public/Platform/Platform.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/stdlib/public/Platform/Platform.swift b/stdlib/public/Platform/Platform.swift index 0c2d63a0cffdb..ca7417c53574b 100644 --- a/stdlib/public/Platform/Platform.swift +++ b/stdlib/public/Platform/Platform.swift @@ -84,6 +84,11 @@ func _convertDarwinBooleanToBool(_ x: DarwinBoolean) -> Bool { #endif +// wasi-libc defines `errno` in a way ClangImporter can understand, so we don't +// need to define shims for it. On the contrary, if we define the shim, we will +// get an ambiguity error when importing WASILibc module and SwiftWASILibc Clang +// module (or a Clang module that re-exports SwiftWASILibc). +#if !os(WASI) //===----------------------------------------------------------------------===// // sys/errno.h //===----------------------------------------------------------------------===// @@ -96,6 +101,7 @@ public var errno : Int32 { return _swift_stdlib_setErrno(val) } } +#endif //===----------------------------------------------------------------------===//