-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
MSBuild does not log "fatal" error messages from Clang as MSbuild errors #10910
Comments
The canonical error format is specifically for MSBuild errors and is provided as a convenience. If a tool wants to accurately report errors from the Exec task, it should use the available knobs (like CustomErrorRegularExpression, CustomWarningRegularExpression, IgnoreStandardErrorWarningFormat from the docs) to massage the output into MSBuild's model. We cannot ship knowledge of every possible tool that can be invoked via Exec. |
"We cannot ship knowledge of every possible tool that can be invoked via Exec." While I agree that this is a completely fair statement in general, MSBuild already has built in custom support specifically for the error/warning formats of Clang and GCC as evidenced by the "s_originCategoryCodeTextExpression2" regex in CanonicalError and also specific unittests for Clang and GCC messages so to me it would make sense to have complete support also for the "fatal" form. |
This is a strong point - I didn't realize we already had some level of compatibility for these error types specifically. If we can add support for detecting "fatal error" then that seems reasonable - though I think it would only be "error" level severity in MSBuild still. |
I wish we didn't have that in there. Looks like it went in in the first mono-support commit. Despite it being there I'm a bit concerned about extending the regex, since that could theoretically take passing builds to failing. Do we know if these compilers reliably return a failure code after emitting a |
FYI. In VC, the clang task has a custom error parser. |
Issue Description
For certain classes of errors (like missing files) the Clang compiler logs a "fatal" error, ex)
fatal.c:1:10: fatal error: 'nosuchfile.h' file not found
When run through MSBuild, using for example the Exec task this error message is not logged as an error through the MSbuild log system and is instead logged as normal text output, most likely because the word "fatal" breaks the detection of canonical errors.
Steps to Reproduce
fatal.zip
With the LLVM toolset support installed for Visual Studio and running from a Visual Studio developer prompt:
To reproduce an example of a fatal error message:
clang.exe fatal.c
fatal.c:1:10: fatal error: 'nosuchfile.h' file not found
1 | #include <nosuchfile.h>
| ^~~~~~~~~~~~~~
1 error generated.
To reproduce the behaviour from MSBuild:
MSbuild fatal.proj
Expected Behavior
MSBuild should detect the message from Clang as an error and log an MSBuild error message along the lines of:
fatal.c(1,10): error ABCDEF: nosuchfile.h: No such file or directory [fatal.proj]
Actual Behavior
The output from Clang is logged as normal message instead of an error
Analysis
The regexes in src\Shared\CanonicalError.cs does not account for the extra word "fatal" in these kind of error messages and therefore fails to detect them as actual errors
Versions & Configurations
msbuild -version
MSBuild version 17.9.8+b34f75857 for .NET Framework
17.9.8.16306
clang -v
clang version 17.0.3
Target: i686-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\Llvm\bin
The text was updated successfully, but these errors were encountered: