[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: What is the correct way to disable -O2?
From: |
Eric Blake |
Subject: |
Re: What is the correct way to disable -O2? |
Date: |
Wed, 23 Jan 2019 12:35:56 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 |
On 1/23/19 12:10 PM, Peng Yu wrote:
> Hi,
>
> I had to use the following command to disable -O2 in the default of
> configure of bash.
>
> http://git.savannah.gnu.org/cgit/bash.git/tree/configure
>
> CFLAGS='' -g -O0" ./configure
That's not the command you used. Maybe you meant:
CFLAGS="-g -O0" ./configure
but in that case, the GNU Coding Standards recommends that you spell it:
./configure CFLAGS="-g -O0"
(although the difference between two forms doesn't really matter to
configure scripts generated by Autoconf, it CAN matter to other
configure scripts that are still compliant with GCS).
>
> But the following command does not disable -O2. I think that -O2
> should be applicable to both C and C++ code, so it should have been
> set to CPPFLAGS as CPPFLAGS is for both C and C++ but CFLAGS is only
> for C.
Rather, CPPFLAGS is for the preprocessor (and affects C and C++ in that
both use the pre-processor), but gets processed prior to CFLAGS on the
command line, and compilers go with the last version set (so if CFLAGS
contains -O2, that overrides any -O0 in CPPFLAGS).
You are correct that setting CFLAGS="-g -O2" at configure time is the
preferred way to disable optimization; but whether it works or not also
depends on whether a particular project properly followed
Autoconf/Automake conventions. Your command line works on other
projects that use both of the autotools; but bash is notorious for using
Autoconf but not Automake; so it could very well be a bug specific to
bash's hand-rolled Makefile.in files for not obeying the GNU Coding
Standards in the same way that Automake would do for you automatically.
But that puts it as a question for automake and/or bash lists, rather
than the autoconf list.
>
> CPPFLAGS='' -g -O0" ./configure
>
> Could anybody let me know what is the standard way to disable -O2? I'd
> like a way that works for many autoconf-based packages besides just
> bash.
>
> Also, the configure file has this. Both -g and -O2 are compile-time
> options. Why are they used for linking? Is this usage correct?
They are more than just compile-time options - the linker needs to know
whether to include debug sections in the resulting binary.
>
> AUTO_LDFLAGS="-g ${GCC+-O2}"
>
The identifier AUTO_LDFLAGS is not present in Autoconf sources; at this
point, any question about its intent should be asked to the bash project
as the place that declared that variable.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature