Skip to content

Fix ARM64EC builds by excluding ARM64EC from x64(_M_X64) detection on Windows#265

Merged
aous72 merged 2 commits intoaous72:masterfrom
navvyswethgraphics:arm64ec_windows_msvc
Apr 8, 2026
Merged

Fix ARM64EC builds by excluding ARM64EC from x64(_M_X64) detection on Windows#265
aous72 merged 2 commits intoaous72:masterfrom
navvyswethgraphics:arm64ec_windows_msvc

Conversation

@navvyswethgraphics
Copy link
Copy Markdown
Contributor

Issue description

On Windows builds using MSVC, ARM64EC defines _M_X64 for source‑level compatibility.
As a result, ARM64EC builds were incorrectly classified as "OJPH_ARCH_X86_64", enabling x86-64 specific code paths and build flags. This leads to compilation failures due to unsupported intrinsics and incorrect ABI assumptions.

Build failure evidence (before fix)

1>------ Rebuild All started: Project: ZERO_CHECK, Configuration: Debug ARM64EC ------
1>1>Checking Build System
2>------ Rebuild All started: Project: openjph, Configuration: Debug ARM64EC ------
2>Compiling...
2>Generating Code...
2>ojph_mem_c.c
2>cl : command line warning D9002: ignoring unknown option '/arch:AVX'
2>ojph_codestream_avx.cpp
2>ojph_colour_avx.cpp
2>ojph_transform_avx.cpp
2>Generating Code...
2>C:\FORK\TEMP\OpenJPH\src\core\transform\ojph_transform_avx.cpp(1,1): error C7302: AVX types (__m256) are not currently supported in ARM64EC code
2>C:\FORK\TEMP\OpenJPH\src\core\codestream\ojph_codestream_avx.cpp(1,1): error C7302: AVX types (__m256) are not currently supported in ARM64EC code
2>Done building project "openjph.vcxproj" -- FAILED.
========== Rebuild All: 1 succeeded, 1 failed, 0 skipped ==========
========== Rebuild completed at 11:54 AM and took 09.063 seconds ==========

Type of change

  • Excludes _M_ARM64EC from Windows x86‑64 architecture detection in MSVC builds.
  • Allows ARM64EC (and ARM64) builds to use the existing macro "OJPH_ARCH_ARM" implementation.

The #else block applies to Linux/FreeBSD/OpenBSD builds and is therefore never selected for Windows ARM64 or ARM64EC.
While _M_ARM64EC is not strictly required here, it is included alongside _M_ARM64 for consistency with the existing ARM64 detection logic.

#else  // Linux/FreeBSD/OpenBSD

  #if defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC) // 64-bit ARM

Impact

  • Fixes compilation errors for Windows ARM64EC builds.
  • No behavior changes for existing x86 or x64 builds.

Build & Test

  • Environment: Windows 11 on ARM64; MSVC (VS 2022 v143 toolset).
  • Result: ARM64 and ARM64EC configurations compile cleanly; x86/x64 unchanged.

@navvyswethgraphics navvyswethgraphics changed the title Arm64ec windows msvc Fix ARM64EC builds by excluding ARM64EC from x64(_M_X64) detection on Windows Apr 6, 2026
@aous72
Copy link
Copy Markdown
Owner

aous72 commented Apr 8, 2026

Thank you navvyswethgraphics for this PR.

@aous72 aous72 merged commit d7cd869 into aous72:master Apr 8, 2026
18 checks passed
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.

2 participants