erincatto / box2d

Box2D is a 2D physics engine for games
https://box2d.org
MIT License
8.12k stars 1.52k forks source link

'__asm__': undeclared identifier with VS 2022 / ARM64 #798

Open abria opened 6 days ago

abria commented 6 days ago

In solver.c, the following code

#if defined( B2_CPU_ARM )
static inline void b2Pause( void )
{
    __asm__ __volatile__( "isb\n" );
}
#elif defined( B2_CPU_X86_X64 )
#include <immintrin.h>
static inline void b2Pause( void )
{
    _mm_pause();
}
#else
static inline void b2Pause( void )
{
    // no threading will likely be used in web assembly
}
#endif

yields error C2065: '__asm__': undeclared identifier when compiling on Visual Studio 2022 targeting ARM64 platform.

I tried to solve replacing the __asm__ __volatile__( "isb\n" ); call with __dmb(_ARM64_BARRIER_SY); and it compiled, however the CrossPlatformTest failed, which might be due to my change:

Starting Box2D unit tests
======================================
test passed: MathTest
  subtest passed: AABBTest
test passed: CollisionTest
  subtest passed: MultithreadingTest
step = 300, hash = 0x769fe476
condition false: sleepStep == 310
  subtest failed: CrossPlatformTest
test failed: DeterminismTest
erincatto commented 5 days ago

I don't have a Windows ARM computer. I could try adding a github action. It is hard to support a platform with this.