Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into bin-push-down
Browse files Browse the repository at this point in the history
  • Loading branch information
An-DJ committed Jul 22, 2022
2 parents d8e3734 + 3ad743b commit ead97da
Show file tree
Hide file tree
Showing 322 changed files with 12,300 additions and 41,885 deletions.
61 changes: 55 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,48 @@ if (COMPILER_CLANG)
endif ()
endif ()

option (ENABLE_LLVM_PROFILE_INSTR "Generate instrumented code to collect execution counts" OFF)
option (ENABLE_LLVM_PGO "Enables flags for Profile Guided Optimization (PGO)" OFF)
option (ENABLE_LLVM_PGO_USE_SAMPLE "Enables flags for Profile Guided Optimization (PGO) and use sampling profilers" OFF)
set (USE_LLVM_FDO OFF CACHE BOOL "" FORCE)

if (ENABLE_LLVM_PGO)
if (ENABLE_LLVM_PROFILE_INSTR)
message (FATAL_ERROR "`ENABLE_LLVM_PROFILE_INSTR` can not be used with `ENABLE_LLVM_PGO`")
endif ()
if (ENABLE_LLVM_PGO_USE_SAMPLE)

# Follow https://clang.llvm.org/docs/UsersManual.html#using-sampling-profilers
# Use https://github.com/google/autofdo

set (_LLVM_PGO_USE_SAMPLE_FLAGS "-gline-tables-only -fdebug-info-for-profiling -funique-internal-linkage-names")

set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_LLVM_PGO_USE_SAMPLE_FLAGS}")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_LLVM_PGO_USE_SAMPLE_FLAGS}")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-rosegment")
message (STATUS "Add flags `${_LLVM_PGO_USE_SAMPLE_FLAGS}` for profiling")

if (NOT "$ENV{TIFLASH_LLVM_PROFDATA}" STREQUAL "")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-sample-use=$ENV{TIFLASH_LLVM_PROFDATA}")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-sample-use=$ENV{TIFLASH_LLVM_PROFDATA}")
message (STATUS "Use sample profile data `$ENV{TIFLASH_LLVM_PROFDATA}` for profile-guided optimization")
set (USE_LLVM_FDO ON CACHE BOOL "" FORCE)
else ()
message (STATUS "NOT use sample profile data")
endif ()

unset (_LLVM_PGO_USE_SAMPLE_FLAGS)
else ()
if ("$ENV{TIFLASH_LLVM_PROFDATA}" STREQUAL "")
message (FATAL_ERROR "Please set env var `TIFLASH_LLVM_PROFDATA`")
endif ()

set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-instr-use=$ENV{TIFLASH_LLVM_PROFDATA} -Wno-profile-instr-unprofiled")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-instr-use=$ENV{TIFLASH_LLVM_PROFDATA} -Wno-profile-instr-unprofiled")
message (STATUS "Use instrumentation data `$ENV{TIFLASH_LLVM_PROFDATA}` for profile-guided optimization")
endif ()
endif ()

if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# clang: warning: argument unused during compilation: '-stdlib=libc++'
# clang: warning: argument unused during compilation: '-specs=/usr/share/dpkg/no-pie-compile.specs' [-Wunused-command-line-argument]
Expand Down Expand Up @@ -201,7 +243,7 @@ endif()
find_program (LLD_PATH NAMES "lld${COMPILER_POSTFIX}" "lld")
find_program (GOLD_PATH NAMES "gold")

if (NOT LINKER_NAME)
if (NOT LINKER_NAME AND NOT APPLE)
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND LLD_PATH)
set (LINKER_NAME "lld")
elseif (GOLD_PATH)
Expand Down Expand Up @@ -239,10 +281,8 @@ else ()
set (CMAKE_CXX_STANDARD_REQUIRED ON)
endif ()

if (NOT ARCH_ARM)
set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O3")
set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -O3")
endif ()
set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O3")
set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -O3")

option (DEBUG_WITHOUT_DEBUG_INFO "Set to ON to build dev target without debug info (remove flag `-g` in order to accelerate compiling speed and reduce target binary size)" OFF)
if (DEBUG_WITHOUT_DEBUG_INFO)
Expand Down Expand Up @@ -399,7 +439,6 @@ option (ENABLE_UNWIND "Enable libunwind (better stacktraces)" ON)
include (libs/libdaemon/cmake/find_unwind.cmake)

# Need to process before "contrib" dir:
include (libs/libcommon/cmake/find_gperftools.cmake)
include (libs/libcommon/cmake/find_jemalloc.cmake)
include (libs/libcommon/cmake/find_mimalloc.cmake)
include (libs/libcommon/cmake/find_cctz.cmake)
Expand Down Expand Up @@ -445,6 +484,16 @@ if (TEST_LLVM_COVERAGE AND CMAKE_BUILD_TYPE_UC STREQUAL "DEBUG")
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-instr-generate -fcoverage-mapping -DTIFLASH_LLVM_COVERAGE=1")
endif ()

# `ENABLE_LLVM_PROFILE_INSTR` will make executable binary generate profile data automatically. Make it only work at modules dbms and libs.
if (ENABLE_LLVM_PROFILE_INSTR)
if (ENABLE_LLVM_PGO)
message (FATAL_ERROR "`ENABLE_LLVM_PROFILE_INSTR` can not be used with `ENABLE_LLVM_PGO`")
endif ()
message (STATUS "Using flag `-fprofile-instr-generate`. Generate instrumented code to collect execution counts into default.profraw file(overridden by '=' form of option or `LLVM_PROFILE_FILE` env var). Follow https://clang.llvm.org/docs/UsersManual.html#profile-guided-optimization.")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-instr-generate")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-instr-generate")
endif ()

if (ARCH_AMD64)
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-mvpclmulqdq -Werror -Wall -Wextra" TIFLASH_COMPILER_VPCLMULQDQ_SUPPORT)
Expand Down
5 changes: 0 additions & 5 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,6 @@ Revision: 21d37dbaa45742c0bd23cc1e5a70b52cbc27f809
Address: https://github.com/ClickHouse/ClickHouse/tree/b13313eecca9455f4fdc923f597fe863df409742/contrib/libsparsehash
License: https://github.com/ClickHouse/ClickHouse/blob/b13313eecca9455f4fdc923f597fe863df409742/contrib/libsparsehash/COPYING
--------------------------------------
tcmalloc
Revision: dde32f8bbc95312379f9f5a651799815bb6327c5
Address: https://github.com/ClickHouse/ClickHouse/tree/b13313eecca9455f4fdc923f597fe863df409742/contrib/libtcmalloc
License: https://github.com/ClickHouse/ClickHouse/blob/b13313eecca9455f4fdc923f597fe863df409742/contrib/libtcmalloc/COPYING
--------------------------------------
libunwind
Revision: 19a2c01b1e8ac20871ea09d20f596d425ba53aed
Address: https://github.com/libunwind/libunwind
Expand Down
75 changes: 0 additions & 75 deletions cmake/Modules/FindGperftools.cmake

This file was deleted.

9 changes: 3 additions & 6 deletions contrib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,6 @@ if (USE_INTERNAL_TIFLASH_PROXY)
add_subdirectory (tiflash-proxy-cmake)
endif ()

# TODO: remove tcmalloc
if (ENABLE_TCMALLOC AND USE_INTERNAL_GPERFTOOLS_LIBRARY)
add_subdirectory (libtcmalloc)
endif ()

if (ENABLE_JEMALLOC AND USE_INTERNAL_JEMALLOC_LIBRARY)
add_subdirectory (jemalloc-cmake)
endif ()
Expand Down Expand Up @@ -164,7 +159,9 @@ SET (BENCHMARK_ENABLE_GTEST_TESTS OFF CACHE BOOL "Disable google-benchmark testi
add_subdirectory(benchmark)

set (BUILD_TESTING OFF CACHE BOOL "Disable cpu-features testing" FORCE)
add_subdirectory(cpu_features)
if (NOT (APPLE AND ARCH_AARCH64))
add_subdirectory(cpu_features)
endif()

if (ARCH_AARCH64 AND ARCH_LINUX)
add_subdirectory(arm-optimized-routines-cmake)
Expand Down
2 changes: 0 additions & 2 deletions contrib/libtcmalloc/AUTHORS

This file was deleted.

81 changes: 0 additions & 81 deletions contrib/libtcmalloc/CMakeLists.txt

This file was deleted.

28 changes: 0 additions & 28 deletions contrib/libtcmalloc/COPYING

This file was deleted.

8 changes: 0 additions & 8 deletions contrib/libtcmalloc/README

This file was deleted.

Loading

0 comments on commit ead97da

Please sign in to comment.