Skip to content

Fix build on arm64ec.#16014

Merged
slouken merged 1 commit into
libsdl-org:mainfrom
madewokherd:arm64ec
Jul 21, 2026
Merged

Fix build on arm64ec.#16014
slouken merged 1 commit into
libsdl-org:mainfrom
madewokherd:arm64ec

Conversation

@madewokherd

Copy link
Copy Markdown
Contributor
  • I confirm that I am the author of this code and release it to the SDL project under the Zlib license. This contribution does not contain code from other sources, including code generated by a Large Language Model ("AI").

Fixes the build on arm64ec, which reports itself as x86_64 even though it's an arm architecture, by disabling code sections with x86_64 assembly on arm64ec.

@cgutman

cgutman commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

What compiler are you using that sets __arm64ec__?

@madebr

madebr commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

What are the errors you're seeing? I remember successfully building a arm64ec SDL3.

@madewokherd

Copy link
Copy Markdown
Contributor Author

What compiler are you using that sets __arm64ec__?

llvm-mingw

@madewokherd

Copy link
Copy Markdown
Contributor Author

What are the errors you're seeing? I remember successfully building a arm64ec SDL3.

[  7%] Building C object CMakeFiles/SDL3-shared.dir/src/atomic/SDL_spinlock.c.obj
/home/meh/wine-mono/SDL3/src/atomic/SDL_spinlock.c:157:13: error: unrecognized instruction mnemonic
  157 |             SDL_CPUPauseInstruction();
      |             ^
/home/meh/wine-mono/SDL3/include/SDL3/SDL_atomic.h:359:60: note: expanded from macro 'SDL_CPUPauseInstruction'
  359 |     #define SDL_CPUPauseInstruction() __asm__ __volatile__("pause\n")  /* Some assemblers can't do REP NOP, s...
      |                                                            ^
<inline asm>:1:2: note: instantiated into assembly here
    1 |         pause
      |         ^
1 error generated.

and later:

[  9%] Building C object CMakeFiles/SDL3-shared.dir/src/cpuinfo/SDL_cpuinfo.c.obj
/home/meh/wine-mono/SDL3/src/cpuinfo/SDL_cpuinfo.c:174:7: error: unknown register name '%rax' in asm
  174 |     : "%rax", "%rcx"
      |       ^
/home/meh/wine-mono/SDL3/src/cpuinfo/SDL_cpuinfo.c:294:13: error: invalid output constraint '=a' in asm
  294 |             cpuid(0, a, b, c, d);
      |             ^
/home/meh/wine-mono/SDL3/src/cpuinfo/SDL_cpuinfo.c:247:11: note: expanded from macro 'cpuid'
  247 |         : "=a"(a), "=S"(b), "=c"(c), "=d"(d) \
      |           ^
/home/meh/wine-mono/SDL3/src/cpuinfo/SDL_cpuinfo.c:297:17: error: invalid output constraint '=a' in asm
  297 |                 cpuid(1, a, b, c, d);
      |                 ^
/home/meh/wine-mono/SDL3/src/cpuinfo/SDL_cpuinfo.c:247:11: note: expanded from macro 'cpuid'
  247 |         : "=a"(a), "=S"(b), "=c"(c), "=d"(d) \
      |           ^
/home/meh/wine-mono/SDL3/src/cpuinfo/SDL_cpuinfo.c:308:31: error: invalid output constraint '=a' in asm
  308 |                             : "=a"(a)
      |                               ^
/home/meh/wine-mono/SDL3/src/cpuinfo/SDL_cpuinfo.c:597:9: error: invalid output constraint '=a' in asm
  597 |         cpuid(7, a, b, c, d);
      |         ^
/home/meh/wine-mono/SDL3/src/cpuinfo/SDL_cpuinfo.c:247:11: note: expanded from macro 'cpuid'
  247 |         : "=a"(a), "=S"(b), "=c"(c), "=d"(d) \
      |           ^
/home/meh/wine-mono/SDL3/src/cpuinfo/SDL_cpuinfo.c:619:9: error: invalid output constraint '=a' in asm
  619 |         cpuid(7, a, b, c, d);
      |         ^
/home/meh/wine-mono/SDL3/src/cpuinfo/SDL_cpuinfo.c:247:11: note: expanded from macro 'cpuid'
  247 |         : "=a"(a), "=S"(b), "=c"(c), "=d"(d) \
      |           ^
/home/meh/wine-mono/SDL3/src/cpuinfo/SDL_cpuinfo.c:688:13: error: invalid output constraint '=a' in asm
  688 |             cpuid(0x00000000, a, b, c, d);
      |             ^
/home/meh/wine-mono/SDL3/src/cpuinfo/SDL_cpuinfo.c:247:11: note: expanded from macro 'cpuid'
  247 |         : "=a"(a), "=S"(b), "=c"(c), "=d"(d) \
      |           ^
/home/meh/wine-mono/SDL3/src/cpuinfo/SDL_cpuinfo.c:867:9: error: invalid output constraint '=a' in asm
  867 |         cpuid(0x00000001, a, b, c, d);
      |         ^
/home/meh/wine-mono/SDL3/src/cpuinfo/SDL_cpuinfo.c:247:11: note: expanded from macro 'cpuid'
  247 |         : "=a"(a), "=S"(b), "=c"(c), "=d"(d) \
      |           ^
/home/meh/wine-mono/SDL3/src/cpuinfo/SDL_cpuinfo.c:870:9: error: invalid output constraint '=a' in asm
  870 |         cpuid(0x80000005, a, b, c, d);
      |         ^
/home/meh/wine-mono/SDL3/src/cpuinfo/SDL_cpuinfo.c:247:11: note: expanded from macro 'cpuid'
  247 |         : "=a"(a), "=S"(b), "=c"(c), "=d"(d) \
      |           ^
9 errors generated.

@icculus

icculus commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

The compiler is defining __x86_64__ and also __arm64ec__...? That seems unexpected.

@madewokherd

Copy link
Copy Markdown
Contributor Author

It is an odd choice, but it's consistent with how msvc does it (although they use _M_AMD64 and _M_ARM64EC).

@slouken

slouken commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Yeah, this platform is native ARM64 and interprets x86_64 instructions.

@icculus

icculus commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Well then this seems reasonable to merge...?

@slouken
slouken merged commit 3fc8509 into libsdl-org:main Jul 21, 2026
10 checks passed
@slouken slouken added this to the 3.4.14 milestone Jul 21, 2026
@slouken

slouken commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Merged, thanks!

@madewokherd
madewokherd deleted the arm64ec branch July 22, 2026 03:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants