Repository : ssh://darcs.haskell.org//srv/darcs/ghc On branch : master
http://hackage.haskell.org/trac/ghc/changeset/6247b59e5d31de58ee51273916bc44ac2118240a >--------------------------------------------------------------- commit 6247b59e5d31de58ee51273916bc44ac2118240a Author: David M Peixotto <[email protected]> Date: Tue Jun 28 15:38:32 2011 -0500 Add autoconf support to detect an LLVM-based C compiler This patch adds support to the autoconf scripts to detect when we are using a C compiler that uses an LLVM back end. An LLVM back end does not support all of the extensions use by GCC, so we need to perform some conditional compilation in the runtime, particularly for handling thread local storage and global register variables. The changes here will set the CC_LLVM_BACKEND in the autoconf scripts if we detect an llvm-based compiler. We use this variable to define the llvm_CC_FLAVOR variable that we can use in the runtime code to conditionally compile for LLVM. >--------------------------------------------------------------- aclocal.m4 | 16 ++++++++++++++++ configure.ac | 4 ++++ includes/ghc.mk | 4 ++++ mk/project.mk.in | 3 +++ 4 files changed, 27 insertions(+), 0 deletions(-) diff --git a/aclocal.m4 b/aclocal.m4 index c8c125a..ebca797 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -853,6 +853,22 @@ AC_SUBST(GccLT34) AC_SUBST(GccLT46) ])# FP_GCC_VERSION +dnl Check to see if the C compiler uses an LLVM back end +dnl +AC_DEFUN([FP_CC_LLVM_BACKEND], +[AC_REQUIRE([AC_PROG_CC]) +AC_MSG_CHECKING([whether C compiler has an LLVM back end]) +$CC -x c /dev/null -dM -E > conftest.txt 2>&1 +if grep "__llvm__" conftest.txt >/dev/null 2>&1; then + AC_SUBST([CC_LLVM_BACKEND], [1]) + AC_MSG_RESULT([yes]) +else + AC_SUBST([CC_LLVM_BACKEND], [0]) + AC_MSG_RESULT([no]) +fi +rm -f conftest.txt +]) + dnl Small feature test for perl version. Assumes PerlCmd dnl contains path to perl binary. dnl diff --git a/configure.ac b/configure.ac index 1207f08..6d4b0db 100644 --- a/configure.ac +++ b/configure.ac @@ -420,6 +420,10 @@ dnl If gcc, make sure it's at least 2.1 dnl FP_GCC_VERSION +dnl ** look to see if we have a C compiler using an llvm back end. +dnl +FP_CC_LLVM_BACKEND + FPTOOLS_SET_C_LD_FLAGS([target],[CFLAGS],[LDFLAGS],[IGNORE_LINKER_LD_FLAGS],[CPPFLAGS]) FPTOOLS_SET_C_LD_FLAGS([build],[CONF_CC_OPTS_STAGE0],[CONF_GCC_LINKER_OPTS_STAGE0],[CONF_LD_LINKER_OPTS_STAGE0],[CONF_CPP_OPTS_STAGE0]) FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE1],[CONF_GCC_LINKER_OPTS_STAGE1],[CONF_LD_LINKER_OPTS_STAGE1],[CONF_CPP_OPTS_STAGE1]) diff --git a/includes/ghc.mk b/includes/ghc.mk index 8d4fd47..f000a04 100644 --- a/includes/ghc.mk +++ b/includes/ghc.mk @@ -104,6 +104,10 @@ endif @echo "#define $(TargetVendor_CPP)_HOST_VENDOR 1" >> $@ @echo "#define BUILD_VENDOR \"$(HostVendor_CPP)\"" >> $@ @echo "#define HOST_VENDOR \"$(TargetVendor_CPP)\"" >> $@ +ifeq "$(CC_LLVM_BACKEND)" "1" + @echo >> $@ + @echo "#define llvm_CC_FLAVOR 1" >> $@ +endif @echo >> $@ @echo "/* These TARGET macros are for backwards compatibily... DO NOT USE! */" >> $@ @echo "#define TargetPlatform_TYPE $(TargetPlatform_CPP)" >> $@ diff --git a/mk/project.mk.in b/mk/project.mk.in index 58b0f1a..3625124 100644 --- a/mk/project.mk.in +++ b/mk/project.mk.in @@ -143,3 +143,6 @@ OSTYPE=@OSTYPE@ # In case of Solaris OS, does it provide broken shared libs # linker or not? SOLARIS_BROKEN_SHLD=@SOLARIS_BROKEN_SHLD@ + +# Do we have a C compiler using an LLVM back end? +CC_LLVM_BACKEND = @CC_LLVM_BACKEND@ _______________________________________________ Cvs-ghc mailing list [email protected] http://www.haskell.org/mailman/listinfo/cvs-ghc
