gnustep / libobjc2

Objective-C runtime library intended for use with Clang.
http://www.gnustep.org/
MIT License
426 stars 116 forks source link

Build error with Visual Studio 17.1 due to stdatomic.h #225

Closed triplef closed 2 years ago

triplef commented 2 years ago

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: 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: 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?

davidchisnall commented 2 years ago

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.

triplef commented 2 years ago

Thanks for your input David. I found that this has been worked around in Clang: https://github.com/llvm/llvm-project/commit/1ad7de9e92bc2977698e5f6d6493202b50c912d5

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