configure: Fix default -O2 being added when CFLAGS not set
PATCH 1/1 configure: Fix default -O2 being added when CFLAGS not set
Autoconf will set a default CFLAGS of "-g -O2" if CFLAGS is not set. CFLAGS was defaulted to "" early in configure to prevent this. Apparently something changed in autoconf and now AC_USE_SYSTEM_EXTENSIONS, which is before the default setting of CFLAGS, will pull in this check. Move the default setting of CFLAGS to before this so that if will see CFLAGS as set and not give it a default.
--- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
configure.ac +3 -3
@@ -36,12 +36,12 @@ dnl description of the relationships between them. AC_INIT([GRUB],[2.11],[[email protected]]) -AC_USE_SYSTEM_EXTENSIONS -AC_CONFIG_AUX_DIR([build-aux]) - # We don't want -g -O2 by default in CFLAGS : ${CFLAGS=""} +AC_USE_SYSTEM_EXTENSIONS +AC_CONFIG_AUX_DIR([build-aux]) + # Checks for build, host and target systems. AC_CANONICAL_BUILD AC_CANONICAL_HOST
Signature · 1 line
2.27.0
Dear Glenn,
Thank you for your tireless awesome work on GRUB.
Am 24.03.22 um 23:31 schrieb Glenn Washburn:
Quoted 6 lines
Autoconf will set a default CFLAGS of "-g -O2" if CFLAGS is not set. CFLAGS was defaulted to "" early in configure to prevent this. Apparently something changed in autoconf and now
AC_USE_SYSTEM_EXTENSIONS, which is before the default setting of CFLAGS, will pull in this check. Move the default setting of CFLAGS to before this so that if will see CFLAGS as set and not give it a default.
Could you please mention the Autoconf version you use? I guess, it’d be great to know, when this behavior started, so to make sure, that the last X years all the tests were done like this, and reverting the behavior would actually break things (though shouldn’t).
With Debian sid/unstable and GNU Autoconf 2.71 I can reproduce your behavior:
$ grep '^CFLAGS=' config.log
CFLAGS='-g -O2'Quoted 15 lines
Signed-off-by Glenn Washburn <[email protected]>--- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)configure.ac +0
-2@@ -36,12 +36,12 @@ dnl description of the relationships between them. AC_INIT([GRUB],[2.11],[[email protected]]) -AC_USE_SYSTEM_EXTENSIONS -AC_CONFIG_AUX_DIR([build-aux])
configure.ac dnl description of the relationships between them. · line 47
Quoted 10 lines
configure.ac +3
-1- # We don't want -g -O2 by default in CFLAGS : ${CFLAGS=""} +AC_USE_SYSTEM_EXTENSIONS +AC_CONFIG_AUX_DIR([build-aux]) + # Checks for build, host and target systems. AC_CANONICAL_BUILD AC_CANONICAL_HOST
$ git am … && ./autogen.sh && ./configure --with-platform=coreboot
$ grep '^CFLAGS=' config.log
CFLAGS=''Kind regards,
Paul
Quoted 6 lines · Glenn Washburn
Autoconf will set a default CFLAGS of "-g -O2" if CFLAGS is not set. CFLAGS was defaulted to "" early in configure to prevent this. Apparently something changed in autoconf and now
AC_USE_SYSTEM_EXTENSIONS, which is before the default setting of CFLAGS, will pull in this check. Move the default setting of CFLAGS to before this so that if will see CFLAGS as set and not give it a default.
This is a result of ad9ccf660013c208077b1e983d6c824df25ed1cf ("configure: Fix various new autotools warnings"), which hoisted AC_USE_SYSTEM_EXTENSIONS to avoid a new warning (slightly too far, it seems).
Quoted 1 line
Signed-off-by Glenn Washburn <[email protected]>
Be well,
--Robbie
Quoted 9 lines · On Fri, 25 Mar 2022 11:54:59 -0400 Robbie Harwood <[email protected]> wrote:
Quoted 6 lines · Glenn Washburn
Autoconf will set a default CFLAGS of "-g -O2" if CFLAGS is not set. CFLAGS was defaulted to "" early in configure to prevent this. Apparently something changed in autoconf and now
AC_USE_SYSTEM_EXTENSIONS, which is before the default setting of CFLAGS, will pull in this check. Move the default setting of CFLAGS to before this so that if will see CFLAGS as set and not give it a default.
Quoted 4 lines
This is a result of
ad9ccf660013c208077b1e983d6c824df25ed1cf("configure: Fix various new autotools warnings"), which hoistedAC_USE_SYSTEM_EXTENSIONSto avoid a new warning (slightly too far, it seems).
I neglected to check the commit log, which hints at the fact that this isn't an issue in autoconf. Thanks for pointing this out, I'll update the commit message with this info to more accurately reflect what's going on.
Glenn
Quoted 6 lines
Quoted 1 line
Signed-off-by Glenn Washburn <[email protected]>Reviewed-by Robbie Harwood <[email protected]>Be well,
--Robbie
Hi Paul,
Quoted 4 lines · On Fri, 25 Mar 2022 07:53:29 +0100 Paul Menzel <[email protected]> wrote:
Dear Glenn,
Thank you for your tireless awesome work on GRUB.
Sincerely, thank you. It seems to me that you're also deserving of this compliment and probably more so.
Quoted 8 lines
Am 24.03.22 um 23:31 schrieb Glenn Washburn:
Quoted 6 lines
Autoconf will set a default CFLAGS of "-g -O2" if CFLAGS is not set. CFLAGS was defaulted to "" early in configure to prevent this. Apparently something changed in autoconf and now
AC_USE_SYSTEM_EXTENSIONS, which is before the default setting of CFLAGS, will pull in this check. Move the default setting of CFLAGS to before this so that if will see CFLAGS as set and not give it a default.
Quoted 4 lines
Could you please mention the Autoconf version you use? I guess, it’d be great to know, when this behavior started, so to make sure, that the last X years all the tests were done like this, and reverting the behavior would actually break things (though shouldn’t).
I'm generally testing on Debian 11 and have an autoconf version of 2.69. However, I was wrong in the commit message as Robbie pointed out. The issue wasn't from a change in autoconf, but in a very recent change in GRUB's usage of autoconf. So this shouldn't have affected any previous testing.
Quoted 25 lines
With Debian sid/unstable and GNU Autoconf 2.71 I can reproduce your behavior:
$ grep '^CFLAGS=' config.log CFLAGS='-g -O2'Quoted 19 lines
Signed-off-by Glenn Washburn <[email protected]>--- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)configure.ac +0
-3@@ -36,12 +36,12 @@ dnl description of the relationships between them. AC_INIT([GRUB],[2.11],[[email protected]]) -AC_USE_SYSTEM_EXTENSIONS -AC_CONFIG_AUX_DIR([build-aux]) - # We don't want -g -O2 by default in CFLAGS : ${CFLAGS=""}
Quoted 8 lines
configure.ac dnl description of the relationships between them. · line 47
Quoted 6 lines
configure.ac +3
-0+AC_USE_SYSTEM_EXTENSIONS +AC_CONFIG_AUX_DIR([build-aux]) + # Checks for build, host and target systems. AC_CANONICAL_BUILD AC_CANONICAL_HOSTTested-by Paul Menzel <[email protected]>
Thank you for testing this.
Glenn
Quoted 9 lines
$ git am … && ./autogen.sh && ./configure --with-platform=coreboot $ grep '^CFLAGS=' config.log CFLAGS=''Kind regards,
Paul