Menu

#951 AX_CPP_PRECOMP not working on OSX/macports

devel
closed
nobody
None
5
2014-08-26
2014-03-10
Jack Jost
No

The current configure script is failing with a message "underscore test crashed" on recent OSX/macports versions. The problem is the mismatch of chosing gcc as compiler and passing the clang option '-no-cpp-precomp'.

One option to resolve the problem is outlined below (simply remove the m4 macro that adds the unrecognized option).

An alternative option could add a proper check for clang vs. gcc and only pass the option when it is actually needed and recognized.

Details below:

$ sh autoconf.sh 
Autoconf in root...
Precompiling lexor_keyword.gperf
Precompiling vhdlpp/lexor_keyword.gperf
$ ./configure
checking build system type... i386-apple-darwin13.1.0
checking host system type... i386-apple-darwin13.1.0
checking for gcc... gcc
[...]
checking for shared library link flag... -bundle -undefined suppress -flat_namespace
checking for leading underscores... configure: error: underscore test crashed

config.log:

gcc: error: unrecognized command line option '-no-cpp-precomp'

The '-no-cpp-precomp' option is added by the m4 macro AX_CPP_PRECOMP. Removing all references to this macro resolves the problem:

diff --git a/aclocal.m4 b/aclocal.m4
index 0b0d9c2..79febf1 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -218,18 +218,6 @@ AC_SUBST(strip_dynamic)
 # AC_MSG_RESULT($strip_dynamic)
 ])# AX_LD_RDYNAMIC

-# AX_CPP_PRECOMP
-# --------------
-AC_DEFUN([AX_CPP_PRECOMP],
-[# Darwin requires -no-cpp-precomp
-case "${host}" in
-    *-*-darwin*)
-        CPPFLAGS="-no-cpp-precomp $CPPFLAGS"
-        CFLAGS="-no-cpp-precomp $CFLAGS"
-        ;;
-esac
-])# AX_CPP_PRECOMP
-
 # AX_C99_STRTOD
 # -------------
 AC_DEFUN([AX_C99_STRTOD],
diff --git a/configure.in b/configure.in
index c5a31bf..a04da52 100644
--- a/configure.in
+++ b/configure.in
@@ -217,9 +217,6 @@ AX_LD_EXTRALIBS
 # CFLAGS inherited by cadpli/Makefile?
 AX_C_PICFLAG

-# may modify CPPFLAGS and CFLAGS
-AX_CPP_PRECOMP
-
 # may modify LDFLAGS
 AX_C99_STRTOD

If removing this macro is not an acceptable option, the m4 macro needs to be extended to check for clang vs. gcc.

Looking at the clang man page, this option seems somewhat outdated (it is not even documented in current clang versions).

Discussion

  • Jack Jost

    Jack Jost - 2014-03-10

    Some more info on this option: http://www.mistydemeo.com/?p=78. A web search for the flag indicates that most open-source projects are not using this anymore since it has been causing hard gcc errors since at least gcc-4.7.

     
  • Stephen Williams

    OK, I've removed reference to this flag. Can't see a real value to it anyhow, so it is gone.

     
  • Stephen Williams

    • status: open --> closed
     

Log in to post a comment.