Skip to content
Snippets Groups Projects
Commit 6247b59e authored by dmp's avatar dmp
Browse files

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.
parent dba72545
No related merge requests found
......@@ -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
......
......@@ -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])
......
......@@ -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)" >> $@
......
......@@ -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@
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment