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

[bug] v0.18.0+ does not recognize Clang with GNU-like command-line on Windows #459

Open
stephanvalentan opened this issue Nov 11, 2022 · 5 comments

Comments

@stephanvalentan
Copy link

I've noticed that a compiler setup with clang (not clang-cl) is not auto-detected on windows any more.
This bug was introduced in the v0.18.0, while on v0.17.0 it works correctly.

The configuration is recognized by cmake like this:

CMAKE_C_COMPILER_ID = Clang
CMAKE_C_COMPILER_FRONTEND_VARIANT = GNU
CMAKE_C_SIMULATE_ID = MSVC

This setup is not recognized by the condition for clang:

...
elseif (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL Clang
        AND NOT "${CMAKE_${LANGUAGE}_COMPILER_FRONTEND_VARIANT}" STREQUAL "MSVC"
        AND NOT "${CMAKE_${LANGUAGE}_SIMULATE_ID}" STREQUAL "MSVC")
...

I think that the last condition can simply be dropped- clang that produces MSVC-ABI code should be recognized as clang.
Without this condition the setup is recognized correctly.

@hwhsu1231
Copy link
Contributor

Agree. However, there is something I need to clarify.

If we install Clang/LLVM from llvm-project, we can see the following two types of Clang compilers:

  • C:\Program Files\LLVM\bin\clang++.exe
  • C:\Program Files\LLVM\bin\clang-cl.exe

According to the issue (conan-io/conan#12424) that I posted previously, both of them should use the SAME the [settings] section since they use the SAME C++ stdlib and runtime dependencies. For example:

[settings]
os=Windows
arch=x86_64
build_type=Release
compiler=clang
compiler.version=13
compiler.cppstd=gnu14
compiler.runtime=dynamic
compiler.runtime_type=Release
compiler.runtime_version=v143

We should call them MSVC-based Clang compilers. The only difference between them is their FRONTEND. Therefore, the condition statement should be like:

elseif ("${CMAKE_${LANGUAGE}_COMPILER_ID}" STREQUAL "Clang"
        AND "${CMAKE_${LANGUAGE}_SIMULATE_ID}" STREQUAL "MSVC")
    # using MSVC-based Clang compilers
    # For example:
    #   C:\Program Files\LLVM\bin\clang.exe
    #   C:\Program Files\LLVM\bin\clang++.exe
    #   C:\Program Files\LLVM\bin\clang-cl.exe
endif ()

@hwhsu1231
Copy link
Contributor

hwhsu1231 commented Nov 13, 2022

I already planned to fulfill the detection of MSVC-based Clang and ClangCL. However, it is required to detect compiler.runtime and compiler.runtime_type settings, which can be detected by the macros implemented in the following PR:

I'm still waiting this PR to be merged, so that I can start to implement the dection of MSVC-based Clang.

@aminya
Copy link

aminya commented Jan 2, 2023

It seems that MSVC and Clang are not detected as of 0.18.1. It worked fine in 0.17.0
aminya/project_options#184

@aminya
Copy link

aminya commented Jul 21, 2023

Any update on this issue? It is blocking project_options' Cmake conan update to 0.18.1

You can see the list of all failing compilers in project_options' testing matrix
aminya/project_options#184

image

@memsharded
Copy link
Member

No updates here, sorry, we are prioritizing at this moment the cmake-conan for Conan 2.0 here: https://github.com/conan-io/cmake-conan/tree/develop2, based on the new CMake dependency providers. Reports and contributions for the develop2 branch are more likely to be able to get some more priority.

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

4 participants