Skip to content

Commit

Permalink
Bug 1259382 - Move CC/CXX/HOST_CC/HOST_CXX to moz.configure. r=ted
Browse files Browse the repository at this point in the history
At the same time, we improve things slightly by deriving HOST_CC from CC
in a smarter way, as well as CXX from CC, which we weren't doing
previously.

Many related things are not moved at the same time to keep the patch
somehow "small".
  • Loading branch information
glandium committed Apr 14, 2016
1 parent 6978958 commit 341ebd8
Show file tree
Hide file tree
Showing 11 changed files with 335 additions and 151 deletions.
1 change: 0 additions & 1 deletion aclocal.m4
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ builtin(include, build/autoconf/acwinpaths.m4)dnl
builtin(include, build/autoconf/hooks.m4)dnl
builtin(include, build/autoconf/config.status.m4)dnl
builtin(include, build/autoconf/toolchain.m4)dnl
builtin(include, build/autoconf/wrapper.m4)dnl
builtin(include, build/autoconf/nspr.m4)dnl
builtin(include, build/autoconf/nspr-build.m4)dnl
builtin(include, build/autoconf/nss.m4)dnl
Expand Down
2 changes: 2 additions & 0 deletions browser/config/mozconfigs/linux64/artifact
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ NO_CACHE=1
. "$topsrcdir/browser/config/mozconfigs/linux64/nightly"

