Skip to content

Commit 164ec0a

Browse files
[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.
1 parent 29a4b8a commit 164ec0a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

stdlib/public/Platform/Platform.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ func _convertDarwinBooleanToBool(_ x: DarwinBoolean) -> Bool {
8484

8585
#endif
8686

87+
// wasi-libc defines `errno` in a way ClangImporter can understand, so we don't
88+
// need to define shims for it. On the contrary, if we define the shim, we will
89+
// get an ambiguity error when importing WASILibc module and SwiftWASILibc Clang
90+
// module (or a Clang module that re-exports SwiftWASILibc).
91+
#if !os(WASI)
8792
//===----------------------------------------------------------------------===//
8893
// sys/errno.h
8994
//===----------------------------------------------------------------------===//
@@ -96,6 +101,7 @@ public var errno : Int32 {
96101
return _swift_stdlib_setErrno(val)
97102
}
98103
}
104+
#endif
99105

100106

101107
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)