clang-build.ps1: -tidy -parallel gives errors (introduced with always writing a .clang-tidy file)
See original GitHub issuePR #886 broke clang-build.ps1 MySolution.sln -tidy .clang-tidy -parallel
.
With this (simplified) snippet from Function Run-ClangJobs
:
if (![string]::IsNullOrWhiteSpace($job.TidyFlagsTempFile) -and (Test-Path $job.TidyFlagsTempFile))
{
$clangTidyFile = "$cppDirectory\.clang-tidy"
}
if (![string]::IsNullOrWhiteSpace($clangTidyFile))
{
Copy-Item -Path $job.TidyFlagsTempFile -Destination $clangTidyFile #### A
}
$callOutput = cmd.exe /c "$($job.FilePath) $($job.ArgumentList) 2>&1" | Out-String #### B
if (![string]::IsNullOrWhiteSpace($clangTidyFile))
{
Remove-Item $clangTidyFile #### C
}
I’ve got .clang-tidy
, project\a.cpp
and project\b.cpp
, and run tidy on a.cpp
and b.cpp
. They start right after each other.
First, a.cpp get at A
and copies .clang-tidy
to project\.clang-tidy
. Then it starts processing for some time (B
).
Meanwhile b.cpp
gets at A
and copies .clang-tidy
to project\.clang-tidy
, but that already exists! Then it also starts processing for some time (B
).
After processing is done (say, a.cpp
is a bit quicker), it removes project\.clang-tidy
(C
). Then b.cpp
wants to remove project\.clang-tidy
(C
) as well, but it is already gone! This results in an error.
So this copying (and creating backups) doesn’t play well with parallellism.
And on top of that, I already have a .clang-tidy
file, and I don’t provide explicit checks on the command line. So why is this copying needed at all?
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
Hello-
<strike>OK, I tried to capture a verbose log, but I can no longer reproduce the problem. I tried a few experiments to see if I could get back to a failing case, but I don’t know what has changed.
If you can give me some idea of where that Copy/Remove operation would be active, I can try to reproduce that setup. In all my experiments to try to reproduce this, I no longer see the Copy-Item in the log. </strike>
Edit: Well, spoke too soon. When I switched back to the same Util.cpp file, I can reproduce the problem. This file is at the solution level, not the DX11 project level, because it’s shared with other projects in the solution. It is at the same level as the .clang-tidy file.
Here is the verbose log: clangpower.log
Hi @gerboengels
Apologies for the inconveniences you’ve encountered. This is clearly a bug, the copying mechanism is intended to address only the explicit checks situation, because we’ve encountered issues when a lot of them are passed (the PR you mentioned addressed such an issue). We will fix the bug you’ve encountered as soon as possible and push it to a bugfix release of Clang Power Tools.
Thank you for the helpful feedback.
Regards, Gabriel