Skip to content

Add Windows ARM64 and ARM64EC build support#11599

Open
RyanEwen wants to merge 1 commit into
bambulab:masterfrom
RyanEwen:windows-arm64-support
Open

Add Windows ARM64 and ARM64EC build support#11599
RyanEwen wants to merge 1 commit into
bambulab:masterfrom
RyanEwen:windows-arm64-support

Conversation

@RyanEwen

Copy link
Copy Markdown

What this does

Adds native Windows on ARM support to BambuStudio in two variants:

  • arm64: a fully native ARM64 build. Everything compiles and links for
    ARM64, including OCCT/OpenCASCADE, so STEP import, SVG to 3D and text emboss
    all work. The one limitation is the network plugin (see below).
  • arm64ec: native ARM64 code built with the x64-compatible ABI. An ARM64EC
    process runs the application at native speed and can still load x64-only DLLs
    in process, which is what allows the closed-source Bambu network plugin
    (cloud login, device management, camera) to work. Bambu currently ships that
    plugin as x64 only, so this is the variant most users on ARM would want.

Both are folded into the existing Windows build matrix on the windows-11-arm
runner. All ARM-specific logic is gated, so the x64, x86, macOS and Linux
paths are unchanged.

Why

Windows on ARM machines (Snapdragon X and similar) currently run BambuStudio
under x64 emulation. A native build removes the emulation overhead from
slicing, and the ARM64EC variant keeps full networking/device support while
doing so.

Notes for reviewers

  • The windows-11-arm GitHub runner ships Visual Studio 2022, not 2026, so the
    ARM jobs use the Visual Studio 17 2022 generator and resolve the Windows
    SDK at runtime rather than pinning it.
  • GMP and MPFR have no upstream win-arm64 prebuilt binaries; the ARM64 blobs
    were already present in the tree. MPFR 4.x ships as libmpfr-6.lib, so an
    aliased libmpfr-4.lib is installed for CGAL's FindMPFR.
  • FFMPEG uses BtbN's winarm64 shared build for the ARM targets because the
    bundled prebuilt package is x64 only. The tag and hash are pinned.
  • For ARM64EC, oneTBB is patched at configure time (drop the hard-coded /GL
    that blocks EC links, and stub the Intel TSX intrinsics, which are unreachable
    under emulation but must resolve at link). The patch is a no-op on non-MSVC
    toolchains.
  • OpenSSL for ARM64EC is built as its x64 flavor under the x64 cross
    environment, since ARM64EC links the x64 static libraries.

Testing

  • CI builds, links and uploads native arm64 and arm64ec portable artifacts on
    windows-11-arm; the x64, macOS and Linux jobs remain green.
  • The arm64ec build was validated on a Snapdragon X machine: it launches,
    slices, imports STEP, and loads the x64 network plugin in process (verified
    by module list and by signing in to a Bambu account and driving a printer).

Not included

Signed installer and release-pipeline wiring for the ARM artifacts are left as
a maintainer follow-up. This is a build-and-CI change.

Native ARM64
- Detect ARM64 as the target platform in the dependency and application
  CMake, giving the generator platform (-A) precedence over the host
  processor so an ARM64 host can also build x64 or ARM64EC targets.
- Match ARM64 case-insensitively, since build_win.bat passes "-A arm64"
  while CI passes "-A ARM64" and CMake keeps CMAKE_GENERATOR_PLATFORM verbatim.
- Alias libmpfr-4.lib next to the shipped libmpfr-6.lib so CGAL's FindMPFR,
  whose name list predates the MPFR 4.x "-6" ABI naming, resolves it.
- Pin OpenCV_ARCH and OpenCV_RUNTIME (ARM64, vc17) so find_package matches the
  installed layout; OpenCV 4.6's dispatcher misclassifies MSVC 194x (VS 17.10+).
- Configure OpenSSL as VC-WIN64-ARM, add an ARM64 branch to FindGLEW, and build
  OpenCV and libjpeg-turbo with IPP and SIMD off, since no ARM64 build exists.
- Use the generic C encoder path in minih264e (its NEON path is gated on the
  GCC/Clang macros that MSVC never defines) and the portable multiply in Int128
  (ARM64 MSVC has no _mul128). Add ARM64 branches to StackWalker and
  BaseException (ARM64 CONTEXT has no EFlags).
- Use BtbN's winarm64 FFmpeg build, since the bundled prebuilt is x64 only.
- Add a windows-11-arm CI job that builds and publishes an arm64 portable zip.

ARM64EC
ARM64EC is native ARM64 code with the x64-compatible ABI, so an ARM64EC
process can link the x64 dependency set and load x64-only DLLs, including the
closed-source Bambu network plugin, in process.
- Build the dependency bundle with -A ARM64EC. This injects the flags EC needs
  (force-include intrin.h so the x86 SIMD headers resolve through the emulation
  layer, and silence the resulting C4996/C4005), selects the winfib
  Boost.Context implementation, excludes Boost.JSON and cobalt (they require
  __shiftright128, which has no EC lowering), patches oneTBB to drop the
  hard-coded /GL and to stub the TSX intrinsics, and builds OpenSSL under the
  x64 cross environment.
- Link softintrin.lib and add a standard C fallback for _mm_cvtsd_si64 in
  Clipper2, which have no native EC lowering.
- Add a windows-11-arm arm64ec CI job and put the architecture in the
  dependency cache key so the two variants do not collide on the same runner.

Build system
- Use /Z7 debug info under the Ninja generator (its parallel compiles cannot
  share the per-target /Zi PDB, which otherwise fails with C1041), limited to
  the debug-carrying configurations so a Release static library stays under the
  4 GB archive limit.

All ARM64 and ARM64EC logic is gated so the existing x64, x86, macOS and Linux
build paths are unchanged.
@Haidiye00

Copy link
Copy Markdown
Contributor

good job

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