Bug 8605 - No color output from gcc
Summary: No color output from gcc
Status: NEW
Alias: None
Product: ThinLinc
Classification: Unclassified
Component: Build system (show other bugs)
Version: trunk
Hardware: PC Unknown
: P2 Normal
Target Milestone: LowPrio
Assignee: Bugzilla mail exporter
URL:
Keywords:
Depends on: 8361
Blocks:
  Show dependency treegraph
 
Reported: 2025-06-11 16:16 CEST by Pierre Ossman
Modified: 2025-06-17 13:38 CEST (History)
0 users

See Also:
Acceptance Criteria:


Attachments

Description Pierre Ossman cendio 2025-06-11 16:16:45 CEST
When we build things in cenbuild, we generally don't get any color output from gcc on warnings and errors. This makes it much more difficult to find what's relevant in the compiler output.

E.g. in output like this:

> $ cbrun x86_64 gcc -Wall -c -o hello.o hello.c 
> hello.c: In function 'main':
> hello.c:3:9: warning: unused variable 'foobar' [-Wunused-variable]
>      int foobar;

Here, "warning" should be in purple, and a number of relevant key words should be bold.

The issue seems to be ccache. If I bypass it, then it works:

> $ cbrun x86_64 /usr/bin/gcc -Wall -c -o hello.o hello.c 

It also works when I do linking, which I assume ccache ignores:

> $ cbrun x86_64 gcc -Wall -o hello.o hello.c 

Lastly, it also works when I set GCC_COLORS for some reason:

> $ GCC_COLORS=foo cbrun x86_64 gcc -Wall -c -o hello.o hello.c
Comment 1 Pierre Ossman cendio 2025-06-11 16:18:47 CEST
We run a rather old ccache. A newer version would require a newer gcc, according to bug 7827.

However, we are upgrading gcc in bug 8361. I tried the latest ccache using that new compiler, and the issue seems to be gone.
Comment 2 Pierre Ossman cendio 2025-06-16 17:03:13 CEST
Apparently, that's only part of the problem. "make -O" from bug 7838 also causes gcc to omit colors. This seems to be a well known issue, with hacky workarounds suggested:

https://whatofhow.wordpress.com/2014/04/03/gnu-make-4-output-sync/

Ninja also documents this problem:

https://github.com/ninja-build/ninja/wiki/FAQ#why-does-my-program-with-colored-output-not-have-color-under-ninja

But at the same time, I'm sometimes getting color even with the -O flag. Something odd is going on here.

Note You need to log in before you can comment on or make changes to this bug.