This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: GCC Build Defaults to Debug Mode?
- From: Nick <nospam at codesniffer dot com>
- To: Andrew Haley <aph at redhat dot com>, gcc-help <gcc-help at gcc dot gnu dot org>
- Date: Wed, 11 Jan 2017 12:21:57 -0500
- Subject: Re: GCC Build Defaults to Debug Mode?
- Authentication-results: sourceware.org; auth=none
- References: <1484151909.14652.44.camel@nimble.325Bayport> <5e43fffc-9878-ed90-93c4-238ad0aded0a@redhat.com>
On Wed, 2017-01-11 at 16:46 +0000, Andrew Haley wrote:
Thanks for the quick reply & info Andrew.
> > 3. How best to turn it off?
>
> It'd probably be best to strip out the debuginfo into a separate file.
>
> <Run "objcopy --only-keep-debug foo foo.dbg" to>
> create a file containing the debugging info.
>
> <Run "objcopy --strip-debug foo" to create a>
> stripped executable.
>
> <Run "objcopy --add-gnu-debuglink=foo.dbg foo">
> to add a link to the debugging info into the stripped
> executable.
>
Stripping the debug info, while possible, might be tricky because I
don't necessarily know all the files from GCC which get linked into my
app. And while I can try to find them now, I worry that over time
others might get linked in. I don't suppose there's an easy way to
systematically strip it out from all libs that GCC produces (ie. without
necessarily specifying each obj or lib file)?
I tried to build GCC specifying CFLAGS, CXXFLAGS, and CPPFLAGS to either
empty or "-O2" and regardless, "-g" gets added. So I guess GCC is doing
this internally.