File tree Expand file tree Collapse file tree 4 files changed +52
-6
lines changed Expand file tree Collapse file tree 4 files changed +52
-6
lines changed Original file line number Diff line number Diff line change @@ -527,6 +527,34 @@ if("WASI" IN_LIST SWIFT_SDKS)
527
527
DESTINATION "lib/swift_static/${arch_subdir} "
528
528
COMPONENT sdk-overlay )
529
529
endif ()
530
+
531
+ set (wasilibc_apinotes_source "SwiftWASILibc.apinotes" )
532
+ add_custom_command_target (
533
+ copy_wasilibc_apinotes_resource
534
+ COMMAND
535
+ "${CMAKE_COMMAND} " "-E" "make_directory" ${SWIFTLIB_DIR} /apinotes ${SWIFTSTATICLIB_DIR} /apinotes
536
+ COMMAND
537
+ "${CMAKE_COMMAND} " "-E" "copy_if_different"
538
+ "${CMAKE_CURRENT_SOURCE_DIR} /${wasilibc_apinotes_source} " ${SWIFTLIB_DIR} /apinotes
539
+ COMMAND
540
+ "${CMAKE_COMMAND} " "-E" "copy_if_different"
541
+ "${CMAKE_CURRENT_SOURCE_DIR} /${wasilibc_apinotes_source} " ${SWIFTSTATICLIB_DIR} /apinotes
542
+ OUTPUT
543
+ ${SWIFTLIB_DIR} /apinotes/${wasilibc_apinotes_source}
544
+ ${SWIFTSTATICLIB_DIR} /apinotes/${wasilibc_apinotes_source}
545
+ COMMENT "Copying WASILibc API notes to resource directories" )
546
+
547
+ list (APPEND wasilibc_modulemap_target_list ${copy_wasilibc_apinotes_resource} )
548
+ add_dependencies (sdk-overlay ${copy_wasilibc_apinotes_resource} )
549
+ swift_install_in_component (FILES "${wasilibc_apinotes_source} "
550
+ DESTINATION "lib/swift/apinotes"
551
+ COMPONENT sdk-overlay )
552
+ if (SWIFT_BUILD_STATIC_STDLIB )
553
+ swift_install_in_component (FILES "${wasilibc_apinotes_source} "
554
+ DESTINATION "lib/swift_static/apinotes"
555
+ COMPONENT sdk-overlay )
556
+ endif ()
557
+
530
558
endforeach ()
531
559
endif ()
532
560
add_custom_target (wasilibc_modulemap DEPENDS ${wasilibc_modulemap_target_list} )
Original file line number Diff line number Diff line change @@ -84,11 +84,6 @@ func _convertDarwinBooleanToBool(_ x: DarwinBoolean) -> Bool {
84
84
85
85
#endif
86
86
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)
92
87
//===----------------------------------------------------------------------===//
93
88
// sys/errno.h
94
89
//===----------------------------------------------------------------------===//
@@ -101,7 +96,6 @@ public var errno : Int32 {
101
96
return _swift_stdlib_setErrno ( val)
102
97
}
103
98
}
104
- #endif
105
99
106
100
107
101
//===----------------------------------------------------------------------===//
Original file line number Diff line number Diff line change
1
+ Name: SwiftWASILibc
2
+ Globals:
3
+ # errno macro is importable but we provide explicit Swift wrapper
4
+ - Name: errno
5
+ SwiftPrivate: true
Original file line number Diff line number Diff line change
1
+ // RUN: %target-swift-frontend -typecheck -swift-version 6 %s -verify
2
+ // REQUIRES: executable_test
3
+ // REQUIRES: OS=wasi
4
+
5
+ import WASILibc
6
+
7
+ // errno is a global thread-local variable, so it should be accessible
8
+ // from any context.
9
+
10
+ enum TestErrno {
11
+ static func testSyncContext( ) {
12
+ _ = errno
13
+ errno = 0
14
+ }
15
+ static func testAsyncContext( ) async {
16
+ _ = errno
17
+ errno = 0
18
+ }
19
+ }
You can’t perform that action at this time.
0 commit comments