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

Can't find system headers on Windows #44

Open
e8y opened this issue Apr 10, 2023 · 0 comments
Open

Can't find system headers on Windows #44

e8y opened this issue Apr 10, 2023 · 0 comments

Comments

@e8y
Copy link

e8y commented Apr 10, 2023

My project builds with clang-cl, but when I use this aspect, it doesn't see certain system headers. Looking into the clang invocation with (-v), it seems the toolchain is slightly different and the system header dirs aren't right when invoked by the aspect.

My workspace .bazelrc file:

build --incompatible_enable_cc_toolchain_resolution
build --compiler=clang-cl
build --cxxopt=/std:c++20
build --cxxopt=-Wno-macro-redefined
build --cxxopt=-v

build:clang-tidy --aspects @bazel_clang_tidy//clang_tidy:clang_tidy.bzl%clang_tidy_aspect
build:clang-tidy --output_groups=report
build:clang-tidy --@bazel_clang_tidy//:clang_tidy_config=//:clang_tidy_config

When I build with bazel build, I see this coming from clang:

"C:\\Program Files\\LLVM\\bin\\clang-cl.exe"
-cc1
-triple
x86_64-pc-windows-msvc19.35.32215
[ ... omitted ... ]
-internal-isystem
"C:\\Program Files\\LLVM\\lib\\clang\\16\\include"
-internal-isystem
"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.35.32215\\include"
-internal-isystem
"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.35.32215\\ATLMFC\\include"
-internal-isystem
"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Auxiliary\\VS\\include"
-internal-isystem
"C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.19041.0\\ucrt"
-internal-isystem
"C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.19041.0\\\\um"
-internal-isystem
"C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.19041.0\\\\shared"
-internal-isystem
"C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.19041.0\\\\winrt"
-internal-isystem
"C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.19041.0\\\\cppwinrt"
-internal-isystem
"C:\\Program Files\\LLVM\\lib\\clang\\16.0.0\\include"

This is correct, and it builds without error.

But when I build with the aspect (bazel build --config=clang-tidy), I see a different triple and system header dirs that don't exist:

"C:\\work\\_bazel\\grcgufmr\\execroot\\__main__\\bazel-out\\x64_windows-fastbuild\\bin\\external\\ext\\llvm\\bin\\clang-tool"
"-cc1"
"-triple"
"x86_64-pc-windows-msvc19.20.0"
[ ... omitted ... ]
"-internal-isystem"
"C:\\work\\_bazel\\grcgufmr\\execroot\\__main__\\bazel-out\\x64_windows-fastbuild\\bin\\external\\ext\\llvm\\lib\\clang\\16\\include"
"-internal-isystem"
"C:/Program Files/Microsoft Visual Studio 10.0/VC/include"
"-internal-isystem"
"C:/Program Files/Microsoft Visual Studio 9.0/VC/include"
"-internal-isystem"
"C:/Program Files/Microsoft Visual Studio 9.0/VC/PlatformSDK/Include"
"-internal-isystem"
"C:/Program Files/Microsoft Visual Studio 8/VC/include"
"-internal-isystem"
"C:/Program Files/Microsoft Visual Studio 8/VC/PlatformSDK/Include"

I see that clang_tidy_aspect has an attribute _cc_toolchain but I'm not sure what to put there, or if/how it's being consumed. I gather that _toolchain_flags is where these flags come from.

Can anyone provide guidance? I'm unsure if this is a bug, or just an issue with my use case. Thanks!

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

1 participant