Skip to content
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

Add colored diagnostics support for GCC (>=4.9) #814

Closed
bchretien opened this issue Sep 16, 2014 · 3 comments
Closed

Add colored diagnostics support for GCC (>=4.9) #814

bchretien opened this issue Sep 16, 2014 · 3 comments

Comments

@bchretien
Copy link

This is something that was made possible with clang (cf. #297), and since GCC finally provides color support (since 4.9), this may be worth supporting as well.

@bchretien
Copy link
Author

Actually, I missed an issue that said that this option needs to be forced with -fcolor-diagnostics (for clang). For GCC:

Support for colorizing diagnostics emitted by GCC has been added. The -fdiagnostics-color=auto will enable it when outputting to terminals, -fdiagnostics-color=always unconditionally. The GCC_COLORS environment variable can be used to customize the colors or disable coloring. If GCC_COLORS variable is present in the environment, the default is -fdiagnostics-color=auto, otherwise -fdiagnostics-color=never.

This only works with ninja if I add -fdiagnostics-color=always, even though GCC_COLORS is set, so I guess the problem is the same (with simply a slightly different compiler flag).

@evmar
Copy link
Collaborator

evmar commented Sep 17, 2014

As mentioned there, Ninja knows to strip shell escapes when used via a pipe. It's kind of subtle, I know, but we don't have any better solution... :\

@evmar evmar closed this as completed Sep 17, 2014
kdesysadmin pushed a commit to KDE/extra-cmake-modules that referenced this issue Dec 29, 2016
Summary:
Colored compiler warnings in ninja output only work with the
`-fdiagnostics-color=always` flag.
See ninja-build/ninja#814 for a rationale.

This commit adds such flag in ecm for gcc >= 4.9 and clang >= 3.5,
and only if the CMAKE_GENERATOR is Ninja.

Test Plan: ninja+gcc and ninja+clang now show nice colored compiler warnings.

Reviewers: #frameworks

Differential Revision: https://phabricator.kde.org/D3733
luis-pereira added a commit to lxqt/lxqt-build-tools that referenced this issue Jan 26, 2017
luis-pereira added a commit to lxqt/lxqt-build-tools that referenced this issue Feb 3, 2017
iphydf added a commit to iphydf/c-toxcore that referenced this issue Aug 19, 2018
iphydf added a commit to iphydf/c-toxcore that referenced this issue Aug 21, 2018
@byron-hawkins
Copy link

As mentioned there, Ninja knows to strip shell escapes when used via a pipe. It's kind of subtle, I know, but we don't have any better solution... :\

The solution used by GCC for years is a better solution than what ninja does (always stripping shell escapes for pipes). Please add a standard 3-way color option: { never, auto, always }, where the current behavior corresponds to auto.

Diagnostics are very difficult to read, particulary where C++ templates are involved. Color is fairly essential. If it is not possible to add this option, can you give me a general idea how I can modify my own ninja instance to support this feature?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants