Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for building for Windows on ARM64, natively. #13116

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

hmartinez82
Copy link

@hmartinez82 hmartinez82 commented Jul 18, 2024

This adds the required changes to build for Windows on ARM on a Windows on ARM machine. No cross compilation supported yet.

Notable changes:

  • Adds pre-compiled MPFR and GMP binaries
  • Uses the correct WebView2Loader on ARM64 machines

Fixes #13107 and #12291
image

image

image

@hmartinez82
Copy link
Author

@JustinBeckerMSFT ^_^

ElectricalBoy added a commit to ElectricalBoy/Orca-deps-wxWidgets that referenced this pull request Jul 18, 2024
ElectricalBoy added a commit to ElectricalBoy/Orca-deps-wxWidgets that referenced this pull request Jul 18, 2024
ElectricalBoy added a commit to ElectricalBoy/Orca-deps-wxWidgets that referenced this pull request Jul 18, 2024
@eblieb
Copy link

eblieb commented Jul 18, 2024

Can't you use ARM64X to fix the cross compatibility issue?

@hmartinez82
Copy link
Author

Can't you use ARM64X to fix the cross compatibility issue?

It's already working, everything fully native.
No need to use Arm64X 🙂

@ggppjj
Copy link

ggppjj commented Jul 18, 2024

I believe they meant "to enable cross-compilation".

@hmartinez82
Copy link
Author

hmartinez82 commented Jul 18, 2024

I believe they meant "to enable cross-compilation".

Well that's not what ARM64EC/ARM64X are used for. Those are ABI types. It has nothing to do with the ability to build an ARM64, ARM64EC or ARM64X binary from a x64 host machine. (The latter is which I mean by cross-compilation).

@JustinBeckerMSFT
Copy link

@hmartinez82 Excellent work! What is the minimal command line invocation I need to try building this on my machine?

@hmartinez82
Copy link
Author

hmartinez82 commented Jul 18, 2024

@JustinBeckerMSFT from a native ARM64 Developer Command Prompt in a ARM64 machine, the build instructions are the same as the manual x64 ones as detailed here: https://github.com/prusa3d/PrusaSlicer/blob/master/doc/How%20to%20build%20-%20Windows.md#2a-manual-build-instructions

Copy link
Collaborator

@SachCZ SachCZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @hmartinez82,
thank you very much for your work. It is a very valuable addition which we intend to use to enable building for windows on ARM64. It seems everything you proposed look good!

From our position we have the luxury to update some dependencies (something we want to do anyway) so some of the patches will not be necessary. I added notes about the versions in the review.

Also the state of cmake around mpfr + gmp on windows can be described as "not great". We intend to take arm64 into consideration when addressing it.

The final thing is that we will have to create/source our own gmp and mpfr dlls as we cannot just include any binary in our codebase for security reasons. I am absolutely certain that your intentions are pure, so please do not take it personally.

Comment on lines +7 to +8
-#if defined(BOOST_JSON_HAS_MSVC_32BIT_INTRINSICS)
+#if defined(BOOST_JSON_HAS_MSVC_32BIT_INTRINSICS) && !defined(_M_ARM64)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in boost 1.84.0 so we will rather update boost.

Copy link
Author

@hmartinez82 hmartinez82 Oct 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SachCZ I'm finally back. When do you think this will happen. I can rebase this branch (I'm 280+ commits behind). And I would like to keep the branch in a buildable state.

target_compile_definitions (glew PRIVATE "GLEW_BUILD;VC_EXTRALEAN")
target_compile_definitions (glew_s PRIVATE "GLEW_STATIC;VC_EXTRALEAN")
- target_link_libraries (glew LINK_PRIVATE -BASE:0x62AA0000)
+ if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(i?86|x86|x86_32)$")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future reference: fix is in glew master but it is not released yet.

Comment on lines -6 to +18
set(_output ${_dstdir}/include/gmp.h
${_dstdir}/lib/libgmp-10.lib
${_dstdir}/bin/libgmp-10.dll)
set(_output ${_dstdir}/include/gmp.h)

if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(ARM64|aarch64)$")
list(APPEND _output ${_dstdir}/lib/gmp.lib
${_dstdir}/bin/gmp-10.dll)
set(_gmplib winarm64/gmp.lib)
set(_gmpdll winarm64/gmp-10.dll)
else()
list(APPEND _output ${_dstdir}/lib/libgmp-10.lib
${_dstdir}/bin/libgmp-10.dll)
set(_gmplib win${DEPS_BITS}/libgmp-10.lib)
set(_gmpdll win${DEPS_BITS}/libgmp-10.dll)
endif()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the near future we want to refactor the cmake so it uses an interface target to link against the pre-compiled dlls. We will move these ifs there.

Comment on lines +38 to +39
-#if defined __SSE2__ || (_MSC_VER >= 1300 && !_M_CEE_PURE)
+#if defined __SSE2__ || (_MSC_VER >= 1300 && !_M_CEE_PURE) && !defined(_M_ARM64)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is hopefully fixed in OpenEXR 3.2.0.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently so, the file is now way more comprehensive and even has NEON optimizations https://github.com/AcademySoftwareFoundation/openexr/blob/v3.3.0/src/lib/OpenEXR/ImfSimd.h

deps/+wxWidgets/wxWidgets.patch Outdated Show resolved Hide resolved
@hmartinez82
Copy link
Author

hmartinez82 commented Sep 19, 2024

Understood. I'll remove the binaries and rebase this branch on top of master.
Also feel free to modify the branch directly. I allowed maintainer pushes.

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.

[Tracking] Tasks required for Windows on ARM64 build
5 participants