emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r108250: Try to fix building with gcc


From: Glenn Morris
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r108250: Try to fix building with gcc >= 4.6 on Darwin.
Date: Tue, 15 May 2012 23:15:52 -0700
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 108250
fixes bug(s): http://debbugs.gnu.org/9755
committer: Glenn Morris <address@hidden>
branch nick: trunk
timestamp: Tue 2012-05-15 23:15:52 -0700
message:
  Try to fix building with gcc >= 4.6 on Darwin.
  Eg, hydra builds have been failing for some time because (?) of this.
  In gcc < 4.6, unrecognized -no-fo options just cause a warning.
  In 4.6 and later, they cause an error.
  
  * configure.in: (CPP): Do not unconditionally set it on Darwin.
  Instead, try to test if -no-cpp-precomp is accepted.
  (CPP_TEST_OPTIONS, SPECIFIED_CPP): New.
modified:
  ChangeLog
  configure.in
=== modified file 'ChangeLog'
--- a/ChangeLog 2012-05-15 19:13:17 +0000
+++ b/ChangeLog 2012-05-16 06:15:52 +0000
@@ -1,3 +1,10 @@
+2012-05-16  Glenn Morris  <address@hidden>
+
+       * configure.in: Try to fix building with gcc >= 4.6 on Darwin.
+       (CPP): Do not unconditionally set it on Darwin.
+       Instead, try to test if -no-cpp-precomp is accepted.
+       (CPP_TEST_OPTIONS, SPECIFIED_CPP): New.  (Bug#9755)
+
 2012-05-15  Glenn Morris  <address@hidden>
 
        * Makefile.in (install-arch-dep): Replace use of MV_DIRS.

=== modified file 'configure.in'
--- a/configure.in      2012-05-12 18:10:37 +0000
+++ b/configure.in      2012-05-16 06:15:52 +0000
@@ -492,12 +492,11 @@
       * )            unported=yes ;;
     esac
     opsys=darwin
-    # Define CPP as follows to make autoconf work correctly.
-    CPP="${CC-cc} -E -no-cpp-precomp"
     # Use fink packages if available.
+    # FIXME?  Is it really our business to decide this for the user?
     if test -d /sw/include && test -d /sw/lib; then
       GCC_TEST_OPTIONS="-I/sw/include -L/sw/lib"
-      CPP="${CPP} ${GCC_TEST_OPTIONS}"
+      CPP_TEST_OPTIONS=${GCC_TEST_OPTIONS}
       NON_GCC_TEST_OPTIONS=${GCC_TEST_OPTIONS}
     fi
   ;;
@@ -581,9 +580,7 @@
     machine=intel386
     case "${canonical}" in
       *-cygwin )                opsys=cygwin ;;
-      *-darwin* )               opsys=darwin
-                                CPP="${CC-cc} -E -no-cpp-precomp"
-                               ;;
+      *-darwin* )               opsys=darwin ;;
       *-sysv4.2uw* )           opsys=unixware; NON_GNU_CPP=/lib/cpp ;;
       *-sysv5uw* )             opsys=unixware; NON_GNU_CPP=/lib/cpp ;;
       *-sysv5OpenUNIX* )       opsys=unixware; NON_GNU_CPP=/lib/cpp ;;
@@ -633,13 +630,18 @@
 # Save the value of CFLAGS that the user specified.
 SPECIFIED_CFLAGS="$CFLAGS"
 
+# Save specified CPP (if any), before AC_PROG_CPP runs.
+SPECIFIED_CPP="$CPP"
+
 dnl Sets GCC=yes if using gcc.
 AC_PROG_CC
 AM_PROG_CC_C_O
 
 # Initialize gnulib right after verifying that the C compiler works.
+# Note: this ends up setting CPP.
 gl_EARLY
 
+dnl Note: looks like gl_EARLY has already done this (via AC_PROG_CPP).
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
   CPP=
@@ -663,6 +665,46 @@
   fi
 fi
 
+## If using gcc, and on darwin, see if using Apple's gcc, where old
+## (pre gcc 3.3?) versions need -no-cpp-precomp to workaround some
+## (unrecorded) issue.
+## Frankly, I suspect this option is no longer needed on any system
+## still in use today.  It is at best a no-op since Apple's version
+## of gcc 3.3 (?), which corresponds (?) to Xcode 1.5 from 2004.
+## This was for OS X 10.3, and the nextstep port (for example)
+## only supports 10.4 or later (although you could be building a
+## non-ns version on some older OS X I guess).
+if test x"$opsys" = xdarwin && test x"$GCC" = xyes; then
+  AC_MSG_CHECKING([whether we are using an Apple version of GCC])
+  AC_CACHE_VAL(emacs_cv_apple_gcc,
+  [AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
+[[#ifndef __APPLE_CC__
+fail;
+#endif
+]])], emacs_cv_apple_gcc=yes, emacs_cv_apple_gcc=no)])
+  AC_MSG_RESULT($emacs_cv_apple_gcc)
+
+  ## This only tests that adding the option does not cause an error.
+  ## FIXME It may still cause "unrecognized option"
+  ## (in gcc < 4.6 --no-foo does that; newer versions throw an error).
+  ## The message appears on stderr, so AC_EGREP_CPP is no use.
+  ## It would be better to test if it is actually needed.
+  ## For that, someone would have actually had to document what the
+  ## issues it worked around were, so we could test for them.
+  if test $emacs_cv_apple_gcc = yes; then
+    AC_MSG_CHECKING([whether preprocessor accepts -no-cpp-precomp])
+    save_CPP="$CPP"
+    test x$SPECIFIED_CPP = x && CPP="${CC-cc} -E"
+    CPP="$CPP -no-cpp-precomp"
+    dnl NB this will run AC_PROG_CPP first if it has not already happened.
+    AC_CACHE_VAL(emacs_cv_precomp,
+    [AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[]],[[]])], emacs_cv_precomp=yes, 
emacs_cv_precomp=no)])
+    AC_MSG_RESULT($emacs_cv_precomp)
+
+    test $emacs_cv_precomp = no && CPP="$save_CPP"
+  fi
+fi
+
 #### Some systems specify a CPP to use unless we are using GCC.
 #### Now that we know whether we are using GCC, we can decide whether
 #### to use that one.
@@ -671,6 +713,8 @@
   CPP="$NON_GNU_CPP"
 fi
 
+test "x$CPP_TEST_OPTIONS" != x && CPP="$CPP $CPP_TEST_OPTIONS"
+
 #### Some systems specify a CC to use unless we are using GCC.
 #### Now that we know whether we are using GCC, we can decide whether
 #### to use that one.
@@ -805,12 +849,16 @@
 
 #### Some other nice autoconf tests.
 
-dnl checks for programs
+dnl Note: looks like gl_EARLY has already done this.
 AC_PROG_CPP
 AC_PROG_INSTALL
+
+dnl Note: looks like configure does this very early on anyway.
 AC_PROG_MKDIR_P
+
+dnl Note: looks like gl_EARLY has already done this.
 if test "x$RANLIB" = x; then
-  AC_PROG_RANLIB
+   AC_PROG_RANLIB
 fi
 
 ## Although we're running on an amd64 kernel, we're actually compiling for


reply via email to

[Prev in Thread] Current Thread [Next in Thread]