FS#69662 - [clang] Coloring diagnostics does not always work

Attached to Project: Arch Linux
Opened by Krzysztof Małysa (varqox) - Tuesday, 16 February 2021, 16:45 GMT
Last edited by Evangelos Foutras (foutrelis) - Wednesday, 17 February 2021, 11:40 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Evangelos Foutras (foutrelis)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:

Arch clang does not color diagnostics, while the upstream clang does when using flags `-Xclang -fcolor-diagnostics -c` and redirecting stderr through a pipe. The expected behavior of clang is to color the diagnostics regardless of the fact that stderr is not some tty.

However, if I remove `-Xclang` or `-c` it works i.e. both `clang++ -fcolor-diagnostics -c foo.cc 2>&1 | cat` and `clang++ -Xclang -fcolor-diagnostics foo.cc 2>&1 | cat` give colored output.

I cannot reproduce this behavior using the official clang build: https://github.com/llvm/llvm-project/releases/download/llvmorg-11.0.1/clang+llvm-11.0.1-x86_64-linux-gnu-ubuntu-20.10.tar.xz

Additional info:
* package version: 11.0.1-1

Steps to reproduce:

1. Create file `foo.cc` with below content:
```
int main() {
return "";
}
```
2. Run: `clang++ -Xclang -fcolor-diagnostics -c foo.cc 2>&1 | cat`
This task depends upon

Closed by  Evangelos Foutras (foutrelis)
Wednesday, 17 February 2021, 11:40 GMT
Reason for closing:  Upstream
Additional comments about closing:  Tracked upstream in ccache.
Comment by Evangelos Foutras (foutrelis) - Wednesday, 17 February 2021, 07:07 GMT
Seems to be an interaction with ccache; `/usr/bin/clang++` instead of `clang++` (which is actually /usr/lib/ccache/bin/clang++) will have consistent colored diagnostics.
Comment by Krzysztof Małysa (varqox) - Wednesday, 17 February 2021, 11:33 GMT
Oh, I forgot about ccache. Thanks for pointing this out, as this is a ccache bug indeed.
I reported this bug upstream: https://github.com/ccache/ccache/issues/801

Loading...