ac_add_options --enable-artifact-builds
unset CC
unset CXX
146 changes: 38 additions & 108 deletions build/autoconf/toolchain.m4
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,12 @@ AC_DEFUN([MOZ_TOOL_VARIABLES],
[
GNU_AS=
GNU_LD=
GNU_CC=
GNU_CXX=
CC_VERSION='N/A'
CXX_VERSION='N/A'
cat <<EOF > conftest.c
#if defined(_MSC_VER)
#if defined(__clang__)
COMPILER clang-cl _MSC_VER
#else
COMPILER msvc _MSC_FULL_VER
#endif
#elif defined(__clang__)
COMPILER clang __clang_major__.__clang_minor__.__clang_patchlevel__
#elif defined(__GNUC__)
COMPILER gcc __GNUC__.__GNUC_MINOR__.__GNUC_PATCHLEVEL__
#endif
EOF
read dummy compiler CC_VERSION <<EOF
$($CC -E $CPPFLAGS $CFLAGS conftest.c 2>/dev/null | grep COMPILER)
EOF
read dummy cxxcompiler CXX_VERSION <<EOF
$($CXX -E $CPPFLAGS $CXXFLAGS 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 "$CC_VERSION" != "$CXX_VERSION"; then
# This may not be strictly necessary, but if we want to drop it, we
# should make sure any version checks below apply to both the C and
# C++ compiler versions.
AC_MSG_ERROR([Your C and C++ compiler versions are different. You need to use the same compiler version.])
fi
CC_VERSION=`echo "$CC_VERSION" | sed 's/ //g'`
CXX_VERSION=`echo "$CXX_VERSION" | sed 's/ //g'`
if test "$compiler" = "gcc"; then
dnl moz.configure ensures that the compilers have the same version
CXX_VERSION=$CC_VERSION
if test "$CC_TYPE" = "gcc"; then
GNU_CC=1
GNU_CXX=1
changequote(<<,>>)
Expand All @@ -60,7 +31,7 @@ if test "`echo | $LD -v 2>&1 | grep -c GNU`" != "0"; then
GNU_LD=1
fi
if test "$compiler" = "msvc"; then
if test "$CC_TYPE" = "msvc"; then
MSVC_VERSION_FULL="$CXX_VERSION"
CC_VERSION=`echo ${CC_VERSION} | cut -c 1-4`
CXX_VERSION=`echo ${CXX_VERSION} | cut -c 1-4`
Expand All @@ -69,13 +40,13 @@ fi
CLANG_CC=
CLANG_CXX=
CLANG_CL=
if test "$compiler" = "clang"; then
if test "$CC_TYPE" = "clang"; then
GNU_CC=1
GNU_CXX=1
CLANG_CC=1
CLANG_CXX=1
fi
if test "$compiler" = "clang-cl"; then
if test "$CC_TYPE" = "clang-cl"; then
CLANG_CL=1
# We force clang-cl to emulate Visual C++ 2013 in configure.in, but that
# is based on the CLANG_CL variable defined here, so make sure that we're
Expand Down Expand Up @@ -113,19 +84,6 @@ _SAVE_CC="$CC"
_SAVE_CFLAGS="$CFLAGS"
_SAVE_LDFLAGS="$LDFLAGS"
AC_MSG_CHECKING([for host c compiler])
AC_CHECK_PROGS(HOST_CC, cc gcc clang cl, "")
if test -z "$HOST_CC"; then
AC_MSG_ERROR([no acceptable c compiler found in \$PATH])
fi
AC_MSG_RESULT([$HOST_CC])
AC_MSG_CHECKING([for host c++ compiler])
AC_CHECK_PROGS(HOST_CXX, c++ g++ clang++ cl, "")
if test -z "$HOST_CXX"; then
AC_MSG_ERROR([no acceptable c++ compiler found in \$PATH])
fi
AC_MSG_RESULT([$HOST_CXX])
if test -z "$HOST_AR_FLAGS"; then
HOST_AR_FLAGS="$AR_FLAGS"
fi
Expand Down Expand Up @@ -162,11 +120,7 @@ case "${TOOLCHAIN_PREFIX}" in
PATH="/:$PATH"
;;
esac
AC_CHECK_PROGS(CC, "${TOOLCHAIN_PREFIX}gcc", :)
unset ac_cv_prog_CC
AC_PROG_CC
AC_CHECK_PROGS(CXX, "${TOOLCHAIN_PREFIX}g++", :)
unset ac_cv_prog_CXX
AC_PROG_CXX
AC_CHECK_PROGS(RANLIB, "${TOOLCHAIN_PREFIX}ranlib", :)
Expand Down Expand Up @@ -230,64 +184,40 @@ if test "$GNU_CXX"; then
fi
if test -n "$CROSS_COMPILE"; then
dnl When cross compile, we have no variable telling us what the host compiler is. Figure it out.
cat > conftest.C <<EOF
#if defined(__clang__)
COMPILER CLANG __clang_major__.__clang_minor__.__clang_patchlevel__
#elif defined(__GNUC__)
COMPILER GCC __GNUC__.__GNUC_MINOR__.__GNUC_PATCHLEVEL__
#endif
EOF
read dummy host_compiler HOST_CC_VERSION <<EOF
$($HOST_CC -E conftest.C 2>/dev/null | grep COMPILER)
EOF
read dummy host_cxxcompiler HOST_CXX_VERSION <<EOF
$($HOST_CXX -E conftest.C 2>/dev/null | grep COMPILER)
EOF
rm conftest.C
if test "$host_compiler" != "$host_cxxcompiler"; then
AC_MSG_ERROR([Your C and C++ host compilers are different. You need to use the same compiler.])
dnl moz.configure ensures that the compilers have the same version
HOST_CXX_VERSION=$HOST_CC_VERSION
if test "$HOST_CC_TYPE" = "gcc" ; then
changequote(<<,>>)
HOST_GCC_VERSION_FULL="$HOST_CXX_VERSION"
HOST_GCC_VERSION=`echo "$HOST_GCC_VERSION_FULL" | $PERL -pe '(split(/\./))[0]>=4&&s/(^\d*\.\d*).*/<<$>>1/;'`
HOST_GCC_MAJOR_VERSION=`echo ${HOST_GCC_VERSION} | $AWK -F\. '{ print <<$>>1 }'`
HOST_GCC_MINOR_VERSION=`echo ${HOST_GCC_VERSION} | $AWK -F\. '{ print <<$>>2 }'`
changequote([,])
if test "$HOST_GCC_MAJOR_VERSION" -eq 4 -a "$HOST_GCC_MINOR_VERSION" -lt 8 ||
test "$HOST_GCC_MAJOR_VERSION" -lt 4; then
AC_MSG_ERROR([Only GCC 4.8 or newer supported for host compiler])
fi
fi
if test "$HOST_CC_VERSION" != "$HOST_CXX_VERSION"; then
# This may not be strictly necessary, but if we want to drop it,
# we should make sure any version checks below apply to both the
# C and C++ compiler versions.
AC_MSG_ERROR([Your C and C++ host compiler versions are different. You need to use the same compiler version.])
fi
if test -n "$host_compiler"; then
if test "$host_compiler" = "GCC" ; then
changequote(<<,>>)
HOST_GCC_VERSION_FULL="$HOST_CXX_VERSION"
HOST_GCC_VERSION=`echo "$HOST_GCC_VERSION_FULL" | $PERL -pe '(split(/\./))[0]>=4&&s/(^\d*\.\d*).*/<<$>>1/;'`
HOST_GCC_MAJOR_VERSION=`echo ${HOST_GCC_VERSION} | $AWK -F\. '{ print <<$>>1 }'`
HOST_GCC_MINOR_VERSION=`echo ${HOST_GCC_VERSION} | $AWK -F\. '{ print <<$>>2 }'`
changequote([,])
if test "$HOST_GCC_MAJOR_VERSION" -eq 4 -a "$HOST_GCC_MINOR_VERSION" -lt 8 ||
test "$HOST_GCC_MAJOR_VERSION" -lt 4; then
AC_MSG_ERROR([Only GCC 4.8 or newer supported for host compiler])
fi
fi
HOST_CXXFLAGS="$HOST_CXXFLAGS -std=gnu++11"
_SAVE_CXXFLAGS="$CXXFLAGS"
_SAVE_CPPFLAGS="$CPPFLAGS"
_SAVE_CXX="$CXX"
CXXFLAGS="$HOST_CXXFLAGS"
CPPFLAGS="$HOST_CPPFLAGS"
CXX="$HOST_CXX"
if test "$host_compiler" = CLANG; then
AC_TRY_COMPILE([], [#if !__cpp_static_assert
#error ISO WG21 SG10 feature test macros unsupported
#endif],,AC_MSG_ERROR([Only clang/llvm 3.4 or newer supported]))
fi
CXXFLAGS="$_SAVE_CXXFLAGS"
CPPFLAGS="$_SAVE_CPPFLAGS"
CXX="$_SAVE_CXX"
HOST_CXXFLAGS="$HOST_CXXFLAGS -std=gnu++11"
_SAVE_CXXFLAGS="$CXXFLAGS"
_SAVE_CPPFLAGS="$CPPFLAGS"
_SAVE_CXX="$CXX"
CXXFLAGS="$HOST_CXXFLAGS"
CPPFLAGS="$HOST_CPPFLAGS"
CXX="$HOST_CXX"
if test "$HOST_CC_TYPE" = clang; then
AC_TRY_COMPILE([], [#if !__cpp_static_assert
#error ISO WG21 SG10 feature test macros unsupported
#endif],,AC_MSG_ERROR([Only clang/llvm 3.4 or newer supported]))
fi
CXXFLAGS="$_SAVE_CXXFLAGS"
CPPFLAGS="$_SAVE_CPPFLAGS"
CXX="$_SAVE_CXX"
elif test "$GNU_CXX"; then
HOST_CXXFLAGS="$HOST_CXXFLAGS $_ADDED_CXXFLAGS"
fi
Expand Down
25 changes: 0 additions & 25 deletions build/autoconf/wrapper.m4

This file was deleted.

4 changes: 4 additions & 0 deletions build/moz.configure/init.configure
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,9 @@ def wanted_mozconfig_variables(help):
return set([
'AUTOCONF',
'AWK',
'CC',
'CCACHE',
'CXX',
'COMPILER_WRAPPER',
'DISABLE_EXPORT_JS',
'DISABLE_SHARED_JS',
Expand All @@ -276,6 +278,8 @@ def wanted_mozconfig_variables(help):
'GRADLE',
'GRADLE_FLAGS',
'GRADLE_MAVEN_REPOSITORY',
'HOST_CC',
'HOST_CXX',
'JS_STANDALONE',
'L10NBASEDIR',
'MOZILLABUILD',
Expand Down
Loading

0 comments on commit 341ebd8

Please sign in to comment.