Skip to contentSkip to conversation

meson: set colorout to auto

PATCH In review Gerd Hoffmann 4 participants 7 messages Aug 25, 2020 – Aug 30, 2020 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 meson: set colorout to auto

Dunno why the default is set to "always". IMHO it should be "auto", i.e. only colorize in case stdout goes to a terminal. Cluttering logfiles and confusing compiler message parsers with terminal control sequences is not nice ...

---
 meson.build | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
meson.build +2 -1
index df5bf728b57a..558e0139768f 100644
@@ -1,5 +1,6 @@
 project('qemu', ['c'], meson_version: '>=0.55.0',
-        default_options: ['warning_level=1', 'c_std=gnu99', 'cpp_std=gnu++11', 'b_lundef=false'],
+        default_options: ['warning_level=1', 'c_std=gnu99', 'cpp_std=gnu++11',
+                          'b_lundef=false','b_colorout=auto'],
         version: run_command('head', meson.source_root() / 'VERSION').stdout().strip())
 
 not_found = dependency('', required: false)
Signature · 1 line
2.27.0
#1 lore raw

Hi

Quoted 7 lines · Gerd Hoffmann

Dunno why the default is set to "always". IMHO it should be "auto", i.e. only colorize in case stdout goes to a terminal. Cluttering logfiles and confusing compiler message parsers with terminal control sequences is not nice ...

"Enable colored output with GCC. Ninja redirects stdout/stderr so by default GCC thinks it is not talking to a terminal"

https://github.com/mesonbuild/meson/commit/4f63fe498314c385de2d3b6a3a953d15985914d2

Since we use make, I don't know if it's any better.

Perhaps meson should set compiler/tools colors = always/never based on what it is connected to at configure time instead?

Signature · 1 line
Marc-André Lureau
#2 lore raw
Quoted 9 lines · Marc-André Lureau

Hi

Quoted 5 lines · Gerd Hoffmann

Dunno why the default is set to "always". IMHO it should be "auto", i.e. only colorize in case stdout goes to a terminal. Cluttering logfiles and confusing compiler message parsers with terminal control sequences is not nice ...

Quoted 7 lines
Quoted 2 lines

"Enable colored output with GCC. Ninja redirects stdout/stderr so by default GCC thinks it is not talking to a terminal"

https://github.com/mesonbuild/meson/commit/4f63fe498314c385de2d3b6a3a953d15985914d2

Hmm, maybe ninja handles this then, by stripping the terminal sequences in case stdout isn't a terminal.

With ninja being the default backend the default kind-of makes sense (for meson upstream) ...

Quoted 1 line

Since we use make, I don't know if it's any better.

... but given qemu uses make not ninja we might prefer something else ;)

As far I know make doesn't redirect output. Or maybe it redirects using a pty (instead of a pipe) in case stdout is a terminal. At least auto mode for colored gcc warnings works fine with make. It is colored when started in a terminal, it isn't when started in emacs (and piped through the emacs message parser).

Quoted 2 lines

Perhaps meson should set compiler/tools colors = always/never based on what it is connected to at configure time instead?

Why? Even when running configure in a terminal I might use emacs for builds later on.

take care,
Gerd

Reviewed-by
#3 lore raw

Hi

Quoted 28 lines · Gerd Hoffmann
Quoted 3 lines · Marc-André Lureau

Hi

On Tue, Aug 25, 2020 at 10:44 AM Gerd Hoffmann <[email protected]>

Quoted 6 lines · wrote:
Quoted 6 lines

Dunno why the default is set to "always". IMHO it should be "auto", i.e. only colorize in case stdout goes to a terminal. Cluttering logfiles and confusing compiler message parsers with terminal control sequences is not nice ...

Quoted 7 lines
Quoted 2 lines

"Enable colored output with GCC. Ninja redirects stdout/stderr so by default GCC thinks it is not talking to a terminal"

https://github.com/mesonbuild/meson/commit/4f63fe498314c385de2d3b6a3a953d15985914d2

Hmm, maybe ninja handles this then, by stripping the terminal sequences in case stdout isn't a terminal.

With ninja being the default backend the default kind-of makes sense (for meson upstream) ...

Quoted 1 line

Since we use make, I don't know if it's any better.

Quoted 9 lines

... but given qemu uses make not ninja we might prefer something else ;)

As far I know make doesn't redirect output. Or maybe it redirects using a pty (instead of a pipe) in case stdout is a terminal. At least auto mode for colored gcc warnings works fine with make. It is colored when started in a terminal, it isn't when started in emacs (and piped through the emacs message parser).

Then it looks like you have a legit patch. We can revert it when we switch back to ninja some day.

Quoted 11 lines

Perhaps meson should set compiler/tools colors = always/never based on what

Quoted 1 line

it is connected to at configure time instead?

Why? Even when running configure in a terminal I might use emacs for builds later on.

take care,
Gerd

Signature · 1 line
Marc-André Lureau
#4 lore raw
Quoted 7 lines · Marc-André Lureau

As far I know make doesn't redirect output.  Or maybe it redirects using a pty (instead of a pipe) in case stdout is a terminal.  At least auto mode for colored gcc warnings works fine with make.  It is colored when started in a terminal, it isn't when started in emacs (and piped through the emacs message parser).

Quoted 6 lines

Then it looks like you have a legit patch. We can revert it when we switch back to ninja some day.

<mailto:[email protected]>>

make has the same issue if you use -O/--output-sync. Programs are supposed to check MAKE_TERMOUT and MAKE_TERMERR to decide whether to colorize output, but I think pretty much no one does?

In any case this would not be a new issue, so b_colorout=auto is preferrable.

Paolo

#5 lore raw
In reply to Gerd Hoffmann
Quoted 9 lines · Gerd Hoffmann

Dunno why the default is set to "always". IMHO it should be "auto", i.e. only colorize in case stdout goes to a terminal. Cluttering logfiles and confusing compiler message parsers with terminal control sequences is not nice ...

---
 meson.build | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Yes please. All the color escape codes has broken emacs make next-error.

Although applying this doesn't seem to have helped...

r~

#6 lore raw
Quoted 6 lines · Richard Henderson
Quoted 5 lines · Gerd Hoffmann

Dunno why the default is set to "always". IMHO it should be "auto", i.e. only colorize in case stdout goes to a terminal. Cluttering logfiles and confusing compiler message parsers with terminal control sequences is not nice ...

Quoted 8 lines
Quoted 4 lines
---
 meson.build | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Yes please. All the color escape codes has broken emacs make next-error.

Although applying this doesn't seem to have helped...

meson remembers the state of the options, so running a build alone doesn't help. rm -rf $builddir and starting over will pick up the new default. You can probably also use "meson configure $something".

HTH,
Gerd