Trying to import new foundation on Windows, with the fix for https://github.com/swiftlang/swift/issues/75691, I hit a follow-up issue related to stdatomic that complains about conflicting types for 'atomic_thread_fence':
# command stderr:
<unknown>:0: warning: the '-enable-experimental-cxx-interop' flag is deprecated; please pass '-cxx-interoperability-mode=' instead
<unknown>:0: note: Swift will maintain source compatibility for imported APIs based on the selected compatibility mode, so updating the Swift compiler will not change how APIs are imported
path arg : 'S:\Program Files\Swift\Platforms\Windows.platform\Developer\SDKs\Windows.sdk'
<module-includes>:1:10: note: in file included from <module-includes>:1:
1 | #include "_FoundationCShims.h"
| `- note: in file included from <module-includes>:1:
2 |
S:\Program Files\Swift\Platforms\Windows.platform\Developer\SDKs\Windows.sdk\usr\include\_FoundationCShims/_FoundationCShims.h:17:10: note: in file included from S:\Program Files\Swift\Platforms\Windows.platform\Developer\SDKs\Windows.sdk\usr\include\_FoundationCShims/_FoundationCShims.h:17:
15 |
16 | #include "_CShimsTargetConditionals.h"
17 | #include "_CStdlib.h"
| `- note: in file included from S:\Program Files\Swift\Platforms\Windows.platform\Developer\SDKs\Windows.sdk\usr\include\_FoundationCShims/_FoundationCShims.h:17:
18 | #include "CFUniCharBitmapData.inc.h"
19 | #include "CFUniCharBitmapData.h"
S:\Program Files\Swift\Platforms\Windows.platform\Developer\SDKs\Windows.sdk\usr\include\_FoundationCShims/_CStdlib.h:127:10: note: in file included from S:\Program Files\Swift\Platforms\Windows.platform\Developer\SDKs\Windows.sdk\usr\include\_FoundationCShims/_CStdlib.h:127:
125 | //#if !defined(_WIN32)
126 | #if __has_include(<stdatomic.h>)
127 | #include <stdatomic.h>
| `- note: in file included from S:\Program Files\Swift\Platforms\Windows.platform\Developer\SDKs\Windows.sdk\usr\include\_FoundationCShims/_CStdlib.h:127:
128 | #endif
129 | //#endif
s:\b\5\lib\swift\clang\include\stdatomic.h:81:6: error: conflicting types for 'atomic_thread_fence'
79 |
80 | /* These should be provided by the libc implementation. */
81 | void atomic_thread_fence(memory_order);
| `- error: conflicting types for 'atomic_thread_fence'
82 | void atomic_signal_fence(memory_order);
83 |
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.40.33807\include/atomic:337:36: note: previous definition is here
335 | #endif // _CMPXCHG_MASK_OUT_PADDING_BITS
336 |
337 | _EXPORT_STD extern "C" inline void atomic_thread_fence(const memory_order _Order) noexcept {
| `- note: previous definition is here
338 | ::_Atomic_thread_fence(static_cast<unsigned int>(_Order));
339 | }
<module-includes>:1:10: note: in file included from <module-includes>:1:
1 | #include "_FoundationCShims.h"
| `- note: in file included from <module-includes>:1:
2 |
S:\Program Files\Swift\Platforms\Windows.platform\Developer\SDKs\Windows.sdk\usr\include\_FoundationCShims/_FoundationCShims.h:17:10: note: in file included from S:\Program Files\Swift\Platforms\Windows.platform\Developer\SDKs\Windows.sdk\usr\include\_FoundationCShims/_FoundationCShims.h:17:
15 |
16 | #include "_CShimsTargetConditionals.h"
17 | #include "_CStdlib.h"
| `- note: in file included from S:\Program Files\Swift\Platforms\Windows.platform\Developer\SDKs\Windows.sdk\usr\include\_FoundationCShims/_FoundationCShims.h:17:
18 | #include "CFUniCharBitmapData.inc.h"
19 | #include "CFUniCharBitmapData.h"
S:\Program Files\Swift\Platforms\Windows.platform\Developer\SDKs\Windows.sdk\usr\include\_FoundationCShims/_CStdlib.h:127:10: note: in file included from S:\Program Files\Swift\Platforms\Windows.platform\Developer\SDKs\Windows.sdk\usr\include\_FoundationCShims/_CStdlib.h:127:
125 | //#if !defined(_WIN32)
126 | #if __has_include(<stdatomic.h>)
127 | #include <stdatomic.h>
| `- note: in file included from S:\Program Files\Swift\Platforms\Windows.platform\Developer\SDKs\Windows.sdk\usr\include\_FoundationCShims/_CStdlib.h:127:
128 | #endif
129 | //#endif
<unknown>:0: error: could not build C module '_FoundationCShims'
s:\b\5\lib\swift\clang\include\stdatomic.h:82:6: error: conflicting types for 'atomic_signal_fence'
80 | /* These should be provided by the libc implementation. */
81 | void atomic_thread_fence(memory_order);
82 | void atomic_signal_fence(memory_order);
| `- error: conflicting types for 'atomic_signal_fence'
83 |
84 | #define atomic_thread_fence(order) __c11_atomic_thread_fence(order)
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.40.33807\include/atomic:341:36: note: previous definition is here
339 | }
340 |
341 | _EXPORT_STD extern "C" inline void atomic_signal_fence(const memory_order _Order) noexcept {
| `- note: previous definition is here
342 | if (_Order != memory_order_relaxed) {
343 | _Compiler_barrier();
error: command failed with exit status: 1
Reproduction
import Foundation and enable C++ interop, windows host.
I think the right fix is to make the two definitions between clang and MSVC match, but for now let's workaround this in the new foundation by not including stdatomic
Description
Trying to import new foundation on Windows, with the fix for https://github.com/swiftlang/swift/issues/75691, I hit a follow-up issue related to
stdatomic
that complains about conflicting types for 'atomic_thread_fence':Reproduction
import Foundation and enable C++ interop, windows host.
Expected behavior
It should work.
Environment
Swift main.
Additional information
No response