Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable LTO in release build process #4924

Merged
merged 9 commits into from
May 23, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions dbms/src/Common/TiFlashBuildInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(), " "));
Expand Down
1 change: 1 addition & 0 deletions libs/libcommon/include/common/config_common.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
#cmakedefine01 ENABLE_FAILPOINTS
#cmakedefine01 USE_UNWIND
#cmakedefine01 USE_LLVM_LIBUNWIND
#cmakedefine01 ENABLE_THINLTO
38 changes: 23 additions & 15 deletions release-centos7-llvm/scripts/build-tiflash-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand All @@ -27,30 +26,40 @@ 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}

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}"
Expand All @@ -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"