[cfe-dev] clang-cl and _Interlocked* intrinsics

Hans Wennborg via cfe-dev cfe-dev at lists.llvm.org
Wed May 23 06:53:10 PDT 2018


Hi Ethan,

On Wed, May 23, 2018 at 1:37 AM, Ethan Smith via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
> I am working on porting CPython to build with clang-cl on Windows, since I
> expect things like labels as values and other optimizations could provide a
> significant speedup. I am currently running into a strange issue, and was
> directed here from IRC. When I have, for example,
>
> #include <intrin.h>
> #include <immintrin.h>
>
> int main() {
>     _InterlockedCompareExchange64_HLEAcquire(4L, 5L, 6L);
> }
>
> building with cl is fine (minus obvious warnings about long to pointer
> conversion). However, if I build with clang-cl, I get "unresolved external
> symbol _InterlockedCompareExchange64_HLEAcquire referenced in function
> main". When I build this in a Visual Studio solution I also get that
> _InterlockedCompareExchange64_HLEAcquire is implicitly declared, and the
> same link error.
>
> Any advice on something I am doing wrong or ways to fix this would be
> appreciated. For the curious, full branch of CPython is
> https://github.com/ethanhs/cpython/tree/clang-cl . The usage of these
> intrinsics is in pyatomic.h.

You're not doing anything wrong. It's we who haven't implemented those
intrinsics yet.

If you want to work around this until we fix it, you can probably just
use the InterlockedCompareExchange variants without the _HLE* part in
pyatomic.h.

(And if you want to consider contributing a patch for this, it should
be fairly simple to add support based on grepping for
InterlockedCompareExchange64 :-)

Thanks,
Hans



More information about the cfe-dev mailing list