dotnet / dotnet/msbuild

MSBuild does not log "fatal" error messages from Clang as MSbuild errors

Open
#10,910 5 comments 0 reactions 0 assignees View on GitHub
gathering-feedback triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

### 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](https://github.com/user-attachments/files/17572997/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
| ^~~~~~~~~~~~~~
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**

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.