From 216bd7c649f0e06c372f0bcf08b4addcaba5734e Mon Sep 17 00:00:00 2001 From: Liu Xudong <45041955+chalsliu@users.noreply.github.com> Date: Tue, 20 Nov 2018 18:45:48 +0800 Subject: [PATCH 1/2] Support for custom build toolchains ISSUE #297 Locate the header file path of DORIS_GCC_HOME, add them to the CPLUS_INCLUDE_PATH environment variable. So clang can find it. --- env.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/env.sh b/env.sh index 543054552a3adb..263a76ef7a15d6 100755 --- a/env.sh +++ b/env.sh @@ -80,3 +80,11 @@ if [[ ! "$(printf '%s\n' "$required_ver" "$gcc_ver" | sort -V | head -n1)" = "$r exit 1 fi +# export include path +ABS_DORIS_GCC_HOME=`readlink -f $DORIS_GCC_HOME` +INCLUDE_PATH_1=`locate cstddef | grep $ABS_DORIS_GCC_HOME | tail -1 | xargs dirname` +INCLUDE_PATH_TMP=`locate c++config.h | grep $ABS_DORIS_GCC_HOME | grep -v "32\/bits" | tail -1 | xargs dirname` +INCLUDE_PATH_2=${INCLUDE_PATH_TMP%/bits} +export CPLUS_INCLUDE_PATH=$INCLUDE_PATH_1:$INCLUDE_PATH_2 + + From d13e11d5a79dc10fd3f87377386e6a4932c4013f Mon Sep 17 00:00:00 2001 From: chalsliu Date: Wed, 21 Nov 2018 13:16:08 +0800 Subject: [PATCH 2/2] Compatible with custom toolchain for clang ISSUE #297 1. Find default header file paths of DORIS_GCC_HOME and set as enviroment variable CLANG_COMPATIBLE_FLAGS. 2. Explicitly add these paths to CLANG_INCLUDE_FLAGS. --- be/CMakeLists.txt | 6 ++++++ env.sh | 9 +++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/be/CMakeLists.txt b/be/CMakeLists.txt index cef376787cc85c..3db6acaf6920b3 100644 --- a/be/CMakeLists.txt +++ b/be/CMakeLists.txt @@ -408,7 +408,12 @@ message(STATUS "${LINUX_VERSION_LOWER}") # message(FATAL_ERROR "Currently not support system ${LINUX_VERSION}") # endif() +if(DEFINED ENV{CLANG_COMPATIBLE_FLAGS}) + set(CLANG_COMPATIBLE_FLAGS $ENV{CLANG_COMPATIBLE_FLAGS}) +endif() + message(STATUS "CLANG_BASE_FLAGS: ${CLANG_BASE_FLAGS}") +message(STATUS "CLANG_COMPATIBLE_FLAGS: ${CLANG_COMPATIBLE_FLAGS}") set(CLANG_INCLUDE_FLAGS "-I${LLVM_HOME}/include" @@ -419,6 +424,7 @@ set(CLANG_INCLUDE_FLAGS "-I${THIRDPARTY_DIR}/include/event/" "-I${GPERFTOOLS_HOME}/include" ${CLANG_BASE_FLAGS} + ${CLANG_COMPATIBLE_FLAGS} ) # Set include dirs diff --git a/env.sh b/env.sh index 263a76ef7a15d6..6c817685b0051e 100755 --- a/env.sh +++ b/env.sh @@ -80,11 +80,8 @@ if [[ ! "$(printf '%s\n' "$required_ver" "$gcc_ver" | sort -V | head -n1)" = "$r exit 1 fi -# export include path -ABS_DORIS_GCC_HOME=`readlink -f $DORIS_GCC_HOME` -INCLUDE_PATH_1=`locate cstddef | grep $ABS_DORIS_GCC_HOME | tail -1 | xargs dirname` -INCLUDE_PATH_TMP=`locate c++config.h | grep $ABS_DORIS_GCC_HOME | grep -v "32\/bits" | tail -1 | xargs dirname` -INCLUDE_PATH_2=${INCLUDE_PATH_TMP%/bits} -export CPLUS_INCLUDE_PATH=$INCLUDE_PATH_1:$INCLUDE_PATH_2 +# export CLANG COMPATIBLE FLAGS +export CLANG_COMPATIBLE_FLAGS=`echo | ${DORIS_GCC_HOME}/bin/gcc -Wp,-v -xc++ - -fsyntax-only 2>&1 \ + | grep -E '^\s+/' | awk '{print "-I" $1}' | tr '\n' ' '`