From cf8c3c9cfe767a767a7237c34075e69cdfd16f64 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Thu, 4 Jun 2015 08:00:54 -0600 Subject: [PATCH] adjust auto-configuration of CPPFLAGS vs. CFLAGS When AC_PROG_CC picks GCC, move its selection of CFLAGS into CPPFLAGS, so that preprocessing will have the same optimization and debugging flags as compilation. Arguably, AC_PROG_CC plus AC_PROG_CPP should do that soemhow, but it's understandable that the autoconf implementers didn't cover the possibility of preprocessing that changes with the optimization level. Closes #945 --- racket/src/configure | 21 +++++++++++++++++++++ racket/src/racket/configure.ac | 23 ++++++++++++++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/racket/src/configure b/racket/src/configure index 6d95e527d4..63bd11a103 100755 --- a/racket/src/configure +++ b/racket/src/configure @@ -3268,7 +3268,16 @@ if test "${enable_ios}" != "" ; then SUB_CONFIGURE_EXTRAS="${SUB_CONFIGURE_EXTRAS} LDFLAGS="'"'"${LDFLAGS}"'"' fi + if test "${enable_oskit}" = "no" ; then + # Auto-set CC, CPP, etc. + + if test "${CFLAGS}${CC}${CPP}" = "" ; then + starts_out_default=yes + else + starts_out_default=no + fi + ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -4195,6 +4204,18 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu + + if test "$starts_out_default" = "yes" ; then + if test "$GCC" = "yes" ; then + # Auto selection of C compiler picked GCC, so we + # assume it also picked the GNU preprocessor; move + # auto-picked CFLAGS to PREFLAGS so that compilation + # and preprocessing are in sync (e.g., for optimization flags) + PREFLAGS="${CFLAGS} ${PREFLAGS}" + CPPFLAGS="${CFLAGS} ${CPPFLAGS}" + CFLAGS="" + fi + fi if test "$AS" = '' ; then AS="${ac_tool_prefix}as" as_was_set=no diff --git a/racket/src/racket/configure.ac b/racket/src/racket/configure.ac index 48766f53d7..f7f19853a9 100644 --- a/racket/src/racket/configure.ac +++ b/racket/src/racket/configure.ac @@ -539,10 +539,31 @@ if test "${enable_ios}" != "" ; then SUB_CONFIGURE_EXTRAS="${SUB_CONFIGURE_EXTRAS} CPPFLAGS="'"'"${PREFLAGS}"'"' SUB_CONFIGURE_EXTRAS="${SUB_CONFIGURE_EXTRAS} LDFLAGS="'"'"${LDFLAGS}"'"' fi - + + if test "${enable_oskit}" = "no" ; then + # Auto-set CC, CPP, etc. + + if test "${CFLAGS}${CC}${CPP}" = "" ; then + starts_out_default=yes + else + starts_out_default=no + fi + AC_PROG_CC AC_PROG_CPP + + if test "$starts_out_default" = "yes" ; then + if test "$GCC" = "yes" ; then + # Auto selection of C compiler picked GCC, so we + # assume it also picked the GNU preprocessor; move + # auto-picked CFLAGS to PREFLAGS so that compilation + # and preprocessing are in sync (e.g., for optimization flags) + PREFLAGS="${CFLAGS} ${PREFLAGS}" + CPPFLAGS="${CFLAGS} ${CPPFLAGS}" + CFLAGS="" + fi + fi if test "$AS" = '' ; then AS="${ac_tool_prefix}as" as_was_set=no