Skip to content

Conversation

K-ballo
Copy link
Collaborator

@K-ballo K-ballo commented Oct 1, 2025

fixes #904

continues the work from #997

makeSingleFileDBForClang(filePath);
#else
makeSingleFileDBForClangCL(filePath);
#endif
Copy link
Collaborator Author

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

Copy link
Collaborator Author

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

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is still arbitrary

:)

Copy link
Collaborator Author

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?

Copy link
Collaborator

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.

Copy link
Collaborator Author

@K-ballo K-ballo Oct 3, 2025

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 ?

https://github.com/llvm/llvm-project/blob/4d32ea87673adaa5252545ca82fa6cd58b134ff9/clang/lib/Driver/ToolChain.cpp#L439

Copy link
Collaborator Author

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?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mizvekov Ideas?

@K-ballo K-ballo marked this pull request as ready for review October 1, 2025 14:18
@cppalliance-bot
Copy link

An automated preview of the documentation is available at https://1045.mrdocs.prtest2.cppalliance.org/index.html

@cppalliance-bot
Copy link

An automated preview of the documentation is available at https://1045.mrdocs.prtest2.cppalliance.org/index.html

@cppalliance-bot
Copy link

An automated preview of the documentation is available at https://1045.mrdocs.prtest2.cppalliance.org/index.html

@cppalliance-bot
Copy link

cppalliance-bot commented Oct 3, 2025

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

@K-ballo
Copy link
Collaborator Author

K-ballo commented Oct 6, 2025

I just found out about clang-cl's /clang: option. Using it still requires conditionals, and it makes working with multiple token options difficult, but we could in principle do:

new_cmdline.emplace_back(is_clang_cl ? "/clang:-std=c++23" : "-std=c++23");
new_cmdline.emplace_back(is_clang_cl ? std::format("/clang:-isystem=\"{}\"", inc) : std::format("-isystem=\"{}\"", inc));

The benefit for these downsides is that mrdocs would not need to know about msvc flags. Thoughts?

@alandefreitas
Copy link
Collaborator

alandefreitas commented Oct 6, 2025

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.

@mizvekov
Copy link
Collaborator

mizvekov commented Oct 6, 2025

Oh yes I knew about the /clang: redirection flag, sorry that I didn't think to bring it up.

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.

@alandefreitas
Copy link
Collaborator

Oh... OK. So it's best to reserve this for flags with no counterpart. Or maybe flags with no obvious counterpart, at least.

@K-ballo
Copy link
Collaborator Author

K-ballo commented Oct 8, 2025

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?

@alandefreitas
Copy link
Collaborator

@alandefreitas @mizvekov what's the procedure?

My procedure is to ask @mizvekov so you already did my procedure :)

@mizvekov
Copy link
Collaborator

mizvekov commented Oct 8, 2025

@K-ballo

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.

@K-ballo
Copy link
Collaborator Author

K-ballo commented Oct 8, 2025

I'd try to preprocess and isolate it first.

@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?

@mizvekov
Copy link
Collaborator

mizvekov commented Oct 8, 2025

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 ?

@K-ballo
Copy link
Collaborator Author

K-ballo commented Oct 8, 2025

The problem is pre-existing and only happens on new tests,

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.

@mizvekov
Copy link
Collaborator

mizvekov commented Oct 8, 2025

The problem is pre-existing and only happens on new tests,

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.

@alandefreitas
Copy link
Collaborator

while parsing libcxx headers

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.

@alandefreitas
Copy link
Collaborator

so I don't see a problem. @alandefreitas ?

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.

@K-ballo
Copy link
Collaborator Author

K-ballo commented Oct 8, 2025

Also, under what conditions is this being triggered?

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)

we may need to reevaluate whether we want sanitizers in dependencies when they are not a strict requirement.

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.

@alandefreitas
Copy link
Collaborator

procedure on how to deal with sanitizer failures in dependencies

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?

@alandefreitas
Copy link
Collaborator

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?

@mizvekov
Copy link
Collaborator

mizvekov commented Oct 8, 2025

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.

@alandefreitas
Copy link
Collaborator

alandefreitas commented Oct 8, 2025

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)

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?

@K-ballo
Copy link
Collaborator Author

K-ballo commented Oct 8, 2025

What does "requires specifying a windows-msvc target" mean in the context of this PR?

passing "-target x86_64-pc-windows-msvc" (or similar) to clang-cl

@alandefreitas
Copy link
Collaborator

alandefreitas commented Oct 8, 2025

passing "-target x86_64-pc-windows-msvc" (or similar) to clang-cl

Ooooooooh. OK. I get it now.

  • You're not passing it via (not "to") the cl driver syntax (not to "clang-cl", which is a program), but
  • the driver implicitly includes -target x86_64-pc-windows-msvc anyway when generating the commands for the frontend, and
  • this leads to a difference in the final commands that
  • probably lead to different conditions in the headers and
  • then leads to an error

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).

@K-ballo
Copy link
Collaborator Author

K-ballo commented Oct 9, 2025

Yes. It makes sense to fix the issue then.

It always makes sense to fix the issue. The question here is whether the clang-fix should be blocked by the clang leak fix.

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

Successfully merging this pull request may close these issues.

--use-system-libc=false is not setting default include paths
4 participants