Skip to content

Commit

Permalink
[Tool] Fix function glibc dispatch error (StarRocks#50790)
Browse files Browse the repository at this point in the history
Signed-off-by: stdpain <[email protected]>
  • Loading branch information
stdpain authored Sep 9, 2024
1 parent 406787f commit 8f128b8
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 15 deletions.
14 changes: 12 additions & 2 deletions be/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -989,8 +989,18 @@ set (TEST_LINK_LIBS ${STARROCKS_LINK_LIBS}
# Only build static libs
set(BUILD_SHARED_LIBS OFF)

if (NOT $ENV{STARROCKS_LINKER} STREQUAL "")
add_link_options("-fuse-ld=$ENV{STARROCKS_LINKER}")
set (STARROCKS_LINKER "$ENV{STARROCKS_LINKER}")
include(cmake_modules/FindGlibcVersion.cmake)

if (GLIBC_VERSION VERSION_LESS "2.29" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 14.0.0)
if (NOT DEFINED ${STARROCKS_LINKER} OR ${STARROCKS_LINKER} STREQUAL "")
set(STARROCKS_LINKER "gold")
endif()
endif()
message("using linker: ${STARROCKS_LINKER}")

if (NOT STARROCKS_LINKER STREQUAL "")
add_link_options("-fuse-ld=${STARROCKS_LINKER}")
endif ()

if (${MAKE_TEST} STREQUAL "ON")
Expand Down
30 changes: 17 additions & 13 deletions be/cmake_modules/FindClangTidy.cmake
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
option(WITH_CLANG_TIDY "Use clang-tidy static analyzer" OFF)

if (${WITH_CLANG_TIDY})
find_program (CLANG_TIDY_CACHE_BIN NAMES "clang-tidy-cache")
find_program (CLANG_TIDY_BIN NAMES "clang-tidy-17" "clang-tidy-16" "clang-tidy-15" "clang-tidy-14" "clang-tidy-13" "clang-tidy")
if(${WITH_CLANG_TIDY})
find_program(CLANG_TIDY_CACHE_BIN NAMES "clang-tidy-cache")
find_program(
CLANG_TIDY_BIN NAMES "clang-tidy-17" "clang-tidy-16" "clang-tidy-15"
"clang-tidy-14" "clang-tidy-13" "clang-tidy")

if (CLANG_TIDY_CACHE_BIN)
set (CLANG_TIDY_PATH "${CLANG_TIDY_CACHE_BIN};${CLANG_TIDY_BIN}" CACHE STRING "Cache for clang-tidy")
else()
set (CLANG_TIDY_PATH "${CLANG_TIDY_BIN}")
endif ()
if(CLANG_TIDY_CACHE_BIN)
set(CLANG_TIDY_PATH
"${CLANG_TIDY_CACHE_BIN};${CLANG_TIDY_BIN}"
CACHE STRING "Cache for clang-tidy")
else()
set(CLANG_TIDY_PATH "${CLANG_TIDY_BIN}")
endif()

if (CLANG_TIDY_PATH)
message (STATUS "Find clang-tidy: ${CLANG_TIDY_PATH}.")
else ()
message (FATAL_ERROR "clang-tidy is not found")
endif ()
if(CLANG_TIDY_PATH)
message(STATUS "Find clang-tidy: ${CLANG_TIDY_PATH}.")
else()
message(FATAL_ERROR "clang-tidy is not found")
endif()
endif()
25 changes: 25 additions & 0 deletions be/cmake_modules/FindGlibcVersion.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# check glibc version, assign to GLIBC_VERSION

set(CHECK_C_SOURCE_CODE
"
#include <stdio.h>
#include <gnu/libc-version.h>
int main() {
const char* version = gnu_get_libc_version();
printf(\"%s\\n\", version);
return 0;
}
")
file(WRITE ${CMAKE_BINARY_DIR}/check_c_source.c "${CHECK_C_SOURCE_CODE}")
execute_process(
COMMAND ${CMAKE_C_COMPILER} ${CMAKE_BINARY_DIR}/check_c_source.c -o
${CMAKE_BINARY_DIR}/check_c_source RESULT_VARIABLE compile_result)
if(compile_result EQUAL 0)
execute_process(
COMMAND ${CMAKE_BINARY_DIR}/check_c_source
OUTPUT_VARIABLE GLIBC_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
message("GLIBC version: ${GLIBC_VERSION}")
else()
message(FATAL_ERROR "Failed to get the glibc version")
endif()

0 comments on commit 8f128b8

Please sign in to comment.