apple / swift-atomics

Low-level atomic operations for Swift
Apache License 2.0
1.08k stars 52 forks source link

Windows: 'stdatomic.h' not found #27

Closed Azoy closed 3 years ago

Azoy commented 3 years ago

I'm trying to compile a package of mine that uses this library as a dependency, and when I build the project on Windows I receive the error:

[1/12] Compiling Atomics AtomicValue.swift
<module-includes>:1:10: note: in file included from <module-includes>:1:
#include "D:\projects\Echo\.build\checkouts\swift-atomics\Sources\_AtomicsShims\include\_AtomicsShims.h"
         ^
D:\projects\Echo\.build\checkouts\swift-atomics\Sources\_AtomicsShims\include\_AtomicsShims.h:59:10: error: 'stdatomic.h' file not found
#include <stdatomic.h>
         ^
D:\projects\Echo\.build\checkouts\swift-atomics\Sources\Atomics\AtomicMemoryOrderings.swift:13:8: error: could not build C module '_AtomicsShims'
import _AtomicsShims

I'm currently testing this out with the Swift 5.4 Windows download and using swiftpm.

cc: @compnerd

compnerd commented 3 years ago

This package doesn't work on windows at the moment. But, the error that you are seeing is not the expected failure. I suspect that your setup is missing dependencies or you're running it in the wrong environment.

Azoy commented 3 years ago

I'm following the directions on the Windows section at swift.org/downloads, I've downloaded all the VS components, done the support files, and am running the above in x64 Native Tools. Maybe there's something else I'm missing?

compnerd commented 3 years ago

Hmm, I suspect that the build tools are not installed or if they are you have a mismatch between the build tools and the SDK. There are a number of cases of that on the forums.

troughton commented 2 years ago

Sorry to bump an old issue, but has anything changed in regards to this package on Windows – i.e. is it expected to work? I get the same build error when building with SwiftPM; I can explicitly pass the include path to the Clang headers to bypass it, but then linking fails (presumably since MSVC doesn’t handle C11 atomics).

Link1J commented 2 years ago

@compnerd MSVC doesn't provide a C supported version of <stdatomic.h>. VS2022 does provide it, but only under C++23.

@troughton Nothing has changed. This was never fixed. But using LLVM's header should work just fine, as they use compiler builtins, not functions.

compnerd commented 2 years ago

This was fixed. There is an associated change to clang - 1ad7de9e92bc2977698e5f6d6493202b50c912d5.