Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 07 Aug 2013 10:57:33 +0300
From:      Andriy Gapon <avg@FreeBSD.org>
To:        Jilles Tjoelker <jilles@stack.nl>
Cc:        freebsd-arch@FreeBSD.org
Subject:   Re: amd64: -O2 even with DEBUG
Message-ID:  <5201FDED.8000408@FreeBSD.org>
In-Reply-To: <20130804202823.GB39246@stack.nl>
References:  <51F221D4.8040308@FreeBSD.org> <20130726185425.GS26412@funkthat.com> <51F37578.2080405@FreeBSD.org> <20130804202823.GB39246@stack.nl>

next in thread | previous in thread | raw e-mail | index | archive | help
on 04/08/2013 23:28 Jilles Tjoelker said the following:
> On the other hand, the difference between DEBUG and !DEBUG should be
> minimized to avoid heisenbugs and taking advantage of undefined
> behaviour that does not work at -O2.

This does make sense.  But shouldn't all architectures be equal in this respect?

> Also note that most standard kernel configuration files have the line
> 
> makeoptions	DEBUG=-g	# Build kernel with gdb(1) debug symbols
> 
> which suggests that it only adds debug symbols and does not lower the
> optimization level (even though that is only the case on amd64).

Exactly -- this is only the case on amd64, for all other architectures DEBUG
implies -O.

> So it seems you are asking about lowering the optimization level of
> almost all amd64 kernels (there seems little reason not to generate
> .symbols files).

No, I am just asking for consistency.

That is, if amd64 is so special among all the platforms and flavors then let
this be explicitly stated somewhere.  If not, then let it follow what all other
architectures do.  Or, conversely, all other architectures should do what amd64
does.

> In my experience, debugging -O2 code is usually possible with
> experience, knowledge about compiler optimizations and good compilers
> and debuggers (for example, gcc and gdb were improved in this area after
> the switch to GPLv3). It can be rather annoying, though, if there is a
> lot of inlining or the value of the variable you need is not available
> (the value may be available elsewhere in the call chain or not at all).

All true.  Especially kgdb-over-{email,irc} becomes annoyingly hard.

-- 
Andriy Gapon



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5201FDED.8000408>