Skip to content

Commit

Permalink
rocksdb: fix FTBFS on gcc 13
Browse files Browse the repository at this point in the history
This applies two patches to the embedded rocksdb source:
- facebook/rocksdb#11118
- facebook/rocksdb#11137

Fixes: https://tracker.ceph.com/issues/58477
Signed-off-by: Tim Serong <tserong@suse.com>
  • Loading branch information
tserong committed Mar 9, 2023
1 parent 46c0ea2 commit bc407ee
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmake/modules/BuildRocksDB.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# CMAKE_CURRENT_FUNCTION_LIST_DIR is introduced by cmake 3.17, but ubuntu comes with 3.16
set(_build_rocksdb_list_dir "${CMAKE_CURRENT_LIST_DIR}")

function(build_rocksdb)
set(rocksdb_CMAKE_ARGS -DCMAKE_POSITION_INDEPENDENT_CODE=ON)
list(APPEND rocksdb_CMAKE_ARGS -DWITH_GFLAGS=OFF)
Expand Down Expand Up @@ -75,10 +78,12 @@ function(build_rocksdb)
set(make_cmd ${CMAKE_COMMAND} --build <BINARY_DIR> --target rocksdb)
endif()

find_program(PATCH_EXECUTABLE patch)
ExternalProject_Add(rocksdb_ext
SOURCE_DIR "${rocksdb_SOURCE_DIR}"
CMAKE_ARGS ${rocksdb_CMAKE_ARGS}
BINARY_DIR "${rocksdb_BINARY_DIR}"
PATCH_COMMAND ${PATCH_EXECUTABLE} -p1 -i ${_build_rocksdb_list_dir}/rocksdb-gcc-13.patch
BUILD_COMMAND "${make_cmd}"
BUILD_BYPRODUCTS "${rocksdb_LIBRARY}"
INSTALL_COMMAND ""
Expand Down
66 changes: 66 additions & 0 deletions cmake/modules/rocksdb-gcc-13.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
From fe4d03d15e662a195bf28cb1327fbaeb563efb13 Mon Sep 17 00:00:00 2001
From: Heiko Becker <heirecka@exherbo.org>
Date: Tue, 24 Jan 2023 16:23:03 +0100
Subject: [PATCH] Fix build with gcc 13 by including <cstdint>

Like other versions before, gcc 13 moved some includes around and as a
result <cstdint> is no longer transitively included [1]. Explicitly include
it for uint{32,64}_t.

[1] https://gcc.gnu.org/gcc-13/porting_to.html#header-dep-changes
---
table/block_based/data_block_hash_index.h | 1 +
util/string_util.h | 1 +
2 files changed, 2 insertions(+)

diff --git a/table/block_based/data_block_hash_index.h b/table/block_based/data_block_hash_index.h
index f356395f329..3215221755d 100644
--- a/table/block_based/data_block_hash_index.h
+++ b/table/block_based/data_block_hash_index.h
@@ -5,6 +5,7 @@

#pragma once

+#include <cstdint>
#include <string>
#include <vector>

diff --git a/util/string_util.h b/util/string_util.h
index 55d106fff02..11178fd1d7b 100644
--- a/util/string_util.h
+++ b/util/string_util.h
@@ -6,6 +6,7 @@

#pragma once

+#include <cstdint>
#include <sstream>
#include <string>
#include <unordered_map>
From 31012cdfa435d9203da3c3de8127b66bf018692a Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Tue, 24 Jan 2023 21:40:43 -0800
Subject: [PATCH] checkpoint.h: Add missing includes <cstdint>

It uses uint64_t and it comes from <cstdint>
This is needed with GCC 13 and newer [1]

[1] https://www.gnu.org/software/gcc/gcc-13/porting_to.html

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
include/rocksdb/utilities/checkpoint.h | 1 +
1 file changed, 1 insertion(+)

diff --git a/include/rocksdb/utilities/checkpoint.h b/include/rocksdb/utilities/checkpoint.h
index 6046513aba4..ecf92061629 100644
--- a/include/rocksdb/utilities/checkpoint.h
+++ b/include/rocksdb/utilities/checkpoint.h
@@ -8,6 +8,7 @@
#pragma once
#ifndef ROCKSDB_LITE

+#include <cstdint>
#include <string>
#include <vector>

0 comments on commit bc407ee

Please sign in to comment.