Caphyon / clang-power-tools

Bringing clang-tidy magic to Visual Studio C++ developers.
http://www.clangpowertools.com
Apache License 2.0
472 stars 57 forks source link

PCH regression at 23.1.2 #1286

Open pasa- opened 1 year ago

pasa- commented 1 year ago

At 23.1.1 my build still worked. Then PCH gets broken.

My projects controls this through $(Pch). and in my .props I have

Use $(Pch) %(ForcedIncludeFiles);$(Pch)

up to 23.1.1 it worked suboptimally, creating the pch not from the intended file in the but the first entry in %(ForcedIncludeFiles), but then passed both entries as forced and the build went okay.

VERBOSE: Force includes: VERBOSE: C:\work\fd\2200\src\include\stru_forced.h VERBOSE: fdcad_common.h

VERBOSE: PCH cpp name: C:\work\fd\2200\src\pch.cpp VERBOSE: PCH header name: C:\work\fd\2200\src\include\stru_forced.h VERBOSE: No PCH information for this project! VERBOSE: Processing 1 cpps on invoke -Wno-microsoft-include -include C:\work\fd\2200\src\include\stru_forced.h -include fdcad_common.h

after patch: VERBOSE: Force includes: VERBOSE: C:\work\fd\2200\src\include\stru_forced.h VERBOSE: fdcad_common.h VERBOSE: PCH cpp name: C:\work\fd\2200\src\pch.cpp VERBOSE: PCH header name: C:\work\fd\2200\src\include\stru_forced.h VERBOSE: No PCH information for this project! VERBOSE: Processing 1 cpps on invoke -Wno-microsoft-include -include "C:\work\fd\2200\src\include\stru_forced.h"


If I modify the props to have only one entry

$(Pch)

then the old gets better: VERBOSE: Force includes: VERBOSE: fdcad_common.h VERBOSE: PCH cpp name: C:\work\fd\2200\src\pch.cpp VERBOSE: PCH header name: fdcad_common.h VERBOSE: PCH directory: C:\work\fd\2200\src\INCLUDE\ VERBOSE: PCH is disabled for this project. Will not generate. VERBOSE: Processing 1 cpps

-Wno-microsoft-include -include fdcad_common.h

and after patch: VERBOSE: Force includes: VERBOSE: fdcad_common.h VERBOSE: PCH cpp name: C:\work\fd\2200\src\pch.cpp VERBOSE: PCH header name: fdcad_common.h VERBOSE: PCH directory: C:\work\fd\2200\src\INCLUDE\ VERBOSE: PCH is disabled for this project. Will not generate. VERBOSE: Processing 1 cpps

After the change same verbose lines but invoke has no -include fdcad_common.h at all and -Wno-microsoft-include also missing.

If compiling the project instead of single file, then VERBOSE: PCH cpp name: C:\work\fd\2200\src\pch.cpp VERBOSE: PCH header name: fdcad_common.h VERBOSE: PCH directory: C:\work\fd\2200\src\INCLUDE\ VERBOSE: Processing 25 cpps VERBOSE: Generating PCH... VERBOSE: INVOKE: C:\Users\baloghp\AppData\Roaming\ClangPowerTools\LLVM\LLVM16.0.0\bin\clang++.exe "C:\work\fd\2200\src\INCLUDE\fdcad_common.h.hpp" -o "C:\work\fd\2200\src\cs2dsk.clang.pch" -x c++ -std=c++2b -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-c++20-compat -Wno-reserved-id-macro -Wno-language-extension-token -Wno-old-style-cast -Wno-unused-parameter -Wno-zero-as-null-pointer-constant -Wno-gnu-zero-variadic-macro-arguments -Wno-extra-semi -Wno-shadow-field-in-constructor -Wno-exit-time-destructors -Wno-global-constructors -Wno-switch-enum -Wno-double-promotion -Wno-nonportable-system-include-path -Wno-documentation-unknown-command -Wno-covered-switch-default -Wno-gnu-anonymous-struct -Wno-nested-anon-types -Wno-cast-align -Wno-sign-compare -Wall -fms-compatibility -Wmicrosoft -Winvalid-token-paste -Wno-unknown-pragmas -Wunused-variable -Wunused-value -Wno-missing-braces -Wno-deprecated-declarations -Wno-switch -Wno-dangling-else -Wmissing-field-initializers -Wnonportable-include-path -Wno-microsoft-enum-value -Winvalid-source-encoding -Wno-microsoft-template -Wconversion -Wno-sign-conversion -Wunused-local-typedef -Wimplicit-fallthrough -Wunused-macros -Wmissing-variable-declarations -Wmissing-prototypes -Wshadow -Wshadow-uncaptured-local -Wno-float-equal -Wno-conversion -Wno-duplicate-enum -Wno-shadow -Wno-shadow-field -Wno-ctad-maybe-unsupported -Wno-deprecated-anon-enum-enum-conversion -Wno-reserved-identifier -Wno-cast-function-type -Wno-invalid-utf8 -Wno-unqualified-std-cast-call -Wno-unsafe-buffer-usage -Wno-unused-command-line-argument "-D_MT" "-D_DLL" "-D_AFXDLL" "-DDLLNAME=FDCADKERNEL" "-DFDCADKERNEL_EXPORTS" "-DCS2DSK_EXPORTS" "-D_WINDLL" "-D_AFXDLL" "-D_AFXEXT" "-DFP_EXCEPTIONS_ON=1" "-DWIN32" "-D_WINDOWS" "-DWINVER=0x0601" "-D_WIN32_WINNT=0x0601" "-DPROJ_NAME=CS2DSK" "-D_DEBUG" "-DNO_GDIPLUS_SHUTDOWN" "-D_DEBUG_FUNCTIONAL_MACHINERY" -fpch-instantiate-templates -isystem"C:\work\fd\2200\src\INCLUDE" -isystem"C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include" -isystem"C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\atlmfc\include" -isystem"C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Auxiliary\VS\include" -isystem"C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\ucrt" -isystem"C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\um" -isystem"C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\shared" -isystem"C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\winrt" -isystem"C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\cppwinrt" -isystem"C:\Program Files (x86)\Microsoft DirectX SDK (November 2008)\Include" -I"C:\work\fd\2200\src\INCLUDE" -I"C:\work\fd\2200\src" -I"C:\work\fd\2200\src..\EX_INCLUDE" VERBOSE: PCH: C:\work\fd\2200\src\cs2dsk.clang.pch

formally generates it, but I guess it will come empty, as the cpp has no lines and would gain them through the forced .h at the end it is cleaned up VERBOSE: Cleaning up PCH temporaries: VERBOSE: C:\work\fd\2200\src\INCLUDE\fdcad_common.h.hpp VERBOSE: C:\work\fd\2200\src\cs2dsk.clang.pch

in the invocations I see no reference of passing the pch to use, I don't know if that requires anything or not.

At the top of master the picture is even more interesting, after a recent patch the pch is generated even for the single file (alt-U) compilation, the check uses the projects' file count of 25 matched against the 2 minimum and sets it true. it's cleaned up -- and but doesn't work in similar way as before, missing the forced inc.

hero101111 commented 1 year ago

Hi @pasa-

Thank you for providing us with the detailed info about this issue, it's been of help to us. We've just pushed a fix and the issue should no longer appear. Please test our fix by updating the CPT PowerShell engine scripts from the CPT Settings and let us know if your build is fixed. image

Regards, Gabriel

pasa- commented 1 year ago

-- unrelated --> this update feature does not work on my box, I get an alert with "Access to the path denied" followed by "PowerSell scripts were updated to latest version", while in fact it just deleted everything in the Tooling folder and left it empty. During the last half-or-one year I had some problems already when the script tried to download something and failed with some cryptic error that I was fixing by using the failed dl url in browser and copy the file where needed. Was lazy to report it, might be from some odd network policy not allowing the connection from the script... For the button I suggest to check the error state correctly, dl to tmp location and move only on success so it does not brick the extension on a random network error....

I used the files from this repo at f7a0d1c6a1d74a2e6b1f1cd6c16432a7e4d77df7 copying the tooling folder to where it is installed. The problem of making PCH for single file is now fixed -- generation happens as expected.

My build shows the same symptoms as reported above, unchanged. I tried some additional tweaks to my .props file resulting it generating the PCH from the header I want. But then still I see no attempts in the INVOKE line to actually pass the generated pch for use. And for the solo compile the forced include line is still missing. From the last delta it's not really surprising, as that part does not look changed.

My build is successful if I revert the change at line 1537

                                           -forceIncludeFiles       $cppForceIncludes `

-> -forceIncludeFiles $forceIncludeFiles `

I don't see any condition connected to it, and it's a sure mistake to strip when PCH is not created for any reason.
When it is created, if the idea of the strip is that the content will arrive from the pch -- then the problem is likely that the pch is not actually picked up by the compiler. I have no clue how clang works for this, from superficial look at the dox I'd expect it to appear in the invoke line before the source and it isn't.

mariru27 commented 1 year ago

Hi @pasa-,

We fix the Update Script issue in Clang Power Tools release v2023.6.0

Can you try Update Script again?

Regards, Marina

pasa- commented 1 year ago

Much better than it was. :) The error messages are still be inconsistent: in the end it always reports that all the scripts were updated successfully, despite previously reported error might made it impossible. I.e dropping a readonly file in the folder gets a message, and the update then happens fine. But if the script itself is made readonly/locked or the dir, then it is not updated.

The network error does not occour here at this time, so could not test what happens, but that part of code change looks fine.

mariru27 commented 1 year ago

Hi @pasa-,

Thank you for your feedback We will change the error message to not mislead our users

Kind regards, Marina