Skip to content

Commit

Permalink
Fix problems introduced by symbolization (#4334)
Browse files Browse the repository at this point in the history
close #4333
  • Loading branch information
SchrodingerZhu authored Mar 18, 2022
1 parent 706d7c3 commit f48d803
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 15 deletions.
11 changes: 7 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY true)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${TiFlash_SOURCE_DIR}/cmake/Modules/")
set(CMAKE_MACOSX_RPATH 1)

# Rust jobs may modify global toolchain settings. We make rust related jobs sequentially scheduled
# by putting them in a job pool with single concurrency.
set_property(GLOBAL PROPERTY JOB_POOLS rust_job_pool=1)

option(TIFLASH_ENABLE_LLVM_DEVELOPMENT "enable facilities for development with LLVM" OFF)

if(CMAKE_PREFIX_PATH)
Expand Down Expand Up @@ -442,3 +438,10 @@ add_subdirectory (dbms)

include (cmake/print_include_directories.cmake)

# Building a rust project may require setting up toolchains. Rustup cannot handle parallel requests, hence it may fail to
# finish the setup if multiple projects want to install a same version. To mitigate the situation, we force cargo targets
# to be invoked sequentially by adding linear dependency relations between them.
# Another way to do so is to use JOB_POOL with single concurrency. However, it is Ninja specific and it seems to have bugs
# with a large number of threads.
include (cmake/sequential.cmake)
build_sequentially (symbolization tiflash_proxy)
4 changes: 4 additions & 0 deletions cmake/find_tiflash_proxy.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,7 @@ endif()
set(TIFLASH_PROXY_FOUND TRUE)

message(STATUS "Using tiflash proxy: ${USE_INTERNAL_TIFLASH_PROXY} : ${TIFLASH_PROXY_INCLUDE_DIR}, ${TIFLASH_PROXY_LIBRARY}")

if (NOT USE_INTERNAL_TIFLASH_PROXY)
add_custom_target(tiflash_proxy ALL DEPENDS ${TIFLASH_PROXY_LIBRARY})
endif()
20 changes: 20 additions & 0 deletions cmake/sequential.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

## Mark targets to build sequentially
# Example: build_sequentially(a, b, c, d)
# a -> b -> c -> d
function(build_sequentially target1 target2)
add_dependencies(${target2} ${target1})
if(${ARGC} GREATER 2)
build_sequentially(${target2} ${ARGN})
endif()
endfunction()
3 changes: 1 addition & 2 deletions contrib/tiflash-proxy-cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ add_custom_command(OUTPUT ${_TIFLASH_PROXY_LIBRARY}
DEPENDS "${_TIFLASH_PROXY_SRCS}" "${_TIFLASH_PROXY_SOURCE_DIR}/Cargo.lock" "${_TIFLASH_PROXY_SOURCE_DIR}/rust-toolchain")

add_custom_target(tiflash_proxy ALL
DEPENDS ${_TIFLASH_PROXY_LIBRARY}
JOB_POOL rust_job_pool)
DEPENDS ${_TIFLASH_PROXY_LIBRARY})

add_library(libtiflash_proxy SHARED IMPORTED GLOBAL)
set_target_properties(libtiflash_proxy PROPERTIES IMPORTED_LOCATION ${_TIFLASH_PROXY_LIBRARY} IMPORTED_NO_SONAME ON)
Expand Down
2 changes: 1 addition & 1 deletion libs/libdaemon/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ endif ()
target_include_directories (daemon PUBLIC include)
target_include_directories (daemon PRIVATE ${TiFlash_SOURCE_DIR}/libs/libpocoext/include)

target_link_libraries (daemon clickhouse_common_io clickhouse_common_config ${EXECINFO_LIBRARY} symbolization)
target_link_libraries (daemon clickhouse_common_io clickhouse_common_config ${EXECINFO_LIBRARY} libsymbolization)
target_compile_definitions(daemon PRIVATE -DTIFLASH_SOURCE_PREFIX=\"${TiFlash_SOURCE_DIR}\")
if (ENABLE_TESTS)
add_subdirectory (src/tests EXCLUDE_FROM_ALL)
Expand Down
7 changes: 4 additions & 3 deletions libs/libdaemon/src/BaseDaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,19 +543,20 @@ class SignalListener : public Poco::Runnable
if (already_printed_stack_trace)
return;

static const int max_frames = 50;
static constexpr int max_frames = 50;
int frames_size = 0;
void * frames[max_frames];

#if USE_UNWIND
int frames_size = backtraceLibUnwind(frames, max_frames, unw_context);
frames_size = backtraceLibUnwind(frames, max_frames, unw_context);
UNUSED(caller_address);
#else
/// No libunwind means no backtrace, because we are in a different thread from the one where the signal happened.
/// So at least print the function where the signal happened.
if (caller_address)
{
frames[0] = caller_address;
int frames_size = 1;
frames_size = 1;
}
#endif

Expand Down
10 changes: 5 additions & 5 deletions libs/libsymbolization/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ add_custom_command(OUTPUT ${_SYMBOLIZATION_LIBRARY}
"${_SYMBOLIZATION_SOURCE_DIR}/Cargo.toml"
"${_SYMBOLIZATION_SOURCE_DIR}/rust-toolchain")

add_custom_target(_symbolization ALL DEPENDS ${_SYMBOLIZATION_LIBRARY} JOB_POOL rust_job_pool)
add_library(symbolization STATIC IMPORTED GLOBAL)
set_target_properties(symbolization PROPERTIES IMPORTED_LOCATION ${_SYMBOLIZATION_LIBRARY})
add_dependencies(symbolization _symbolization)
target_include_directories(symbolization INTERFACE ${_SYMBOLIZATION_SOURCE_DIR}/include)
add_custom_target(symbolization ALL DEPENDS ${_SYMBOLIZATION_LIBRARY})
add_library(libsymbolization STATIC IMPORTED GLOBAL)
set_target_properties(libsymbolization PROPERTIES IMPORTED_LOCATION ${_SYMBOLIZATION_LIBRARY})
add_dependencies(libsymbolization symbolization)
target_include_directories(libsymbolization INTERFACE ${_SYMBOLIZATION_SOURCE_DIR}/include)

0 comments on commit f48d803

Please sign in to comment.