add liburing to build

This commit is contained in:
Saulius Valatka 2022-04-05 16:47:59 +03:00
parent 75b8800b5c
commit 3f755a2505
6 changed files with 149 additions and 0 deletions

3
.gitmodules vendored
View File

@ -268,3 +268,6 @@
[submodule "contrib/hashidsxx"]
path = contrib/hashidsxx
url = https://github.com/schoentoon/hashidsxx.git
[submodule "contrib/liburing"]
path = contrib/liburing
url = https://github.com/axboe/liburing.git

View File

@ -118,6 +118,7 @@ add_contrib (simdjson-cmake simdjson)
add_contrib (rapidjson-cmake rapidjson)
add_contrib (fastops-cmake fastops)
add_contrib (libuv-cmake libuv)
add_contrib (liburing-cmake liburing)
add_contrib (amqpcpp-cmake AMQP-CPP) # requires: libuv
add_contrib (cassandra-cmake cassandra) # requires: libuv

1
contrib/liburing vendored Submodule

@ -0,0 +1 @@
Subproject commit ecf66cc2a49c69e9c9d224ef54b95082844a7b7a

View File

@ -0,0 +1,99 @@
set (ENABLE_LIBURING_DEFAULT ${ENABLE_LIBRARIES})
if (NOT OS_LINUX)
set (ENABLE_LIBURING_DEFAULT OFF)
endif ()
option (ENABLE_LIBURING "Enable liburing" ${ENABLE_LIBURING_DEFAULT})
if (NOT ENABLE_LIBURING)
message(STATUS "Not using liburing")
return()
endif()
set (LIBURING_INCLUDE_DIR "${ClickHouse_SOURCE_DIR}/contrib/liburing/src/include")
set (LIBURING_SOURCE_DIR "${ClickHouse_SOURCE_DIR}/contrib/liburing/src")
set (SRCS
"${LIBURING_SOURCE_DIR}/queue.c"
"${LIBURING_SOURCE_DIR}/register.c"
"${LIBURING_SOURCE_DIR}/setup.c"
"${LIBURING_SOURCE_DIR}/syscall.c"
)
set (LIBURING_COMPAT_INCLUDE_DIR "${ClickHouse_BINARY_DIR}/contrib/liburing/src/include-compat")
set (LIBURING_COMPAT_HEADER "${LIBURING_COMPAT_INCLUDE_DIR}/liburing/compat.h")
include(CheckCSourceCompiles)
# The below checks should run against the bundled contrib/libc-headers
set (CMAKE_REQUIRED_INCLUDES ${CMAKE_C_STANDARD_INCLUDE_DIRECTORIES})
check_c_source_compiles ("
#include <linux/fs.h>
int main(int argc, char **argv)
{
__kernel_rwf_t x;
x = 0;
return x;
}" LIBURING_CONFIG_HAS_KERNEL_RWF_T)
check_c_source_compiles ("
#include <linux/time.h>
#include <linux/time_types.h>
int main(int argc, char **argv)
{
struct __kernel_timespec ts;
ts.tv_sec = 0;
ts.tv_nsec = 1;
return 0;
}" LIBURING_CONFIG_HAS_KERNEL_TIMESPEC)
check_c_source_compiles ("
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
int main(int argc, char **argv)
{
struct open_how how;
how.flags = 0;
how.mode = 0;
how.resolve = 0;
return 0;
}" LIBURING_CONFIG_HAS_OPEN_HOW)
check_c_source_compiles ("
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <linux/stat.h>
int main(int argc, char **argv)
{
struct statx x;
return memset(&x, 0, sizeof(x)) != NULL;
}" LIBURING_CONFIG_HAS_STATX)
check_c_source_compiles ("
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <linux/stat.h>
int main(int argc, char **argv)
{
struct statx x;
return memset(&x, 0, sizeof(x)) != NULL;
}" LIBURING_CONFIG_HAS_GLIBC_STATX)
unset (CMAKE_REQUIRED_INCLUDES)
add_compile_definitions(LIBURING_INTERNAL)
configure_file (compat.h.in ${LIBURING_COMPAT_HEADER})
add_library (_liburing ${SRCS})
add_library (ch_contrib::liburing ALIAS _liburing)
target_include_directories (_liburing PUBLIC ${LIBURING_COMPAT_INCLUDE_DIR} "${LIBURING_SOURCE_DIR}/include")

View File

@ -0,0 +1,40 @@
/* SPDX-License-Identifier: MIT */
#ifndef LIBURING_COMPAT_H
#define LIBURING_COMPAT_H
# cmakedefine LIBURING_CONFIG_HAS_KERNEL_RWF_T
# cmakedefine LIBURING_CONFIG_HAS_KERNEL_TIMESPEC
# cmakedefine LIBURING_CONFIG_HAS_OPEN_HOW
# cmakedefine LIBURING_CONFIG_HAS_GLIBC_STATX
# cmakedefine LIBURING_CONFIG_HAS_STATX
#if !defined(LIBURING_CONFIG_HAS_KERNEL_RWF_T)
typedef int __kernel_rwf_t;
#endif
#if !defined(LIBURING_CONFIG_HAS_KERNEL_TIMESPEC)
#include <stdint.h>
struct __kernel_timespec {
int64_t tv_sec;
long long tv_nsec;
};
#else
#include <linux/time_types.h>
#endif
#if !defined(LIBURING_CONFIG_HAS_OPEN_HOW)
#include <inttypes.h>
struct open_how {
uint64_t flags;
uint64_t mode;
uint64_t resolve;
};
#endif
#if !defined(LIBURING_CONFIG_HAS_GLIBC_STATX) && defined(LIBURING_CONFIG_HAS_STATX)
#include <sys/stat.h>
#endif
#endif

View File

@ -498,6 +498,11 @@ if (TARGET ch_contrib::msgpack)
target_link_libraries (clickhouse_common_io PUBLIC ch_contrib::msgpack)
endif()
if (TARGET ch_contrib::liburing)
target_link_libraries (clickhouse_common_io PUBLIC ch_contrib::liburing)
target_include_directories (clickhouse_common_io SYSTEM BEFORE PUBLIC ${LIBURING_COMPAT_INCLUDE_DIR} ${LIBURING_INCLUDE_DIR})
endif()
target_link_libraries (clickhouse_common_io PUBLIC ch_contrib::fast_float)
if (USE_ORC)