[commit: ghc] master: workaround Solaris 11 GNU C CPP issue by using GNU C 3.4 as CPP (2d42564)
git at git.haskell.org
git at git.haskell.org
Sun Aug 17 21:27:15 UTC 2014
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/2d42564ac9ffe768f21078e40886fd066f87d1c3/ghc
>---------------------------------------------------------------
commit 2d42564ac9ffe768f21078e40886fd066f87d1c3
Author: Karel Gardas <karel.gardas at centrum.cz>
Date: Sun Aug 17 23:26:39 2014 +0200
workaround Solaris 11 GNU C CPP issue by using GNU C 3.4 as CPP
Summary:
Solaris 11 distributed GNU C 4.5.x is configured in a way that its
CPP is not working well while invoked from GHC. GHC runs it with
-x assembler-with-cpp and in this particular configuration GNU C CPP
does not provide any line-markers so GHC's output of errors or warnings
is confusing since it points to preprocessed file in /tmp and not
to the original Haskell file. Fortunately old GNU C 3.4.x is still
provided by the OS and when installed it'll be used automatically
as GHC CPP which is whole logic of this patch. So although we use modern
GCC as a C compiler and assembler we use old GCC as a C preprocessor.
Test Plan: validate
Reviewers: austin
Reviewed By: austin
Subscribers: phaskell, simonmar, relrod, ezyang, carter
Differential Revision: https://phabricator.haskell.org/D151
>---------------------------------------------------------------
2d42564ac9ffe768f21078e40886fd066f87d1c3
aclocal.m4 | 98 +++++++++++++++++++++++++++++++++++++++++++++++++
configure.ac | 56 +---------------------------
distrib/configure.ac.in | 60 +-----------------------------
3 files changed, 102 insertions(+), 112 deletions(-)
diff --git a/aclocal.m4 b/aclocal.m4
index d3a32b8..7fcf67e 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -2126,5 +2126,103 @@ AC_DEFUN([MAYBE_OVERRIDE_STAGE0],[
])
+# FP_CPP_CMD_WITH_ARGS()
+# ----------------------
+# sets CPP command and its arguments
+#
+# $1 = the variable to set to CPP command
+# $2 = the varibale to set to CPP command arguments
+
+AC_DEFUN([FP_CPP_CMD_WITH_ARGS],[
+dnl ** what cpp to use?
+dnl --------------------------------------------------------------
+AC_ARG_WITH(hs-cpp,
+[AC_HELP_STRING([--with-hs-cpp=ARG],
+ [Use ARG as the path to cpp [default=autodetect]])],
+[
+ if test "$HostOS" = "mingw32"
+ then
+ AC_MSG_WARN([Request to use $withval will be ignored])
+ else
+ HS_CPP_CMD=$withval
+ fi
+],
+[
+
+ HS_CPP_CMD=$WhatGccIsCalled
+
+ SOLARIS_GCC_CPP_BROKEN=NO
+ SOLARIS_FOUND_GOOD_CPP=NO
+ case $host in
+ i386-*-solaris2)
+ GCC_MAJOR_MINOR=`$WhatGccIsCalled --version|grep "gcc (GCC)"|cut -d ' ' -f 3-3|cut -d '.' -f 1-2`
+ if test "$GCC_MAJOR_MINOR" != "3.4"; then
+ # this is not 3.4.x release so with broken CPP
+ SOLARIS_GCC_CPP_BROKEN=YES
+ fi
+ ;;
+ esac
+
+ if test "$SOLARIS_GCC_CPP_BROKEN" = "YES"; then
+ # let's try to find if GNU C 3.4.x is installed
+ if test -x /usr/sfw/bin/gcc; then
+ # something executable is in expected path so let's
+ # see if it's really GNU C
+ NEW_GCC_MAJOR_MINOR=`/usr/sfw/bin/gcc --version|grep "gcc (GCC)"|cut -d ' ' -f 3-3|cut -d '.' -f 1-2`
+ if test "$NEW_GCC_MAJOR_MINOR" = "3.4"; then
+ # this is GNU C 3.4.x which provides non-broken CPP on Solaris
+ # let's use it as CPP then.
+ HS_CPP_CMD=/usr/sfw/bin/gcc
+ SOLARIS_FOUND_GOOD_CPP=YES
+ fi
+ fi
+ if test "$SOLARIS_FOUND_GOOD_CPP" = "NO"; then
+ AC_MSG_WARN([Your GNU C provides broken CPP and you do not have GNU C 3.4.x installed.])
+ AC_MSG_WARN([Please install GNU C 3.4.x to solve this issue. It will be used as CPP only.])
+ fi
+ fi
+]
+)
+
+
+
+dnl ** what cpp flags to use?
+dnl -----------------------------------------------------------
+AC_ARG_WITH(hs-cpp-flags,
+ [AC_HELP_STRING([--with-hs-cpp-flags=ARG],
+ [Use ARG as the path to hs cpp [default=autodetect]])],
+ [
+ if test "$HostOS" = "mingw32"
+ then
+ AC_MSG_WARN([Request to use $withval will be ignored])
+ else
+ HS_CPP_ARGS=$withval
+ fi
+ ],
+[
+ $HS_CPP_CMD -x c /dev/null -dM -E > conftest.txt 2>&1
+ if grep "__clang__" conftest.txt >/dev/null 2>&1; then
+ HS_CPP_ARGS="-E -undef -traditional -Wno-invalid-pp-token -Wno-unicode -Wno-trigraphs "
+ else
+ $HS_CPP_CMD -v > conftest.txt 2>&1
+ if grep "gcc" conftest.txt >/dev/null 2>&1; then
+ HS_CPP_ARGS="-E -undef -traditional "
+ else
+ $HS_CPP_CMD --version > conftest.txt 2>&1
+ if grep "cpphs" conftest.txt >/dev/null 2>&1; then
+ HS_CPP_ARGS="--cpp -traditional"
+ else
+ AC_MSG_WARN([configure can't recognize your CPP program, you may need to set --with-hs-cpp-flags=FLAGS explicitly])
+ HS_CPP_ARGS=""
+ fi
+ fi
+ fi
+ ]
+)
+
+$1=$HS_CPP_CMD
+$2=$HS_CPP_ARGS
+
+])
# LocalWords: fi
diff --git a/configure.ac b/configure.ac
index 378578a..a065b31 100644
--- a/configure.ac
+++ b/configure.ac
@@ -484,60 +484,8 @@ export CC
MAYBE_OVERRIDE_STAGE0([gcc],[CC_STAGE0])
MAYBE_OVERRIDE_STAGE0([ar],[AR_STAGE0])
-dnl ** what cpp to use?
-dnl --------------------------------------------------------------
-AC_ARG_WITH(hs-cpp,
-[AC_HELP_STRING([--with-hs-cpp=ARG],
- [Use ARG as the path to cpp [default=autodetect]])],
-[
- if test "$HostOS" = "mingw32"
- then
- AC_MSG_WARN([Request to use $withval will be ignored])
- else
- HaskellCPPCmd=$withval
- fi
-],
-[
- HaskellCPPCmd=$WhatGccIsCalled
-]
-)
-
-
-
-dnl ** what cpp flags to use?
-dnl -----------------------------------------------------------
-AC_ARG_WITH(hs-cpp-flags,
- [AC_HELP_STRING([--with-hs-cpp-flags=ARG],
- [Use ARG as the path to hs cpp [default=autodetect]])],
- [
- if test "$HostOS" = "mingw32"
- then
- AC_MSG_WARN([Request to use $withval will be ignored])
- else
- HaskellCPPArgs=$withval
- fi
- ],
-[
- $HaskellCPPCmd -x c /dev/null -dM -E > conftest.txt 2>&1
- if grep "__clang__" conftest.txt >/dev/null 2>&1; then
- HaskellCPPArgs="-E -undef -traditional -Wno-invalid-pp-token -Wno-unicode -Wno-trigraphs "
- else
- $HaskellCPPCmd -v > conftest.txt 2>&1
- if grep "gcc" conftest.txt >/dev/null 2>&1; then
- HaskellCPPArgs="-E -undef -traditional "
- else
- $HaskellCPPCmd --version > conftest.txt 2>&1
- if grep "cpphs" conftest.txt >/dev/null 2>&1; then
- HaskellCPPArgs="--cpp -traditional"
- else
- AC_MSG_WARN([configure can't recognize your CPP program, you may need to set --with-hs-cpp-flags=FLAGS explicitly])
- HaskellCPPArgs=""
- fi
- fi
- fi
- ]
-)
-
+# --with-hs-cpp/--with-hs-cpp-flags
+FP_CPP_CMD_WITH_ARGS(HaskellCPPCmd, HaskellCPPArgs)
dnl ** Which ld to use?
dnl --------------------------------------------------------------
diff --git a/distrib/configure.ac.in b/distrib/configure.ac.in
index c7a8ead..2ae0072 100644
--- a/distrib/configure.ac.in
+++ b/distrib/configure.ac.in
@@ -63,64 +63,8 @@ FIND_GCC([WhatGccIsCalled], [gcc], [gcc])
CC="$WhatGccIsCalled"
export CC
-
-dnl ** what cpp to use?
-dnl --------------------------------------------------------------
-AC_ARG_WITH(hs-cpp,
-[AC_HELP_STRING([--with-hs-cpp=ARG],
- [Use ARG as the path to cpp [default=autodetect]])],
-[
- if test "$HostOS" = "mingw32"
- then
- AC_MSG_WARN([Request to use $withval will be ignored])
- else
- HaskellCPPCmd=$withval
- fi
-],
-[
- if test "$HostOS" != "mingw32"
- then
- HaskellCPPCmd=$WhatGccIsCalled
- fi
-]
-)
-
-
-
-dnl ** what cpp flags to use?
-dnl -----------------------------------------------------------
-AC_ARG_WITH(hs-cpp-flags,
- [AC_HELP_STRING([--with-hs-cpp-flags=ARG],
- [Use ARG as the path to hs cpp [default=autodetect]])],
- [
- if test "$HostOS" = "mingw32"
- then
- AC_MSG_WARN([Request to use $withval will be ignored])
- else
- HaskellCPPArgs=$withval
- fi
- ],
-[
- $HaskellCPPCmd -x c /dev/null -dM -E > conftest.txt 2>&1
- if grep "__clang__" conftest.txt >/dev/null 2>&1; then
- HaskellCPPArgs="-E -undef -traditional -Wno-invalid-pp-token -Wno-unicode -Wno-trigraphs "
- else
- $HaskellCPPCmd -v > conftest.txt 2>&1
- if grep "gcc" conftest.txt >/dev/null 2>&1; then
- HaskellCPPArgs="-E -undef -traditional "
- else
- $HaskellCPPCmd --version > conftest.txt 2>&1
- if grep "cpphs" conftest.txt >/dev/null 2>&1; then
- HaskellCPPArgs="--cpp -traditional"
- else
- AC_MSG_WARN([configure can't recognize your CPP program, you may need to set --with-hs-cpp-flags=FLAGS explicitly])
- HaskellCPPArgs=""
- fi
- fi
- fi
- ]
-)
-
+# --with-hs-cpp/--with-hs-cpp-flags
+FP_CPP_CMD_WITH_ARGS(HaskellCPPCmd, HaskellCPPArgs)
dnl ** Which ld to use?
dnl --------------------------------------------------------------
More information about the ghc-commits
mailing list