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

Build errors with ARM64 on Windows #1859

Closed
num3ric opened this issue Sep 19, 2023 · 7 comments
Closed

Build errors with ARM64 on Windows #1859

num3ric opened this issue Sep 19, 2023 · 7 comments
Labels
Build Issue Issues related to build or environment problems on any platform.

Comments

@num3ric
Copy link
Contributor

num3ric commented Sep 19, 2023

cmake -S . -B build -G "Visual Studio 17 2022"^
    -A ARM64^
    -DBUILD_SHARED_LIBS=ON^
    -DOCIO_BUILD_STATIC=OFF^
    -DOCIO_BUILD_TRUELIGHT=OFF^
    -DOCIO_BUILD_APPS=OFF^
    -DOCIO_BUILD_GPU_TESTS=OFF^
    -DOCIO_BUILD_NUKE=OFF^
    -DOCIO_BUILD_DOCS=OFF^
    -DOCIO_BUILD_TESTS=OFF^
    -DOCIO_BUILD_PYGLUE=OFF^
    -DOCIO_BUILD_JNIGLUE=OFF^
    -DOCIO_STATIC_JNIGLUE=OFF^
    -DOCIO_USE_BOOST_PTR=OFF^
    -DOCIO_PYGLUE_LINK=OFF^
    -DOCIO_BUILD_PYTHON=OFF^
    -DCMAKE_INSTALL_PREFIX:PATH=.\install

cmake --build build --config Release --target INSTALL

yields the following build errors:

OpenColorIO-2.3.0\src\OpenColorIO\CPUInfo.cpp(40,12): error C3861: '_xg
etbv': identifier not found
OpenColorIO-2.3.0\src\OpenColorIO\CPUInfo.cpp(52,5): error C3861: '__cp
uid': identifier not found
@num3ric
Copy link
Contributor Author

num3ric commented Sep 19, 2023

At first glance, it looks like the full set of preprocessor checks should be based on defined( __aarch64__ ) || defined( __arm64__ ) || defined( _M_ARM64 ) instead of just __aarch64__, but I could be wrong.

EDIT: Or maybe the fix ought to be in Cmake? I would expect this invocation to disable OCIO_ARCH_X86 actually.

EDIT 2: Maybe this is a CMake bug actually. CMAKE_SYSTEM_PROCESSOR:UNINITIALIZED=ARM64 in the cache but while running CMAKE_SYSTEM_PROCESSOR is AMD64... https://gitlab.kitware.com/cmake/cmake/-/issues/15170

EDIT 3: Adding the following in the NOT APPLE case seems to fix the issue for me:

    if(MSVC)
        set(CMAKE_SYSTEM_PROCESSOR ${MSVC_CXX_ARCHITECTURE_ID})
    endif()

@num3ric
Copy link
Contributor Author

num3ric commented Sep 19, 2023

Tagging @markreidvfx

@doug-walker
Copy link
Collaborator

doug-walker commented Sep 20, 2023

@num3ric , thanks for the report. Would you please provide a bit more detail about the CPU in the machine you are building on and which versions of CMake and MSVC?

@num3ric
Copy link
Contributor Author

num3ric commented Sep 20, 2023

cmake version 3.21.1
Visual Studio 17 2022
OS Name Microsoft Windows 10 Enterprise
Version 10.0.19044 Build 19044
Processor AMD Ryzen Threadripper PRO 3995WX 64-Cores, 2695 Mhz, 64 Core(s), 64 Logical Processor(s)

@doug-walker
Copy link
Collaborator

Thanks for the added detail @num3ric. I was discussing this with Cedrik and we're still not clear on what you're trying to do. We see how your EDIT 3 above would work around an issue where CMAKE_SYSTEM_PROCESSOR has the unexpected value on AMD processors (and we could add AMD64 to the list in the CMake checks). But we're confused by your use of the -A ARM64 option above. Are you trying to cross-compile for a Windows ARM platform on an AMD64 machine? If so, EDIT 3 doesn't seem like it would fix that.

The ARM work we've done so far has been solely for macOS, support for other platforms was not in scope for our work and we've done no testing to support use of ARM on other platforms.

@num3ric
Copy link
Contributor Author

num3ric commented Sep 21, 2023

Yes, it is unusual... https://devblogs.microsoft.com/cppblog/windows-arm64-support-for-cmake-projects-in-visual-studio/

To be honest, we used to support Windows ARM64 for Hololens but that's been dropped, so I don't think we use this build configuration much, if at all, anymore. It's there mostly there for "coverage".

I noticed that CMAKE_SYSTEM_PROCESSOR (which can differ from CMAKE_HOST_SYSTEM_PROCESSOR) wasn't reflecting ARM64, per cmake link above. EDIT 3 fixes the build error... but only sort of accidentally/indirectly by disabling SIMD code: OCIO_ARCH_X86 == 0 & __aarch64__ == 0. Looks like CPUInfo essentially vanishes in this case... Not an official solution by any means.

To be clear, I'm not advocating for Win ARM64 SIMD support, just looking for an error-free build. I'll dig around some more too... I saw that OpenCV may be a good reference here.

@carolalynn carolalynn added the Build Issue Issues related to build or environment problems on any platform. label Feb 7, 2024
@doug-walker
Copy link
Collaborator

Based on @num3ric's testing, this should be fixed by PR #2089.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build Issue Issues related to build or environment problems on any platform.
Projects
None yet
Development

No branches or pull requests

3 participants