diff mbox series

meson: set colorout to auto

Message ID 20200825064342.2037-1-kraxel@redhat.com (mailing list archive)
State New, archived
Headers show
Series meson: set colorout to auto | expand

Commit Message

Gerd Hoffmann Aug. 25, 2020, 6:43 a.m. UTC
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 ...

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 meson.build | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Marc-André Lureau Aug. 25, 2020, 6:59 a.m. UTC | #1
Hi

On Tue, Aug 25, 2020 at 10:44 AM Gerd Hoffmann <kraxel@redhat.com> wrote:

> 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 ...
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
>

"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?
Gerd Hoffmann Aug. 25, 2020, 8:06 a.m. UTC | #2
On Tue, Aug 25, 2020 at 10:59:42AM +0400, Marc-André Lureau wrote:
> Hi
> 
> On Tue, Aug 25, 2020 at 10:44 AM Gerd Hoffmann <kraxel@redhat.com> wrote:
> 
> > 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 ...
> >
> > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> >
> 
> "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) ...

> 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).

> 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
Marc-André Lureau Aug. 25, 2020, 8:11 a.m. UTC | #3
Hi

On Tue, Aug 25, 2020 at 12:07 PM Gerd Hoffmann <kraxel@redhat.com> wrote:

> On Tue, Aug 25, 2020 at 10:59:42AM +0400, Marc-André Lureau wrote:
> > Hi
> >
> > On Tue, Aug 25, 2020 at 10:44 AM Gerd Hoffmann <kraxel@redhat.com>
> wrote:
> >
> > > 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 ...
> > >
> > > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> > >
> >
> > "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) ...
>
> > 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).
>
>
Then it looks like you have a legit patch. We can revert it when we switch
back to ninja some day.

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

> 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
>
>
Richard Henderson Aug. 25, 2020, 1:26 p.m. UTC | #4
On 8/24/20 11:43 PM, Gerd Hoffmann wrote:
> 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 ...
> 
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  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~
Gerd Hoffmann Aug. 26, 2020, 5:05 a.m. UTC | #5
On Tue, Aug 25, 2020 at 06:26:33AM -0700, Richard Henderson wrote:
> On 8/24/20 11:43 PM, Gerd Hoffmann wrote:
> > 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 ...
> > 
> > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> > ---
> >  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
Paolo Bonzini Aug. 30, 2020, 9:37 a.m. UTC | #6
On 25/08/20 10:11, Marc-André Lureau wrote:
> 
>     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.
> 
> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com
> <mailto:marcandre.lureau@redhat.com>>
> 

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
diff mbox series

Patch

diff --git a/meson.build b/meson.build
index df5bf728b57a..558e0139768f 100644
--- a/meson.build
+++ b/meson.build
@@ -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)