From 3e659dcd914adfbdc544b083dfd1e0686b9018c4 Mon Sep 17 00:00:00 2001 From: Matthew Jacobs Date: Mon, 13 Feb 2017 14:33:06 -0800 Subject: [PATCH] KUDU-1870: Fix Boost build to respect CC/CXX Boost doesn't respect the CC/CXX environment variables, but they may have been set in the Kudu build environment. This fixes this issue by configuring Boost's compiler using the CC/CXX flags if they were set. Testing: - Ran thirdparty build locally, including for tsan. Checked that gcc/clang appeared to be set appropriately. - Ran Impala's toolchain build with this change, verifying the toolchain compiler in CC/CXX was used. Change-Id: I67002e074a67a3a83b8a96167906dbffe2db9522 Reviewed-on: http://gerrit.cloudera.org:8080/5986 Reviewed-by: Adar Dembo Tested-by: Kudu Jenkins Reviewed-by: Todd Lipcon --- thirdparty/build-definitions.sh | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/thirdparty/build-definitions.sh b/thirdparty/build-definitions.sh index 270d0e6b01..d33739b6e8 100644 --- a/thirdparty/build-definitions.sh +++ b/thirdparty/build-definitions.sh @@ -663,18 +663,10 @@ build_boost() { BOOST_CXXFLAGS="$EXTRA_CXXFLAGS -fPIC -DBOOST_DATE_TIME_POSIX_TIME_STD_CONFIG" BOOST_LDFLAGS="$EXTRA_LDFLAGS" - case $BUILD_TYPE in "normal") - # Default: use the default toolset. ;; "tsan") - # We're using a custom clang, so we specify its path in the jamfile. - echo "using clang : : $CXX ;" > $USER_JAMFILE - echo "User jamfile location: $USER_JAMFILE" - echo "User jamfile contents:" - cat $USER_JAMFILE - TOOLSET="toolset=clang" BOOST_LDFLAGS="-stdlib=libc++ $BOOST_LDFLAGS" ;; *) @@ -683,6 +675,21 @@ build_boost() { ;; esac + # If CC and CXX are set, set the compiler in user-config.jam. + if [ -n "$CC" -a -n "$CXX" ]; then + # Determine the name of the compiler referenced in $CC. This assumes the compiler + # prints its name as the first word of the first line, which appears to work for gcc + # and clang, even when they're called through ccache. + local COMPILER=$($CC --version | awk 'NR==1 {print $1;}') + + TOOLSET="toolset=${COMPILER}" + echo "Using $TOOLSET" + echo "using ${COMPILER} : : $CXX ;" > $USER_JAMFILE + echo "User jamfile location: $USER_JAMFILE" + echo "User jamfile contents:" + cat $USER_JAMFILE + fi + # Build the date_time boost lib. ./bootstrap.sh --prefix=$PREFIX threading=multi --with-libraries=date_time ./b2 clean $TOOLSET --build-dir="$BOOST_BDIR"