mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-11 08:52:06 +00:00
4c043301e6
This will fix with issues like this [1]:
Aug 12 09:58:44 '/usr/bin/cmake' '--build' '/build/build_docker/native' '--target' 'pre_compressor'
Aug 12 09:58:44 sccache: error: Server startup failed: cache storage failed to read: Unexpected (temporary) at stat
Aug 12 09:58:45 ninja: build stopped: subcommand failed.
Aug 12 09:58:45 -- Configuring done (77.7s)
Aug 12 09:58:47 -- Generating done (1.8s)
Aug 12 09:58:47 -- Build files have been written to: /build/build_docker
So as you can see even if ninja fails it still wrote build files, while
it should fail.
[1]: https://s3.amazonaws.com/clickhouse-test-reports/64955/0af41e32a5822d25ac3760f1ebb2313557474701/builds/report.html
[2]: 0af41e32a5/binary_darwin_aarch64/build_log.log
Note, COMMAND_ERROR_IS_FATAL is 3.19+, and the requirement for now is
3.20
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
60 lines
2.1 KiB
CMake
60 lines
2.1 KiB
CMake
# Set standard, system and compiler libraries explicitly.
|
|
# This is intended for more control of what we are linking.
|
|
|
|
set (DEFAULT_LIBS "-nodefaultlibs")
|
|
|
|
# We need builtins from Clang's RT even without libcxx - for ubsan+int128.
|
|
# See https://bugs.llvm.org/show_bug.cgi?id=16404
|
|
execute_process (COMMAND
|
|
${CMAKE_CXX_COMPILER} --target=${CMAKE_CXX_COMPILER_TARGET} --print-libgcc-file-name --rtlib=compiler-rt
|
|
OUTPUT_VARIABLE BUILTINS_LIBRARY
|
|
COMMAND_ERROR_IS_FATAL ANY
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
# Apparently, in clang-19, the UBSan support library for C++ was moved out into ubsan_standalone_cxx.a, so we have to include both.
|
|
if (SANITIZE STREQUAL undefined)
|
|
string(REPLACE "builtins.a" "ubsan_standalone_cxx.a" EXTRA_BUILTINS_LIBRARY "${BUILTINS_LIBRARY}")
|
|
endif ()
|
|
|
|
if (NOT EXISTS "${BUILTINS_LIBRARY}")
|
|
set (BUILTINS_LIBRARY "-lgcc")
|
|
endif ()
|
|
|
|
if (OS_ANDROID)
|
|
# pthread and rt are included in libc
|
|
set (DEFAULT_LIBS "${DEFAULT_LIBS} ${BUILTINS_LIBRARY} ${EXTRA_BUILTINS_LIBRARY} ${COVERAGE_OPTION} -lc -lm -ldl")
|
|
elseif (USE_MUSL)
|
|
set (DEFAULT_LIBS "${DEFAULT_LIBS} ${BUILTINS_LIBRARY} ${EXTRA_BUILTINS_LIBRARY} ${COVERAGE_OPTION} -static -lc")
|
|
else ()
|
|
set (DEFAULT_LIBS "${DEFAULT_LIBS} ${BUILTINS_LIBRARY} ${EXTRA_BUILTINS_LIBRARY} ${COVERAGE_OPTION} -lc -lm -lrt -lpthread -ldl")
|
|
endif ()
|
|
|
|
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/unwind.cmake)
|
|
include (cmake/cxx.cmake)
|
|
|
|
if (NOT OS_ANDROID)
|
|
if (NOT USE_MUSL)
|
|
# Our compatibility layer doesn't build under Android, many errors in musl.
|
|
add_subdirectory(base/glibc-compatibility)
|
|
endif ()
|
|
add_subdirectory(base/harmful)
|
|
endif ()
|
|
|
|
link_libraries(global-group)
|
|
|
|
target_link_libraries(global-group INTERFACE
|
|
-Wl,--start-group
|
|
$<TARGET_PROPERTY:global-libs,INTERFACE_LINK_LIBRARIES>
|
|
-Wl,--end-group
|
|
)
|