gnustep/libobjc2

Build error with Visual Studio 17.1 due to stdatomic.h

triplef opened this issue · 2 comments

The latest CI build of the GNUstep MSVC toolchain failed building the libobjc2 tests with this error:

C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.31.31103\include\stdatomic.h(15,2): error: <stdatomic.h> is not yet supported when compiling as C, but this is planned for a future release.

What changed since the last CI build is that the GitHub Runner VM was updated from 20220116.1 to 20220220.1, which includes a Visual Studio update from 17.0 to 17.1. The changelog contains the following change regarding stdatomic:

P0943R6 #2008 Supporting C Atomics In C++

  • Note: <stdatomic.h> is currently supported when compiling as C++ (/std:c++latest). It is not yet supported when compiling as C (/std:c11 and /std:c17), but support for C atomics is planned for a future release. For more info, see the September 2020 blog post "C11 and C17 Standard Support Arriving in MSVC".

Not sure if I’m missing something, though it seems a bit crazy that they would have broken stdatomic support in C with this release. Any ideas how to work around this?

We're compiling with clang, and I believe clang has a stdatomic.h that does #include_next of the system one if it exists. I think in MSVC _Atomic(T) is defined as std::atomic<T>, so we could compile those files in C++ mode.

We only use stdatomic.h in tests, so we could probably just skip them on Windows.

Thanks for your input David. I found that this has been worked around in Clang: llvm/llvm-project@1ad7de9

I’ll simply disable building the tests for now until this patch or C atomics land with a future VS update.