2019-08-28 20:49:37 +00:00
|
|
|
if (GLIBC_COMPATIBILITY)
|
2021-03-02 19:09:37 +00:00
|
|
|
add_subdirectory(memcpy)
|
2021-03-13 19:39:10 +00:00
|
|
|
if(TARGET memcpy)
|
|
|
|
set(MEMCPY_LIBRARY memcpy)
|
|
|
|
endif()
|
2020-10-01 07:38:06 +00:00
|
|
|
|
2019-08-28 20:49:37 +00:00
|
|
|
enable_language(ASM)
|
|
|
|
include(CheckIncludeFile)
|
2018-06-18 21:14:17 +00:00
|
|
|
|
2019-08-28 20:49:37 +00:00
|
|
|
check_include_file("sys/random.h" HAVE_SYS_RANDOM_H)
|
2019-04-11 19:28:29 +00:00
|
|
|
|
2019-08-28 20:49:37 +00:00
|
|
|
add_headers_and_sources(glibc_compatibility .)
|
|
|
|
add_headers_and_sources(glibc_compatibility musl)
|
2021-05-08 12:24:04 +00:00
|
|
|
if (ARCH_AARCH64)
|
2019-10-13 16:06:54 +00:00
|
|
|
list (APPEND glibc_compatibility_sources musl/aarch64/syscall.s musl/aarch64/longjmp.s)
|
|
|
|
set (musl_arch_include_dir musl/aarch64)
|
|
|
|
elseif (ARCH_AMD64)
|
|
|
|
list (APPEND glibc_compatibility_sources musl/x86_64/syscall.s musl/x86_64/longjmp.s)
|
|
|
|
set (musl_arch_include_dir musl/x86_64)
|
|
|
|
else ()
|
|
|
|
message (FATAL_ERROR "glibc_compatibility can only be used on x86_64 or aarch64.")
|
|
|
|
endif ()
|
2019-04-11 19:28:29 +00:00
|
|
|
|
2019-08-28 20:49:37 +00:00
|
|
|
list(REMOVE_ITEM glibc_compatibility_sources musl/getentropy.c)
|
|
|
|
if(HAVE_SYS_RANDOM_H)
|
|
|
|
list(APPEND glibc_compatibility_sources musl/getentropy.c)
|
|
|
|
endif()
|
2018-09-14 00:00:24 +00:00
|
|
|
|
2019-12-09 13:25:54 +00:00
|
|
|
# Need to omit frame pointers to match the performance of glibc
|
|
|
|
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fomit-frame-pointer")
|
|
|
|
|
2019-08-28 20:49:37 +00:00
|
|
|
add_library(glibc-compatibility STATIC ${glibc_compatibility_sources})
|
|
|
|
|
2021-08-16 00:16:45 +00:00
|
|
|
target_no_warning(glibc-compatibility unused-command-line-argument)
|
|
|
|
target_no_warning(glibc-compatibility unused-but-set-variable)
|
|
|
|
target_no_warning(glibc-compatibility builtin-requires-header)
|
2019-12-15 06:18:08 +00:00
|
|
|
|
2019-10-13 16:06:54 +00:00
|
|
|
target_include_directories(glibc-compatibility PRIVATE libcxxabi ${musl_arch_include_dir})
|
2019-08-28 20:49:37 +00:00
|
|
|
|
2022-12-06 22:17:53 +00:00
|
|
|
if (( NOT USE_STATIC_LIBRARIES AND NOT USE_STATIC_LIBRARIES ) OR ENABLE_OPENSSL_DYNAMIC)
|
2019-09-17 10:37:35 +00:00
|
|
|
target_compile_options(glibc-compatibility PRIVATE -fPIC)
|
2019-08-28 20:49:37 +00:00
|
|
|
endif ()
|
|
|
|
|
2021-03-13 19:39:10 +00:00
|
|
|
target_link_libraries(global-libs INTERFACE glibc-compatibility ${MEMCPY_LIBRARY})
|
2019-08-28 20:49:37 +00:00
|
|
|
|
|
|
|
install(
|
2021-03-13 19:39:10 +00:00
|
|
|
TARGETS glibc-compatibility ${MEMCPY_LIBRARY}
|
2019-08-28 20:49:37 +00:00
|
|
|
EXPORT global
|
|
|
|
ARCHIVE DESTINATION lib
|
|
|
|
)
|
|
|
|
|
|
|
|
message (STATUS "Some symbols from glibc will be replaced for compatibility")
|
2021-03-02 19:09:37 +00:00
|
|
|
|
2022-03-28 13:53:22 +00:00
|
|
|
elseif (CLICKHOUSE_OFFICIAL_BUILD)
|
2019-08-28 20:49:37 +00:00
|
|
|
message (WARNING "Option GLIBC_COMPATIBILITY must be turned on for production builds.")
|
|
|
|
endif ()
|