зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1021378 - Add support for clang-cl to the build system; r=glandium
This patch does two things: 1. Treat clang on Windows explicitly as MSVC. There are some places in our build system where we try to detect clang by looking at the output of $(CC) -v, and that will cause us to believe that we are using clang, which is not helpful. This patch defines the CLANG_CL variable when it detects clang being used on Windows. It also masquarades clang-cl as MSVC 2012, which is how the compiler introduces itself through the _MSC_VER predefined variable. 2. Disable a bunch of things which currently are not supported on clang-cl. As we proceed with this port, hopefully we'll be able to remove everything in this list, but this will get us closer to be able to build with clang-cl. With this patch and clang-cl trunk, we can get past the configure stage of the build. --HG-- extra : rebase_source : e5b8d77e4571c936820cec858953d58b6f31e0d5
This commit is contained in:
Родитель
1091ffe3bd
Коммит
fde35aa8b8
|
@ -10,15 +10,40 @@ GNU_CC=
|
|||
GNU_CXX=
|
||||
CC_VERSION='N/A'
|
||||
CXX_VERSION='N/A'
|
||||
if test "$GCC" = "yes"; then
|
||||
GNU_CC=1
|
||||
CC_VERSION=`$CC -v 2>&1 | grep 'gcc version'`
|
||||
cat <<EOF > conftest.c
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(__clang__)
|
||||
COMPILER clang-cl _MSC_VER
|
||||
#else
|
||||
COMPILER msvc _MSC_VER
|
||||
#endif
|
||||
#elif defined(__clang__)
|
||||
COMPILER clang __clang_major__.__clang_minor__.__clang_patchlevel__
|
||||
#elif defined(__GNUC__)
|
||||
COMPILER gcc __GNUC__.__GNUC_MINOR__.__GNUC_PATCHLEVEL__
|
||||
#elif defined(__INTEL_COMPILER)
|
||||
COMPILER icc __INTEL_COMPILER
|
||||
#endif
|
||||
EOF
|
||||
read dummy compiler CC_VERSION <<EOF
|
||||
$($CC -E conftest.c 2>/dev/null | grep COMPILER)
|
||||
EOF
|
||||
read dummy cxxcompiler CXX_VERSION <<EOF
|
||||
$($CXX -E conftest.c 2>/dev/null | grep COMPILER)
|
||||
EOF
|
||||
if test "$compiler" != "$cxxcompiler"; then
|
||||
AC_MSG_ERROR([Your C and C++ compilers are different. You need to use the same compiler.])
|
||||
fi
|
||||
if test "$GXX" = "yes"; then
|
||||
CC_VERSION=`echo "$CC_VERSION" | sed 's/ //g'`
|
||||
CXX_VERSION=`echo "$CXX_VERSION" | sed 's/ //g'`
|
||||
echo "$CC_VERSION"
|
||||
echo "$CXX_VERSION"
|
||||
ecit 1
|
||||
if test "$compiler" = "gcc"; then
|
||||
GNU_CC=1
|
||||
GNU_CXX=1
|
||||
CXX_VERSION=`$CXX -v 2>&1 | grep 'gcc version'`
|
||||
changequote(<<,>>)
|
||||
GCC_VERSION_FULL=`echo "$CXX_VERSION" | $PERL -pe 's/^.*gcc version ([^ ]*).*/<<$>>1/'`
|
||||
GCC_VERSION_FULL="$CXX_VERSION"
|
||||
GCC_VERSION=`echo "$GCC_VERSION_FULL" | $PERL -pe '(split(/\./))[0]>=4&&s/(^\d*\.\d*).*/<<$>>1/;'`
|
||||
|
||||
GCC_MAJOR_VERSION=`echo ${GCC_VERSION} | $AWK -F\. '{ print <<$>>1 }'`
|
||||
|
@ -41,28 +66,26 @@ fi
|
|||
|
||||
INTEL_CC=
|
||||
INTEL_CXX=
|
||||
if test "$GCC" = yes; then
|
||||
if test "`$CC -help 2>&1 | grep -c 'Intel(R) C++ Compiler'`" != "0"; then
|
||||
INTEL_CC=1
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$GXX" = yes; then
|
||||
if test "`$CXX -help 2>&1 | grep -c 'Intel(R) C++ Compiler'`" != "0"; then
|
||||
INTEL_CXX=1
|
||||
fi
|
||||
if test "$compiler" = "icc"; then
|
||||
INTEL_CC=1
|
||||
INTEL_CXX=1
|
||||
fi
|
||||
|
||||
CLANG_CC=
|
||||
CLANG_CXX=
|
||||
if test "`$CC -v 2>&1 | egrep -c '(clang version|Apple.*clang)'`" != "0"; then
|
||||
CLANG_CC=1
|
||||
CLANG_CL=
|
||||
if test "$compiler" = "clang"; then
|
||||
GNU_CC=1
|
||||
GNU_CXX=1
|
||||
CLANG_CC=1
|
||||
CLANG_CXX=1
|
||||
fi
|
||||
if test "$compiler" = "clang-cl"; then
|
||||
CLANG_CL=1
|
||||
fi
|
||||
|
||||
if test "`$CXX -v 2>&1 | egrep -c '(clang version|Apple.*clang)'`" != "0"; then
|
||||
CLANG_CXX=1
|
||||
fi
|
||||
AC_SUBST(CLANG_CXX)
|
||||
AC_SUBST(CLANG_CL)
|
||||
])
|
||||
|
||||
AC_DEFUN([MOZ_CROSS_COMPILER],
|
||||
|
|
38
configure.in
38
configure.in
|
@ -465,15 +465,11 @@ case "$target" in
|
|||
changequote([,])
|
||||
|
||||
# Determine compiler version
|
||||
CC_VERSION=`${CC} -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
|
||||
_CC_MAJOR_VERSION=`echo ${CC_VERSION} | $AWK -F\. '{ print $1 }'`
|
||||
_CC_MINOR_VERSION=`echo ${CC_VERSION} | $AWK -F\. '{ print $2 }'`
|
||||
_CC_RELEASE=`echo ${CC_VERSION} | $AWK -F\. '{ print $3 }'`
|
||||
_CC_BUILD=`echo ${CC_VERSION} | $AWK -F\. '{ print $4 }'`
|
||||
_MSC_VER=${_CC_MAJOR_VERSION}${_CC_MINOR_VERSION}
|
||||
_CC_MAJOR_VERSION=`echo ${CC_VERSION} | cut -c 1-2`
|
||||
_CC_MINOR_VERSION=`echo ${CC_VERSION} | cut -c 3-4`
|
||||
_MSC_VER=${CC_VERSION}
|
||||
|
||||
CXX_VERSION=`${CXX} -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
|
||||
_CXX_MAJOR_VERSION=`echo ${CXX_VERSION} | $AWK -F\. '{ print $1 }'`
|
||||
_CXX_MAJOR_VERSION=`echo ${CXX_VERSION} | cut -c 1-2`
|
||||
|
||||
if test "$_CC_MAJOR_VERSION" != "$_CXX_MAJOR_VERSION"; then
|
||||
AC_MSG_ERROR([The major versions of \$CC and \$CXX do not match.])
|
||||
|
@ -496,7 +492,10 @@ case "$target" in
|
|||
fi
|
||||
AC_SUBST(MSVS_VERSION)
|
||||
|
||||
AC_DEFINE(HAVE_SEH_EXCEPTIONS)
|
||||
# Disable SEH on clang-cl because it doesn't implement them yet.
|
||||
if test -z "$CLANG_CL"; then
|
||||
AC_DEFINE(HAVE_SEH_EXCEPTIONS)
|
||||
fi
|
||||
|
||||
if test -n "$WIN32_REDIST_DIR"; then
|
||||
if test ! -d "$WIN32_REDIST_DIR"; then
|
||||
|
@ -617,8 +616,10 @@ case "$target" in
|
|||
fi
|
||||
|
||||
if test "$WRAP_STL_INCLUDES" = "1"; then
|
||||
STL_FLAGS='-D_HAS_EXCEPTIONS=0 -I$(DIST)/stl_wrappers'
|
||||
STL_FLAGS='-I$(DIST)/stl_wrappers'
|
||||
fi
|
||||
CFLAGS="$CFLAGS -D_HAS_EXCEPTIONS=0"
|
||||
CXXFLAGS="$CXXFLAGS -D_HAS_EXCEPTIONS=0"
|
||||
elif test -z "$CLANG_CC"; then
|
||||
# Check w32api version
|
||||
_W32API_MAJOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $1 }'`
|
||||
|
@ -899,11 +900,6 @@ fi
|
|||
|
||||
fi # COMPILE_ENVIRONMENT
|
||||
|
||||
AC_MSG_CHECKING([compiler version])
|
||||
# Just print it so it shows up in the logs.
|
||||
cc_version=$($CC --version)
|
||||
AC_MSG_RESULT([$cc_version])
|
||||
|
||||
if test -n "$MAKE"; then
|
||||
if test `echo $MAKE | grep -c make.py` != 1; then
|
||||
NOT_PYMAKE=$MAKE
|
||||
|
@ -2166,7 +2162,11 @@ ia64*-hpux*)
|
|||
MOZ_OPTIMIZE_FLAGS='-O1 -Oi'
|
||||
MOZ_FIX_LINK_PATHS=
|
||||
MOZ_COMPONENT_NSPR_LIBS='$(NSPR_LIBS)'
|
||||
LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE -NXCOMPAT"
|
||||
# Disable these flags on clang-cl since it doesn't ignore unknown arguments by default, and
|
||||
# autoconf insists on passing $LDFLAGS to the compiler.
|
||||
if test -z "$CLANG_CL"; then
|
||||
LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE -NXCOMPAT"
|
||||
fi
|
||||
if test -z "$DEVELOPER_OPTIONS"; then
|
||||
LDFLAGS="$LDFLAGS -RELEASE"
|
||||
fi
|
||||
|
@ -2254,7 +2254,11 @@ ia64*-hpux*)
|
|||
LDFLAGS="$LDFLAGS -Wl,--enable-stdcall-fixup -Wl,--large-address-aware"
|
||||
else
|
||||
DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X86"
|
||||
LDFLAGS="$LDFLAGS -SAFESEH"
|
||||
# Disable this flag on clang-cl since it doesn't ignore unknown arguments by default, and
|
||||
# autoconf insists on passing $LDFLAGS to the compiler.
|
||||
if test -z "$CLANG_CL"; then
|
||||
LDFLAGS="$LDFLAGS -SAFESEH"
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_DEFINE(_X86_)
|
||||
|
|
|
@ -422,15 +422,11 @@ case "$target" in
|
|||
changequote([,])
|
||||
|
||||
# Determine compiler version
|
||||
CC_VERSION=`${CC} -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
|
||||
_CC_MAJOR_VERSION=`echo ${CC_VERSION} | $AWK -F\. '{ print $1 }'`
|
||||
_CC_MINOR_VERSION=`echo ${CC_VERSION} | $AWK -F\. '{ print $2 }'`
|
||||
_CC_RELEASE=`echo ${CC_VERSION} | $AWK -F\. '{ print $3 }'`
|
||||
_CC_BUILD=`echo ${CC_VERSION} | $AWK -F\. '{ print $4 }'`
|
||||
_MSC_VER=${_CC_MAJOR_VERSION}${_CC_MINOR_VERSION}
|
||||
_CC_MAJOR_VERSION=`echo ${CC_VERSION} | cut -c 1-2`
|
||||
_CC_MINOR_VERSION=`echo ${CC_VERSION} | cut -c 3-4`
|
||||
_MSC_VER=${CC_VERSION}
|
||||
|
||||
CXX_VERSION=`${CXX} -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
|
||||
_CXX_MAJOR_VERSION=`echo ${CXX_VERSION} | $AWK -F\. '{ print $1 }'`
|
||||
_CXX_MAJOR_VERSION=`echo ${CXX_VERSION} | cut -c 1-2`
|
||||
|
||||
if test "$_CC_MAJOR_VERSION" != "$_CXX_MAJOR_VERSION"; then
|
||||
AC_MSG_ERROR([The major versions of \$CC and \$CXX do not match.])
|
||||
|
@ -1678,7 +1674,11 @@ ia64*-hpux*)
|
|||
MOZ_OPTIMIZE_FLAGS="-O2"
|
||||
MOZ_FIX_LINK_PATHS=
|
||||
MOZ_COMPONENT_NSPR_LIBS='$(NSPR_LIBS)'
|
||||
LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE -NXCOMPAT"
|
||||
# Disable these flags on clang-cl since it doesn't ignore unknown arguments by default, and
|
||||
# autoconf insists on passing $LDFLAGS to the compiler.
|
||||
if test -z "$CLANG_CL"; then
|
||||
LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE -NXCOMPAT"
|
||||
fi
|
||||
if test -z "$DEVELOPER_OPTIONS"; then
|
||||
LDFLAGS="$LDFLAGS -RELEASE"
|
||||
fi
|
||||
|
@ -1758,7 +1758,11 @@ ia64*-hpux*)
|
|||
LDFLAGS="$LDFLAGS -Wl,--large-address-aware"
|
||||
else
|
||||
DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X86"
|
||||
LDFLAGS="$LDFLAGS -SAFESEH"
|
||||
# Disable this flag on clang-cl since it doesn't ignore unknown arguments by default, and
|
||||
# autoconf insists on passing $LDFLAGS to the compiler.
|
||||
if test -z "$CLANG_CL"; then
|
||||
LDFLAGS="$LDFLAGS -SAFESEH"
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_DEFINE(_X86_)
|
||||
|
|
Загрузка…
Ссылка в новой задаче