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

Feature Request: Clang support under Windows #7

Open
mchagneux opened this issue Sep 18, 2024 · 2 comments
Open

Feature Request: Clang support under Windows #7

mchagneux opened this issue Sep 18, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@mchagneux
Copy link

Hi !

I'm trying to work on Windows with a cross-platform toolchain so I'm using Ninja + Clang for my project. Since Clang for MSCV is ABI compatible with MSVC code, everything works fine with the anira binaries except for Clang errors related to the symbols \bigobjand \EHsc. Those flags are set in \lib\cmake\Caffe2\Caffe2Targets.cmake in the pre-built binaries (0.1.2), so it's possible to make it work by changing:

set_target_properties(torch_cpu PROPERTIES
  INTERFACE_COMPILE_DEFINITIONS "USE_DISTRIBUTED;USE_C10D_GLOO"
  INTERFACE_COMPILE_OPTIONS "\$<\$<COMPILE_LANGUAGE:CXX>:;\$<\$<OR:\$<CONFIG:Debug>,\$<CONFIG:RelWithDebInfo>>:/Z7>;/EHsc;/bigobj>"
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
  INTERFACE_LINK_LIBRARIES "protobuf::libprotobuf;c10;caffe2::mkl"
)

into

if (MSVC)
    set_target_properties(torch_cpu PROPERTIES
    INTERFACE_COMPILE_DEFINITIONS "USE_DISTRIBUTED;USE_C10D_GLOO"
    INTERFACE_COMPILE_OPTIONS "\$<\$<COMPILE_LANGUAGE:CXX>:;\$<\$<OR:\$<CONFIG:Debug>,\$<CONFIG:RelWithDebInfo>>:/Z7>;/EHsc;/bigobj>"
    INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
    INTERFACE_LINK_LIBRARIES "protobuf::libprotobuf;c10;caffe2::mkl"
    )
else()
    set_target_properties(torch_cpu PROPERTIES
    INTERFACE_COMPILE_DEFINITIONS "USE_DISTRIBUTED;USE_C10D_GLOO"
    INTERFACE_COMPILE_OPTIONS "\$<\$<COMPILE_LANGUAGE:CXX>:;\$<\$<OR:\$<CONFIG:Debug>,\$<CONFIG:RelWithDebInfo>>:/Z7>;-fexceptions>"
    INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
    INTERFACE_LINK_LIBRARIES "protobuf::libprotobuf;c10;caffe2::mkl"
    )
endif()

I don't know if this .cmake file is written as part of your code or if it comes with the libtorch library. In the latter case maybe there's a CMake command that could be used to intercept the MSVC flags and change them before compilation (this way there's no need to change the libtorch code), but I don't know it. If it's part of your code I suggest making the change so that this toolchain is readily enable on Windows.

Best,

Mathis.

@faressc
Copy link
Member

faressc commented Sep 18, 2024

These cmake files are part of the libtorch library. They look like they are automatically generated by the libtorch cmake install command. So it's something we cann't change since we download the libs from their servers on build.

@faressc faressc added the enhancement New feature or request label Sep 18, 2024
@faressc faressc changed the title Compiling with Clang for MSVC Windows raises error, fix possible. Clang support for libtorch under Windows. Sep 18, 2024
@faressc
Copy link
Member

faressc commented Sep 18, 2024

We will think about your suggestion with the compile flags and report back :)

@vackva vackva changed the title Clang support for libtorch under Windows. Feature Request: Clang support under Windows Nov 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants