Skip to content

Commit

Permalink
[MSVC] workaround mvn macro and detect ARM64 (#407)
Browse files Browse the repository at this point in the history
Fixed MSVC AArch64 build

* Detect AArch64 target properly when compiling by MSVC
* Workaround the issue caused by MSVC defining a mvn macro

---------

Co-authored-by: Petr Kobalicek <kobalicek.petr@gmail.com>
  • Loading branch information
ZeeWanderer and kobalicek committed Apr 27, 2023
1 parent 5635cf4 commit 3577608
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/asmjit/arm/a64emitter.h
Expand Up @@ -11,6 +11,14 @@
#include "../arm/a64instdb.h"
#include "../arm/a64operand.h"

// MSVC targeting AArch64 defines a lot of macros without underscores clashing
// with AArch64 instruction names. We have to workaround until it's fixed in SDK.
#if defined(_MSC_VER) && defined(mvn)
#define ASMJIT_RESTORE_MSVC_AARCH64_MACROS
#pragma push_macro("mvn")
#undef mvn
#endif

ASMJIT_BEGIN_SUB_NAMESPACE(a64)

#define ASMJIT_INST_0x(NAME, ID) \
Expand Down Expand Up @@ -1225,4 +1233,9 @@ class Emitter : public BaseEmitter, public EmitterExplicitT<Emitter> {

ASMJIT_END_SUB_NAMESPACE

// Restore undefined MSVC AArch64 macros.
#if defined(ASMJIT_RESTORE_MSVC_AARCH64_MACROS)
#pragma pop_macro("mvn")
#endif

#endif // ASMJIT_ARM_A64EMITTER_H_INCLUDED
2 changes: 1 addition & 1 deletion src/asmjit/core/api-config.h
Expand Up @@ -172,7 +172,7 @@ namespace asmjit {
#define ASMJIT_ARCH_X86 0
#endif

#if defined(__arm64__) || defined(__aarch64__)
#if defined(_M_ARM64) || defined(__arm64__) || defined(__aarch64__)
# define ASMJIT_ARCH_ARM 64
#elif defined(_M_ARM) || defined(_M_ARMT) || defined(__arm__) || defined(__thumb__) || defined(__thumb2__)
#define ASMJIT_ARCH_ARM 32
Expand Down

0 comments on commit 3577608

Please sign in to comment.