Skip to content

MSVC ARM64 build fails #2193

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

Open
Promon-iking opened this issue May 27, 2025 · 3 comments
Open

MSVC ARM64 build fails #2193

Promon-iking opened this issue May 27, 2025 · 3 comments

Comments

@Promon-iking
Copy link

Promon-iking commented May 27, 2025

Hi,

I am having trouble building unicorn using MSVC on an ARM machine for Windows.

Using Visual Studio 2022 with version 14.36.32532 build tools (ARM/ARM64 both installed)

CMake version 4.0.2

Following the instructions I get the following output when running the cmake command

PS unicorn-2.1.3\build> cmake .. -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release
CMake Deprecation Warning at CMakeLists.txt:4 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.


-- The C compiler identification is MSVC 19.36.32548.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.36.32532/bin/Hostx64/arm64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- The ASM_MASM compiler identification is unknown
-- Found assembler: ml
-- Configuring done (1.7s)
-- Generating done (0.2s)

As you can see it doesn't detect the MASM assembler, properly and hence the build fails when it tries to assemble CMakeFiles/unicorn-common.dir/qemu/util/setjmp-wrapper-win32.asm.obj with the following error

[  4%] Building ASM_MASM object CMakeFiles/unicorn-common.dir/qemu/util/setjmp-wrapper-win32.asm.obj
'ml' is not recognized as an internal or external command,

When I manually set tell CMAKE where the MASM assembler is by setting the cmake option manually using -DCMAKE_ASM_MASM_COMPILER='C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.36.32532\bin\Hostx64\arm64\ml64.exe' the cmake command succeeds.

PS <omitted>\unicorn-2.1.3\build> cmake .. -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_ASM_MASM_COMPILER='C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.36.32532\bin\Hostx64\arm64\ml64.exe'
CMake Deprecation Warning at CMakeLists.txt:4 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.


-- The C compiler identification is MSVC 19.36.32548.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.36.32532/bin/Hostx64/arm64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- The ASM_MASM compiler identification is MSVC
-- Found assembler: C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.36.32532/bin/Hostx64/arm64/ml64.exe
-- Configuring done (1.5s)
-- Generating done (0.2s)
-- Build files have been written to: <omitted>/unicorn-2.1.3/build

But then when I try to build unicorn, I get the following error

[  4%] Building ASM_MASM object CMakeFiles/unicorn-common.dir/qemu/util/setjmp-wrapper-win32.asm.obj
Microsoft (R) Macro Assembler (x64) Version 14.36.32548.0
Copyright (C) Microsoft Corporation.  All rights reserved.

 Assembling: <omitted>\unicorn-2.1.3\qemu\util\setjmp-wrapper-win32.asm
[  5%] Linking C static library unicorn-common.lib
CMakeFiles\unicorn-common.dir\qemu\util\setjmp-wrapper-win32.asm.obj : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'ARM64'
NMAKE : fatal error U1077: 'C:\PROGRA~1\MICROS~3\2022\PROFES~1\VC\Tools\MSVC\1436~1.325\bin\Hostx64\arm64\lib.exe /nologo /machine:ARM64 /out:unicorn-common.lib @CMakeFiles\unicorn-common.dir\objects1.rsp' : return code '0x458'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.36.32532\bin\HostX64\ARM64\nmake.exe" -s -f CMakeFiles\unicorn-common.dir\build.make /nologo -SL                 CMakeFiles\unicorn-common.dir\build' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.36.32532\bin\HostX64\ARM64\nmake.exe" -s -f CMakeFiles\Makefile2 /nologo -S                  all' : return code '0x2'
Stop.

When running dumpbin.exe on the generated setjmp-wrapper-win32.asm.obj it gives me the following

Dump of file <omitted>\unicorn-2.1.3\build\CMakeFiles\unicorn-common.dir\qemu\util\setjmp-wrapper-win32.asm.obj

File Type: COFF OBJECT

FILE HEADER VALUES
            8664 machine (x64)
               3 number of sections
        68354BCF time date stamp Tue May 27 15:21:19 2025
             15A file pointer to symbol table
               A number of symbols
               0 size of optional header
               0 characteristics

Which means maybe the command for ml64.exe was incorrect? Why would it generated an x64 object file when the specific path to the assembler is given that is from the ARM64 toolchain. I'm not sure whether this is a CMAKE problem or whether the CMake file itself is written incorrectly for ARM on Windows.

Any ideas?

@wtdcode
Copy link
Member

wtdcode commented May 27, 2025

Windows arm64 is not supported by design. I don't have access to such hardware for testing.

@Promon-iking
Copy link
Author

Promon-iking commented May 27, 2025

Would it be a lot of work to get it working on ARM on WIndows? What are the main blockers?

@wtdcode
Copy link
Member

wtdcode commented May 28, 2025

Not a lot, but it needs testing.

The main blockers are that we are using a few assemblies, as you already noticed.

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

No branches or pull requests

2 participants