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

clang (MSVC) kits should specify the 'ClangCL' toolset #2810

Closed
fredemmott opened this issue Oct 20, 2022 · 3 comments · Fixed by #2812
Closed

clang (MSVC) kits should specify the 'ClangCL' toolset #2810

fredemmott opened this issue Oct 20, 2022 · 3 comments · Fixed by #2812
Labels
bug a bug in the product Feature: kits
Milestone

Comments

@fredemmott
Copy link

fredemmott commented Oct 20, 2022

Brief Issue Summary

Currently, the incorrect toolset 'host=amd64' is set (#2790) - as well as correcting 'amd64' to 'x64', ClangCL should be specified - e.g. toolset: "ClangCL,host=x64"

This makes CMAKE_CXX_COMPILER_ID and CMAKE_CXX_SIMULATE_ID bepopulated correctly ('Clang' and 'MSVC' respectively, and the MSVC variable remains correctly set to 1)

For example:

[
  {
    "name": "Custom Clang-CL from MSVC 2022 x64",
    "visualStudio": "ee13335b",
    "visualStudioArchitecture": "x64",
    "preferredGenerator": {
      "name": "Visual Studio 17 2022",
      "platform": "x64",
      "toolset": "ClangCL,host=x64"
    },
    "compilers": {
      "C": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\Llvm\\x64\\bin\\clang-cl.exe",
      "CXX": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\Llvm\\x64\\bin\\clang-cl.exe"
    }
  }
]

CMake Tools Diagnostics

No response

Debug Log

No response

Additional Information

Setting CMAKE_CXX_COMPILER_ID and CMAKE_CXX_SIMULATE_ID is useful to detect ClangCL within CMake; this is occasionally required when MSVC builds require a flag like /await:strict which errors with clang-cl.

@bobbrow
Copy link
Member

bobbrow commented Oct 20, 2022

Thank you for opening this issue. We should fix this in the same PR as the fix for #2790.

@bobbrow bobbrow added bug a bug in the product Feature: kits labels Oct 20, 2022
@bobbrow bobbrow added this to the On Deck milestone Oct 20, 2022
@bobbrow bobbrow linked a pull request Oct 20, 2022 that will close this issue
@fredemmott
Copy link
Author

Another related note is the C and CXX compiler specifications do not appear to do anything when using clang-cl - for example, if I specify:

    "compilers": {
      "C": "C:\\Program Files\\LLVM\\bin\\clang-cl.exe",
      "CXX": "C:\\Program Files\\LLVM\\bin\\clang-cl.exe",
    }

... or specify CMAKE_CXX_COMPILER by hand in the CMakeCache.txt, when using the visual studio generators, cmake will always use the Visual-Studio-bundled clang-cl instead of the one I tell it to.

@bobbrow
Copy link
Member

bobbrow commented Oct 21, 2022

Another related note is the C and CXX compiler specifications do not appear to do anything when using clang-cl - for example, if I specify:

    "compilers": {
      "C": "C:\\Program Files\\LLVM\\bin\\clang-cl.exe",
      "CXX": "C:\\Program Files\\LLVM\\bin\\clang-cl.exe",
    }

... or specify CMAKE_CXX_COMPILER by hand in the CMakeCache.txt, when using the visual studio generators, cmake will always use the Visual-Studio-bundled clang-cl instead of the one I tell it to.

I opened a separate issue for this feedback since I already have a PR open for the original comment.

@bobbrow bobbrow modified the milestones: On Deck, 1.13 Nov 11, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Dec 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug a bug in the product Feature: kits
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants