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
Attachment:
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Autoconf mailing list Autoconf@xxxxxxx https://lists.gnu.org/mailman/listinfo/autoconf