mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 00:22:29 +00:00
c862ae0c42
gcc with -nodefaultlibs does not add sanitizers library during linkage with -static-libasan and similar, fix this, by add them explicitly. From the gcc(1) about -nodefaultlibs: Do not use the standard system libraries when linking. Only the libraries you specify are passed to the linker, and options specifying linkage of the system libraries, such as -static-libgcc or -shared-libgcc, are ignored. The standard startup files are used normally, unless -nostartfiles is used. Plus checked it manually, w/o -nodefaultlibs everything works without this explicit linkage. After this patch UBSAN under gcc compiled successfully. v2: freebsd and darwin
41 lines
1.3 KiB
CMake
41 lines
1.3 KiB
CMake
set (DEFAULT_LIBS "-nodefaultlibs")
|
|
|
|
if (NOT COMPILER_CLANG)
|
|
message (FATAL_ERROR "FreeBSD build is supported only for Clang")
|
|
endif ()
|
|
|
|
if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "amd64")
|
|
execute_process (COMMAND ${CMAKE_CXX_COMPILER} --print-file-name=libclang_rt.builtins-x86_64.a OUTPUT_VARIABLE BUILTINS_LIBRARY OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
else ()
|
|
execute_process (COMMAND ${CMAKE_CXX_COMPILER} --print-file-name=libclang_rt.builtins-${CMAKE_SYSTEM_PROCESSOR}.a OUTPUT_VARIABLE BUILTINS_LIBRARY OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
endif ()
|
|
|
|
set (DEFAULT_LIBS "${DEFAULT_LIBS} ${BUILTINS_LIBRARY} ${COVERAGE_OPTION} -lc -lm -lrt -lpthread")
|
|
|
|
message(STATUS "Default libraries: ${DEFAULT_LIBS}")
|
|
|
|
set(CMAKE_CXX_STANDARD_LIBRARIES ${DEFAULT_LIBS})
|
|
set(CMAKE_C_STANDARD_LIBRARIES ${DEFAULT_LIBS})
|
|
|
|
# Unfortunately '-pthread' doesn't work with '-nodefaultlibs'.
|
|
# Just make sure we have pthreads at all.
|
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
|
find_package(Threads REQUIRED)
|
|
|
|
include (cmake/find/unwind.cmake)
|
|
include (cmake/find/cxx.cmake)
|
|
|
|
add_library(global-group INTERFACE)
|
|
|
|
target_link_libraries(global-group INTERFACE
|
|
$<TARGET_PROPERTY:global-libs,INTERFACE_LINK_LIBRARIES>
|
|
)
|
|
|
|
link_libraries(global-group)
|
|
|
|
# FIXME: remove when all contribs will get custom cmake lists
|
|
install(
|
|
TARGETS global-group global-libs
|
|
EXPORT global
|
|
)
|