Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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.
  • Loading branch information...
commit 21b476597dcf199801f8dff4358632b141920d1d 1 parent ccf0166
David Peixotto authored
16  aclocal.m4
@@ -760,6 +760,22 @@ AC_SUBST(GccLT34)
760 760
 AC_SUBST(GccLT46)
761 761
 ])# FP_GCC_VERSION
762 762
 
  763
+dnl Check to see if the C compiler uses an LLVM back end
  764
+dnl
  765
+AC_DEFUN([FP_CC_LLVM_BACKEND],
  766
+[AC_REQUIRE([AC_PROG_CC])
  767
+AC_MSG_CHECKING([whether C compiler has an LLVM back end])
  768
+$CC -x c /dev/null -dM -E > conftest.txt 2>&1
  769
+if grep "__llvm__" conftest.txt >/dev/null 2>&1; then
  770
+  AC_SUBST([CC_LLVM_BACKEND], [1])
  771
+  AC_MSG_RESULT([yes])
  772
+else
  773
+  AC_SUBST([CC_LLVM_BACKEND], [0])
  774
+  AC_MSG_RESULT([no])
  775
+fi
  776
+rm -f conftest.txt
  777
+])
  778
+
763 779
 dnl Small feature test for perl version. Assumes PerlCmd
764 780
 dnl contains path to perl binary.
765 781
 dnl
4  configure.ac
@@ -526,6 +526,10 @@ dnl     If gcc, make sure it's at least 2.1
526 526
 dnl
527 527
 FP_GCC_VERSION
528 528
 
  529
+dnl ** look to see if we have a C compiler using an llvm back end.
  530
+dnl
  531
+FP_CC_LLVM_BACKEND
  532
+
529 533
 FPTOOLS_SET_C_LD_FLAGS([target],[CFLAGS],[LDFLAGS],[IGNORE_LINKER_LD_FLAGS],[CPPFLAGS])
530 534
 FPTOOLS_SET_C_LD_FLAGS([build],[CONF_CC_OPTS_STAGE0],[CONF_GCC_LINKER_OPTS_STAGE0],[CONF_LD_LINKER_OPTS_STAGE0],[CONF_CPP_OPTS_STAGE0])
531 535
 FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE1],[CONF_GCC_LINKER_OPTS_STAGE1],[CONF_LD_LINKER_OPTS_STAGE1],[CONF_CPP_OPTS_STAGE1])
4  includes/ghc.mk
@@ -104,6 +104,10 @@ endif
104 104
 	@echo "#define $(TargetVendor_CPP)_HOST_VENDOR  1" >> $@
105 105
 	@echo "#define BUILD_VENDOR  \"$(HostVendor_CPP)\"" >> $@
106 106
 	@echo "#define HOST_VENDOR  \"$(TargetVendor_CPP)\"" >> $@
  107
+ifeq "$(CC_LLVM_BACKEND)" "1"
  108
+	@echo >> $@
  109
+	@echo "#define llvm_CC_FLAVOR 1" >> $@
  110
+endif
107 111
 	@echo >> $@
108 112
 	@echo "/* These TARGET macros are for backwards compatibily... DO NOT USE! */" >> $@
109 113
 	@echo "#define TargetPlatform_TYPE $(TargetPlatform_CPP)" >> $@
3  mk/project.mk.in
@@ -143,3 +143,6 @@ OSTYPE=@OSTYPE@
143 143
 # In case of Solaris OS, does it provide broken shared libs
144 144
 # linker or not?
145 145
 SOLARIS_BROKEN_SHLD=@SOLARIS_BROKEN_SHLD@
  146
+
  147
+# Do we have a C compiler using an LLVM back end?
  148
+CC_LLVM_BACKEND = @CC_LLVM_BACKEND@

0 notes on commit 21b4765

Please sign in to comment.
Something went wrong with that request. Please try again.