diff --git a/dbms/src/Common/TiFlashBuildInfo.cpp b/dbms/src/Common/TiFlashBuildInfo.cpp index b18fb63d93e..ff46e04384d 100644 --- a/dbms/src/Common/TiFlashBuildInfo.cpp +++ b/dbms/src/Common/TiFlashBuildInfo.cpp @@ -95,6 +95,11 @@ std::string getEnabledFeatures() #else "unwind", #endif +#endif + +// THINLTO +#if ENABLE_THINLTO + "thinlto", #endif }; return fmt::format("{}", fmt::join(features.begin(), features.end(), " ")); diff --git a/libs/libcommon/include/common/config_common.h.in b/libs/libcommon/include/common/config_common.h.in index e11ec418e7c..46f167ea683 100644 --- a/libs/libcommon/include/common/config_common.h.in +++ b/libs/libcommon/include/common/config_common.h.in @@ -13,3 +13,4 @@ #cmakedefine01 ENABLE_FAILPOINTS #cmakedefine01 USE_UNWIND #cmakedefine01 USE_LLVM_LIBUNWIND +#cmakedefine01 ENABLE_THINLTO diff --git a/release-centos7-llvm/scripts/build-tiflash-release.sh b/release-centos7-llvm/scripts/build-tiflash-release.sh index d3eda1dff4e..bb62e4743f6 100755 --- a/release-centos7-llvm/scripts/build-tiflash-release.sh +++ b/release-centos7-llvm/scripts/build-tiflash-release.sh @@ -13,12 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. - CMAKE_BUILD_TYPE=$1 CMAKE_PREFIX_PATH=$2 if [[ -z ${CMAKE_BUILD_TYPE} ]]; then - CMAKE_BUILD_TYPE="RELWITHDEBINFO" + CMAKE_BUILD_TYPE="RELWITHDEBINFO" fi DEFAULT_CMAKE_PREFIX_PATH="/usr/local/" @@ -27,15 +26,22 @@ DEFINE_CMAKE_PREFIX_PATH="-DCMAKE_PREFIX_PATH=${DEFAULT_CMAKE_PREFIX_PATH}" # https://cmake.org/cmake/help/latest/variable/CMAKE_PREFIX_PATH.html # CMAKE_PREFIX_PATH should be semicolon-separated list if [[ ${CMAKE_PREFIX_PATH} ]]; then - DEFINE_CMAKE_PREFIX_PATH="-DCMAKE_PREFIX_PATH=\"${DEFAULT_CMAKE_PREFIX_PATH};${CMAKE_PREFIX_PATH}\"" - echo "CMAKE_PREFIX_PATH is \"${DEFAULT_CMAKE_PREFIX_PATH};${CMAKE_PREFIX_PATH}\"" + DEFINE_CMAKE_PREFIX_PATH="-DCMAKE_PREFIX_PATH=\"${DEFAULT_CMAKE_PREFIX_PATH};${CMAKE_PREFIX_PATH}\"" + echo "CMAKE_PREFIX_PATH is \"${DEFAULT_CMAKE_PREFIX_PATH};${CMAKE_PREFIX_PATH}\"" fi set -ueox pipefail -SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )" -SRCPATH=$(cd ${SCRIPTPATH}/../..; pwd -P) +SCRIPTPATH="$( + cd "$(dirname "$0")" + pwd -P +)" +SRCPATH=$( + cd ${SCRIPTPATH}/../.. + pwd -P +) NPROC=${NPROC:-$(nproc || grep -c ^processor /proc/cpuinfo)} +ENABLE_THINLTO=${ENABLE_THINLTO:-ON} INSTALL_DIR="${SRCPATH}/release-centos7-llvm/tiflash" rm -rf ${INSTALL_DIR} && mkdir -p ${INSTALL_DIR} @@ -43,14 +49,17 @@ rm -rf ${INSTALL_DIR} && mkdir -p ${INSTALL_DIR} BUILD_DIR="${SRCPATH}/release-centos7-llvm/build-release" rm -rf ${BUILD_DIR} && mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR} -cmake "${SRCPATH}" ${DEFINE_CMAKE_PREFIX_PATH} \ - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \ - -DENABLE_TESTING=OFF \ - -DENABLE_TESTS=OFF \ - -Wno-dev \ - -DUSE_CCACHE=OFF \ - -DRUN_HAVE_STD_REGEX=0 \ - -GNinja +cmake -S "${SRCPATH}" \ + ${DEFINE_CMAKE_PREFIX_PATH} \ + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \ + -DENABLE_TESTING=OFF \ + -DENABLE_TESTS=OFF \ + -Wno-dev \ + -DUSE_CCACHE=OFF \ + -DRUN_HAVE_STD_REGEX=0 \ + -DENABLE_THINLTO=${ENABLE_THINLTO} \ + -DTHINLTO_JOBS=${NPROC} \ + -GNinja cmake --build . --target tiflash --parallel ${NPROC} cmake --install . --component=tiflash-release --prefix="${INSTALL_DIR}" @@ -59,4 +68,3 @@ cmake --install . --component=tiflash-release --prefix="${INSTALL_DIR}" unset LD_LIBRARY_PATH readelf -d "${INSTALL_DIR}/tiflash" ldd "${INSTALL_DIR}/tiflash" -