CodeCommitsIssuesPull requestsActionsInsightsSecurity
13852301ae30fc912b4171838ac541ccd60d5366

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

base/glibc-compatibility/CMakeLists.txt

58lines · modecode

1if (GLIBC_COMPATIBILITY)
2 set (ENABLE_FASTMEMCPY ON)
3
4 enable_language(ASM)
5 include(CheckIncludeFile)
6
7 check_include_file("sys/random.h" HAVE_SYS_RANDOM_H)
8
9 if(COMPILER_CLANG)
10 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-builtin-requires-header")
11 endif()
12
13 add_headers_and_sources(glibc_compatibility .)
14 add_headers_and_sources(glibc_compatibility musl)
15 if (ARCH_ARM)
16 list (APPEND glibc_compatibility_sources musl/aarch64/syscall.s musl/aarch64/longjmp.s)
17 set (musl_arch_include_dir musl/aarch64)
18 elseif (ARCH_AMD64)
19 list (APPEND glibc_compatibility_sources musl/x86_64/syscall.s musl/x86_64/longjmp.s)
20 set (musl_arch_include_dir musl/x86_64)
21 else ()
22 message (FATAL_ERROR "glibc_compatibility can only be used on x86_64 or aarch64.")
23 endif ()
24
25 list(REMOVE_ITEM glibc_compatibility_sources musl/getentropy.c)
26 if(HAVE_SYS_RANDOM_H)
27 list(APPEND glibc_compatibility_sources musl/getentropy.c)
28 endif()
29
30 # Need to omit frame pointers to match the performance of glibc
31 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fomit-frame-pointer")
32
33 add_library(glibc-compatibility STATIC ${glibc_compatibility_sources})
34
35 if (COMPILER_CLANG)
36 target_compile_options(glibc-compatibility PRIVATE -Wno-unused-command-line-argument)
37 elseif (COMPILER_GCC)
38 target_compile_options(glibc-compatibility PRIVATE -Wno-unused-but-set-variable)
39 endif ()
40
41 target_include_directories(glibc-compatibility PRIVATE libcxxabi ${musl_arch_include_dir})
42
43 if (NOT USE_STATIC_LIBRARIES AND NOT MAKE_STATIC_LIBRARIES)
44 target_compile_options(glibc-compatibility PRIVATE -fPIC)
45 endif ()
46
47 target_link_libraries(global-libs INTERFACE glibc-compatibility)
48
49 install(
50 TARGETS glibc-compatibility
51 EXPORT global
52 ARCHIVE DESTINATION lib
53 )
54
55 message (STATUS "Some symbols from glibc will be replaced for compatibility")
56elseif (YANDEX_OFFICIAL_BUILD)
57 message (WARNING "Option GLIBC_COMPATIBILITY must be turned on for production builds.")
58endif ()