-
Notifications
You must be signed in to change notification settings - Fork 22
fix: support clang-cl #1045
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
base: develop
Are you sure you want to change the base?
fix: support clang-cl #1045
Conversation
src/test/TestRunner.cpp
Outdated
makeSingleFileDBForClang(filePath); | ||
#else | ||
makeSingleFileDBForClangCL(filePath); | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is still arbitrary.. there's no reason why both drivers couldn't be tested on every platform
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
furthermore, this triggers unused function warnings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is still arbitrary
:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would you suggest we run every test twice?
or should I rather conditionally define the one we're actually testing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would you suggest we run every test twice?
Sure. All platforms must be able to read both file formats, so it makes sense to test both formats on all platforms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to change the program name from "clang-cl" to just "cl", otherwise clang wasn't recognizing "/std:c++latest" on linux/macos. I do not have an explanation for this, why would it depend on the environment? @mizvekov ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This didn't work out either. Is it possible to use CL mode on linux/macox? Does it require explicit --driver-mode
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mizvekov Ideas?
An automated preview of the documentation is available at https://1045.mrdocs.prtest2.cppalliance.org/index.html |
An automated preview of the documentation is available at https://1045.mrdocs.prtest2.cppalliance.org/index.html |
An automated preview of the documentation is available at https://1045.mrdocs.prtest2.cppalliance.org/index.html |
An automated preview of the documentation is available at https://1045.mrdocs.prtest2.cppalliance.org/index.html If more commits are pushed to the pull request, the docs will rebuild at the same URL. 2025-10-08 16:26:36 UTC |
c546c2f
to
c2b61ad
Compare
I just found out about clang-cl's
The benefit for these downsides is that mrdocs would not need to know about msvc flags. Thoughts? |
That's a fantastic discovery! In most cases, things would get much more readable because we would be expressing directly in code that we explicitly want both options in the ternary operator to represent the same thing. We can even write a lambda or something that optionally wraps the flags with it, and the code would get much simpler. Maybe @mizvekov knows of some drawbacks. |
Oh yes I knew about the Using the redirection flag skips any driver specific behavior for that flag, the driver simply forwards it to another driver. This could be, as one simple example, checking that one flag is compatible with another one. I'd say this is best used for flags which don't have a specific counterpart in the cl driver. I suppose it's not a big deal if we use it with a limited set of flags and use cases we have vetted are ok, but then this wouldn't be a big advantage versus simply not using it. |
Oh... OK. So it's best to reserve this for flags with no counterpart. Or maybe flags with no obvious counterpart, at least. |
Everything should be in order now, but the PR is triggering some leaks deep within clang (while parsing libcxx headers). @alandefreitas @mizvekov what's the procedure? |
My procedure is to ask @mizvekov so you already did my procedure :) |
I'd try to preprocess and isolate it first. These are probably clang bugs, I had to fix a few of these leaks in the past. While clang is in general extensively tested with sanitizers, we run clang in a configuration which is not so tested, and there likely lies the problem. |
@mizvekov does that mean the clang-cl fix will be on hold until the clang leak is fixed upstream and mrdocs bumps its target llvm commit? |
Yeah, but you could simply not commit the libc++ tests at this point, send that to a separate PR and lets fix it there. The problem is pre-existing and only happens on new tests, so I don't see a problem. @alandefreitas ? |
The problem happens on existing tests, when run under a new configuration. So I take it the way to proceed is to leave clang-cl tests out on non-windows platforms. |
Yeah, that sounds fair to me, it would unblock this PR. |
Is that in the new test, any of the old tests, or both? If it's in any of the old tests or both, is it test-files/golden-tests/core/libcxx.cpp? I can't remember any other that would try to parse libcxx headers. Also, under what conditions is this being triggered? Both CL and non-CL mode? All platforms? In this PR, the stubs haven't been replaced yet, and although we use a different driver, it's always clang under the hood. So the problem was already there, right? Is any sanitizer catching this? Depending on the case, we may need to reevaluate whether we want sanitizers in dependencies when they are not a strict requirement. The ROI is very low (for the ones with false negatives only: ASan and UBSan) so we'll have to remove them from dependencies if they keep getting bugs we can't fix. Especially after #1030, when we won't be able to control the environment as much. |
In general, I agree with the "feeling", so to speak. But at the same time, unblocking PRs is not our end goal in itself. We need to have clarity about the conditions under which we're seeing the bug, including which tests it appears in, what came before the PR, what's causing it, and how complex it would be to fix. With this information, we can make an informed decision on what's more beneficial to the project. It could be just fixing it or opening an independent issue that "unblocks" the PR. |
Clang 21: C++20 (ASan) is reporting a leak deep within clang when testing test-files/golden-tests/core/libcxx.cpp in CL mode (requires specifying a windows-msvc target)
There should be a procedure on how to deal with sanitizer failures in dependencies. I'm not saying they should be ignored, I don't think it's reasonable to hold important fixes. |
Exactly. That's why I made all those questions. The details matter here. CI will not be able to determine where the problem originates. @mizvekov Isn't ASan supposed to be making CI fail, by the way? |
Doesn't Asan in clang include LSan? Or is it disabled for some reason? Or if it doesn't, maybe that's why the GCC PR is failing? |
It is failing, I believe this PR is only passing because @K-ballo just disabled the libcxx tests here, in other to confirm the problem. |
What does "requires specifying a windows-msvc target" mean in the context of this PR? Only that the compilation database we give clang uses CL syntax? |
passing "-target x86_64-pc-windows-msvc" (or similar) to clang-cl |
Ooooooooh. OK. I get it now.
OK. Since this is not ultimately compiled to any target anyway (clang is just parsing the code), the problem is related to some MACRO being defined at this lower level. Yes. It makes sense to fix the issue then. It's not an unrelated blocker, but the logic most Windows users will be using. Or at least not ignoring the issue completely and moving on without caring about what's happening. One thing you might want to play with is disabling the libcxx stubs option for this text case, although I'm not sure tests look for the implicit compiler include paths to replace the stubs (the other issue will have to do it sooner or later because it's a requirement for some tests). |
It always makes sense to fix the issue. The question here is whether the clang-fix should be blocked by the clang leak fix. |
fixes #904
continues the work from #997