Skip to contentSkip to conversation

configure: Fix default -O2 being added when CFLAGS not set

PATCH In review Glenn Washburn 3 participants 3 messages Apr 9, 2022 – Apr 14, 2022

lore
Share & tools
lore
#0 lore raw

PATCH v3 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. A recent commit ad9ccf660013c208077b1e983d6c824df25ed1cf ("configure: Fix various new autotools warnings") added AC_USE_SYSTEM_EXTENSIONS, which pulls in the autoconf CFLAGS check, before we default CFLAGS and thus setting the autoconf default for CFLAGS. Move the default setting of CFLAGS to before AC_USE_SYSTEM_EXTENSIONS so that autoconf will see CFLAGS as set and not give it a default.

CFLAGS is also moved above AC_CONFIG_AUX_DIR, because CFLAGS should be defaulted to "" as soon as possible to catch any autoconf macros that try to use some other default. Regardless, this currently has no effect as that macro does not consider the CFLAGS variable.

---
 configure.ac | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
configure.ac +3 -3
index 94653039c1..57fb709451 100644
@@ -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.25.1
Reviewed-by on v3 1/1
#1 lore raw
Quoted 9 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. A recent commit ad9ccf660013c208077b1e983d6c824df25ed1cf ("configure: Fix various new autotools warnings") added AC_USE_SYSTEM_EXTENSIONS, which pulls in the autoconf CFLAGS check, before we default CFLAGS and thus setting the autoconf default for CFLAGS. Move the default setting of CFLAGS to before AC_USE_SYSTEM_EXTENSIONS so that autoconf will see CFLAGS as set and not give it a default.

Quoted 6 lines

CFLAGS is also moved above AC_CONFIG_AUX_DIR, because CFLAGS should be defaulted to "" as soon as possible to catch any autoconf macros that try to use some other default. Regardless, this currently has no effect as that macro does not consider the CFLAGS variable.

Be well,
--Robbie

Reviewed-by
#2 lore raw
Quoted 11 lines · Robbie Harwood
Quoted 9 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. A recent commit ad9ccf660013c208077b1e983d6c824df25ed1cf ("configure: Fix various new autotools warnings") added AC_USE_SYSTEM_EXTENSIONS, which pulls in the autoconf CFLAGS check, before we default CFLAGS and thus setting the autoconf default for CFLAGS. Move the default setting of CFLAGS to before AC_USE_SYSTEM_EXTENSIONS so that autoconf will see CFLAGS as set and not give it a default.

Quoted 8 lines
Quoted 6 lines

CFLAGS is also moved above AC_CONFIG_AUX_DIR, because CFLAGS should be defaulted to "" as soon as possible to catch any autoconf macros that try to use some other default. Regardless, this currently has no effect as that macro does not consider the CFLAGS variable.

Daniel