cf: Prevent default CFLAGS in OPENAFS_PATH_CC

Commit dba6ec9548 (cf: Set CC before calling AC_PROG_CC) moved our
logic for preventing a default CFLAGS from the top-level
configure.ac/configure-libafs.ac into OPENAFS_CONFIGURE_COMMON. This
doesn't work, because OPENAFS_CONFIGURE_COMMON calls
AC_USE_SYSTEM_EXTENSIONS, which effectively runs the compiler and sets
default CFLAGS at the beginning of OPENAFS_CONFIGURE_COMMON.

This means that if the user doesn't specify any CFLAGS, autoconf will
set our CFLAGS to the default of '-g -O2', which can break various
environments. (For example, --disable-optimize no longer works, because
that flag only controls the OPTMZ var, and doesn't touch CFLAGS.)

To fix this, move our logic for preventing default CFLAGS into
OPENAFS_PATH_CC, which is explicitly called before
OPENAFS_CONFIGURE_COMMON so we can set the compiler before autoconf sets
its defaults. This should ensure that we are setting CFLAGS before
autoconf does; otherwise, we're also probably not setting CC early
enough, either.

Change-Id: Ic64e46aee35ffd3b5ee4ad1241c4c7366d9ccb67
Reviewed-on: https://gerrit.openafs.org/15778
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
This commit is contained in:
Andrew Deason 2024-07-04 12:31:06 -05:00 committed by Michael Meffie
parent af788963a9
commit 20e996af4e
2 changed files with 3 additions and 2 deletions

View File

@ -6,8 +6,6 @@ dnl parameters must be done like $[]1 instead of $1
AC_DEFUN([OPENAFS_CONFIGURE_COMMON],[
dnl If the user hasn't specified CFLAGS don't let configure pick -g -O2
AS_IF([test -z "$CFLAGS"], [CFLAGS=" "])
AC_USE_SYSTEM_EXTENSIONS
AC_PROG_CC

View File

@ -26,6 +26,9 @@ AC_DEFUN([OPENAFS_PATH_CC], [
AC_PROVIDE_IFELSE([AC_PROG_CC],
[AC_FATAL([AC_PROG_CC was called before $0])])
dnl If the user hasn't specified CFLAGS don't let configure pick -g -O2
AS_IF([test -z "$CFLAGS"], [CFLAGS=" "])
AS_CASE([$host],
dnl hp_ux102
[hppa*-hp-hpux10*],