Skip to content

MSVC ARM64 build fails #2193

@Promon-iking

Description

@Promon-iking

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions