From 8840aa924274d76199fdd1b4662c6c0500648a01 Mon Sep 17 00:00:00 2001 From: Robert Schulze Date: Mon, 6 Feb 2023 16:55:07 +0000 Subject: [PATCH] Fix build with -DENABLE_LIBURING=0 (or -DENABLE_LIBRARIES=0) Follow-up to #38456 The problem was that code which uses liburing was conditionally build depending on define OS_LINUX and not based on whether liburing was enabled/disabled at build time. --- src/Common/config.h.in | 1 + src/Disks/IO/IOUringReader.cpp | 5 +++-- src/Disks/IO/IOUringReader.h | 5 ++++- src/Disks/IO/createReadBufferFromFileBase.cpp | 4 ++-- src/Storages/System/StorageSystemBuildOptions.cpp.in | 1 + src/configure_config.cmake | 3 +++ 6 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/Common/config.h.in b/src/Common/config.h.in index baa480a6545..36dfd13534e 100644 --- a/src/Common/config.h.in +++ b/src/Common/config.h.in @@ -29,6 +29,7 @@ #cmakedefine01 USE_FASTOPS #cmakedefine01 USE_NLP #cmakedefine01 USE_VECTORSCAN +#cmakedefine01 USE_LIBURING #cmakedefine01 USE_AVRO #cmakedefine01 USE_CAPNP #cmakedefine01 USE_PARQUET diff --git a/src/Disks/IO/IOUringReader.cpp b/src/Disks/IO/IOUringReader.cpp index 3c6e7d415c7..7bf1982d515 100644 --- a/src/Disks/IO/IOUringReader.cpp +++ b/src/Disks/IO/IOUringReader.cpp @@ -1,6 +1,7 @@ -#if defined(OS_LINUX) - #include "IOUringReader.h" + +#if USE_LIBURING + #include #include #include diff --git a/src/Disks/IO/IOUringReader.h b/src/Disks/IO/IOUringReader.h index beba3636ca7..e3fcf116448 100644 --- a/src/Disks/IO/IOUringReader.h +++ b/src/Disks/IO/IOUringReader.h @@ -1,5 +1,8 @@ #pragma once -#if defined(OS_LINUX) + +#include "config.h" + +#if USE_LIBURING #include #include diff --git a/src/Disks/IO/createReadBufferFromFileBase.cpp b/src/Disks/IO/createReadBufferFromFileBase.cpp index 47625705a10..d4ee53a4066 100644 --- a/src/Disks/IO/createReadBufferFromFileBase.cpp +++ b/src/Disks/IO/createReadBufferFromFileBase.cpp @@ -7,7 +7,7 @@ #include #include #include - +#include "config.h" namespace ProfileEvents { @@ -84,7 +84,7 @@ std::unique_ptr createReadBufferFromFileBase( } else if (settings.local_fs_method == LocalFSReadMethod::io_uring) { -#if defined(OS_LINUX) +#if USE_LIBURING static std::shared_ptr reader = std::make_shared(512); if (!reader->isSupported()) throw Exception(ErrorCodes::UNSUPPORTED_METHOD, "io_uring is not supported by this system"); diff --git a/src/Storages/System/StorageSystemBuildOptions.cpp.in b/src/Storages/System/StorageSystemBuildOptions.cpp.in index fd4e478004f..3465e47449b 100644 --- a/src/Storages/System/StorageSystemBuildOptions.cpp.in +++ b/src/Storages/System/StorageSystemBuildOptions.cpp.in @@ -51,6 +51,7 @@ const char * auto_config_build[] "USE_ROCKSDB", "@USE_ROCKSDB@", "USE_NURAFT", "@USE_NURAFT@", "USE_NLP", "@USE_NLP@", + "USE_LIBURING", "@USE_LIBURING@", "USE_SQLITE", "@USE_SQLITE@", "USE_LIBPQXX", "@USE_LIBPQXX@", "USE_AZURE_BLOB_STORAGE", "@USE_AZURE_BLOB_STORAGE@", diff --git a/src/configure_config.cmake b/src/configure_config.cmake index 58cb34b7d67..fe298855bcd 100644 --- a/src/configure_config.cmake +++ b/src/configure_config.cmake @@ -129,6 +129,9 @@ if (TARGET ch_contrib::parquet) set(USE_ARROW 1) set(USE_ORC 1) endif() +if (TARGET ch_contrib::liburing) + set(USE_LIBURING 1) +endif () if (TARGET ch_contrib::protobuf) set(USE_PROTOBUF 1) endif()