Skip to content

Commit 7987f91

Browse files
committed
build: third_party を submodule から FetchContent に移行 (#97 + #98)
masstree / mimalloc / googletest を tracked submodule + 手動 bootstrap.sh から FetchContent ベースに切り替える。 - cmake/ThirdParty.cmake を新設し、3 つの依存を SHA / tag で pin して取得: - masstree: thawk105 fork, commit b3c5d05 (現 submodule と同一) - mimalloc: v2.3.2 (commit 02a2f5d, 性能を変えないため version 据え置き) - googletest: commit f8d7d77 (現 submodule と同一) - masstree は CMake project ではないので FetchContent_Populate 後に旧 bootstrap.sh と同じ手順 (bootstrap → configure → make → ar → ranlib) を add_custom_command で再現し、ccbench::masstree (INTERFACE library) で expose する。 - mimalloc は FetchContent_MakeAvailable → upstream の mimalloc-static ターゲットを ccbench::mimalloc に alias。MI_BUILD_SHARED/OBJECT/TESTS は OFF にして余計なアーティファクトを抑える。 - googletest は FetchContent_MakeAvailable で GTest::gtest{,_main} を expose し、cc/ss2pl/test/CMakeLists.txt の生パス直参照を置き換える。 - include/masstree_wrapper.hh の "../third_party/masstree/..." 形式の include を <...> 形式に変更 (ccbench::masstree の include dir 経由で 解決)。 - build_tools/bootstrap.sh / bootstrap_googletest.sh / bootstrap_mimalloc.sh と .gitmodules を削除。third_party/{masstree,mimalloc,googletest} の submodule entry も削除。 Closes #97, closes #98. CI (build.yml) の submodule/bootstrap ステップ撤去と docs 更新は依存先の #99 で行う。性能 regression 検証 (#98 の主目的) は user の明示指示により 本 PR ではスキップ — v2.3.2 を据え置いているのでビルド/リンクが通って動く ことの確認のみ行った。
1 parent 49475eb commit 7987f91

11 files changed

Lines changed: 165 additions & 83 deletions

File tree

.gitmodules

Lines changed: 0 additions & 9 deletions
This file was deleted.

CMakeLists.txt

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
88
# protocol binary via ccbench_add_protocol() (see cmake/CompileOptions.cmake).
99
include(CompileOptions)
1010

11-
set(THIRD_PARTY_DIR "${PROJECT_SOURCE_DIR}/third_party/")
12-
1311
option(ENABLE_SANITIZER "enable sanitizer on debug build" ON)
1412
option(ENABLE_UB_SANITIZER "enable undefined behavior sanitizer on debug build" OFF)
1513
option(ENABLE_COVERAGE "enable coverage on debug build" OFF)
@@ -32,17 +30,12 @@ find_package(glog REQUIRED)
3230
find_package(Boost COMPONENTS filesystem)
3331

3432
# ---------------------------------------------------------------------------
35-
# Imported targets for the bootstrap-built third-party static libraries.
36-
# Replaces the raw ${THIRD_PARTY_DIR}/.../*.a paths previously copy-pasted
37-
# into every protocol's target_link_libraries(...).
33+
# Third-party dependencies (masstree / mimalloc / googletest) are pulled in
34+
# via FetchContent — see cmake/ThirdParty.cmake. Exposes ccbench::masstree
35+
# / ccbench::mimalloc / GTest::gtest{,_main}, which replace the static
36+
# IMPORTED targets and raw third_party/*.a paths used previously.
3837
# ---------------------------------------------------------------------------
39-
add_library(ccbench::masstree STATIC IMPORTED GLOBAL)
40-
set_target_properties(ccbench::masstree PROPERTIES
41-
IMPORTED_LOCATION "${THIRD_PARTY_DIR}/masstree/libkohler_masstree_json.a")
42-
43-
add_library(ccbench::mimalloc STATIC IMPORTED GLOBAL)
44-
set_target_properties(ccbench::mimalloc PROPERTIES
45-
IMPORTED_LOCATION "${THIRD_PARTY_DIR}/mimalloc/out/release/libmimalloc.a")
38+
include(ThirdParty)
4639

4740
# ---------------------------------------------------------------------------
4841
# common/ as a real shared static library — replaces the per-binary

build_tools/bootstrap.sh

Lines changed: 0 additions & 9 deletions
This file was deleted.

build_tools/bootstrap_googletest.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.

build_tools/bootstrap_mimalloc.sh

Lines changed: 0 additions & 24 deletions
This file was deleted.

cc/ss2pl/test/CMakeLists.txt

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,18 @@ foreach(src IN LISTS TEST_SOURCES)
2828
KEY_SORT=${CCBENCH_KEY_SORT}
2929
)
3030

31-
target_include_directories(${test_name}
32-
PRIVATE ${PROJECT_SOURCE_DIR}/../third_party/googletest/googletest/include
33-
)
34-
31+
# All three deps now come from FetchContent (cmake/ThirdParty.cmake) —
32+
# GTest::gtest{,_main} carry their own INTERFACE_INCLUDE_DIRECTORIES so
33+
# we no longer need the manual include path override.
3534
target_link_libraries(${test_name}
3635
Boost::filesystem
3736
gflags::gflags
3837
glog::glog
39-
${PROJECT_SOURCE_DIR}/../third_party/mimalloc/out/release/libmimalloc.a
40-
${PROJECT_SOURCE_DIR}/../third_party/masstree/libkohler_masstree_json.a
38+
ccbench::mimalloc
39+
ccbench::masstree
4140
Threads::Threads
42-
${PROJECT_SOURCE_DIR}/../third_party/googletest/build/lib/libgtest.a
43-
${PROJECT_SOURCE_DIR}/../third_party/googletest/build/lib/libgtest_main.a
41+
GTest::gtest
42+
GTest::gtest_main
4443
)
4544
set_compile_options(${test_name})
4645
add_test(

cmake/ThirdParty.cmake

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# cmake/ThirdParty.cmake
2+
#
3+
# Centralised FetchContent declarations for ccbench's third-party
4+
# dependencies. Replaces tracked submodules under third_party/ +
5+
# the per-library build_tools/bootstrap_*.sh scripts.
6+
#
7+
# Targets exposed to the rest of the build:
8+
# ccbench::masstree — static archive built from upstream sources
9+
# (libkohler_masstree_json.a; same 11 objects the
10+
# old build_tools/bootstrap.sh produced)
11+
# ccbench::mimalloc — alias for the upstream mimalloc-static target
12+
# GTest::gtest /
13+
# GTest::gtest_main — provided directly by upstream googletest
14+
#
15+
# All revisions are pinned to commit SHAs / tags so the build is
16+
# reproducible and FetchContent never silently follows a moving branch.
17+
18+
include(FetchContent)
19+
include(ExternalProject)
20+
21+
# --- masstree --------------------------------------------------------------
22+
#
23+
# Upstream masstree-beta is not a CMake project (autotools + hand-rolled
24+
# Makefile). We mirror the old build_tools/bootstrap.sh exactly:
25+
# ./bootstrap.sh && ./configure --disable-assertions
26+
# make CXXFLAGS='-g -W -Wall -O3 -fPIC'
27+
# ar cr libkohler_masstree_json.a <11 objects> && ranlib …
28+
# done at configure time via ExternalProject_Add, then exposed as a
29+
# STATIC IMPORTED target so the rest of the CMake graph treats it the
30+
# same way as before.
31+
#
32+
# The fork URL + commit SHA come from the previous .gitmodules /
33+
# `git submodule status` (see issue #97).
34+
35+
set(CCBENCH_MASSTREE_REPO "https://github.com/thawk105/masstree-beta.git")
36+
set(CCBENCH_MASSTREE_TAG "b3c5d054b66b08374d7a6ff5a0faeaf28b041a38")
37+
set(CCBENCH_MIMALLOC_REPO "https://github.com/microsoft/mimalloc.git")
38+
set(CCBENCH_MIMALLOC_TAG "v2.3.2") # commit 02a2f5d, matches old submodule
39+
set(CCBENCH_GOOGLETEST_REPO "https://github.com/google/googletest.git")
40+
set(CCBENCH_GOOGLETEST_TAG "f8d7d77c06936315286eb55f8de22cd23c188571")
41+
42+
FetchContent_Declare(
43+
masstree
44+
GIT_REPOSITORY "${CCBENCH_MASSTREE_REPO}"
45+
GIT_TAG "${CCBENCH_MASSTREE_TAG}"
46+
GIT_SHALLOW FALSE # SHA pin needs the full object, not a tag-only fetch
47+
)
48+
49+
# Populate() leaves us with masstree_SOURCE_DIR / masstree_BINARY_DIR but
50+
# does NOT add it to the build graph (the upstream tree has no
51+
# CMakeLists.txt). We then drive its autotools build out-of-tree.
52+
FetchContent_GetProperties(masstree)
53+
if(NOT masstree_POPULATED)
54+
FetchContent_Populate(masstree)
55+
endif()
56+
57+
set(_masstree_archive "${masstree_SOURCE_DIR}/libkohler_masstree_json.a")
58+
set(_masstree_config_h "${masstree_SOURCE_DIR}/config.h")
59+
60+
# Mirror the historical bootstrap.sh object set verbatim — these are the
61+
# exact 11 translation units the old script packed into the archive.
62+
set(_masstree_objs
63+
json.o string.o straccum.o str.o msgpack.o clp.o
64+
kvrandom.o compiler.o memdebug.o kvthread.o misc.o)
65+
66+
add_custom_command(
67+
OUTPUT "${_masstree_archive}" "${_masstree_config_h}"
68+
COMMAND ${CMAKE_COMMAND} -E echo "Building masstree (libkohler_masstree_json.a)"
69+
COMMAND ./bootstrap.sh
70+
COMMAND ./configure --disable-assertions
71+
COMMAND make -j CXXFLAGS=-g\ -W\ -Wall\ -O3\ -fPIC
72+
COMMAND ar cr libkohler_masstree_json.a ${_masstree_objs}
73+
COMMAND ranlib libkohler_masstree_json.a
74+
WORKING_DIRECTORY "${masstree_SOURCE_DIR}"
75+
COMMENT "masstree: bootstrap + configure + make + ar"
76+
VERBATIM
77+
)
78+
add_custom_target(masstree_build DEPENDS "${_masstree_archive}" "${_masstree_config_h}")
79+
80+
# Expose masstree as an INTERFACE library (rather than STATIC IMPORTED) so
81+
# we can use add_dependencies() to wire the upstream-build custom target
82+
# into every consumer — IMPORTED targets don't propagate build-order deps
83+
# reliably across all CMake versions we care about.
84+
add_library(ccbench_masstree INTERFACE)
85+
target_include_directories(ccbench_masstree INTERFACE "${masstree_SOURCE_DIR}")
86+
target_link_libraries(ccbench_masstree INTERFACE "${_masstree_archive}")
87+
add_dependencies(ccbench_masstree masstree_build)
88+
add_library(ccbench::masstree ALIAS ccbench_masstree)
89+
90+
# --- mimalloc --------------------------------------------------------------
91+
#
92+
# mimalloc is a regular CMake project; FetchContent_MakeAvailable drops it
93+
# straight into the build graph and gives us the upstream
94+
# `mimalloc-static` target. We alias it so the rest of the tree keeps
95+
# linking against ccbench::mimalloc unchanged.
96+
#
97+
# Note: we keep the same commit (v2.3.2) the old submodule was pinned to —
98+
# bumping the allocator version is out of scope for issue #98.
99+
100+
set(MI_BUILD_STATIC ON CACHE BOOL "" FORCE)
101+
set(MI_BUILD_SHARED OFF CACHE BOOL "" FORCE)
102+
set(MI_BUILD_OBJECT OFF CACHE BOOL "" FORCE)
103+
set(MI_BUILD_TESTS OFF CACHE BOOL "" FORCE)
104+
set(MI_OVERRIDE OFF CACHE BOOL "" FORCE)
105+
106+
FetchContent_Declare(
107+
mimalloc
108+
GIT_REPOSITORY "${CCBENCH_MIMALLOC_REPO}"
109+
GIT_TAG "${CCBENCH_MIMALLOC_TAG}"
110+
GIT_SHALLOW TRUE
111+
)
112+
FetchContent_MakeAvailable(mimalloc)
113+
114+
# Upstream exports `mimalloc-static`; expose it under ccbench:: so callers
115+
# don't have to know which upstream name to use.
116+
add_library(ccbench::mimalloc ALIAS mimalloc-static)
117+
118+
# --- googletest ------------------------------------------------------------
119+
#
120+
# Standard FetchContent + MakeAvailable. The googletest CMake project
121+
# exports `GTest::gtest` / `GTest::gtest_main` targets that the test
122+
# subdirectories (currently only cc/ss2pl/test) link against directly.
123+
124+
set(BUILD_GMOCK OFF CACHE BOOL "" FORCE)
125+
set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)
126+
# Match MSVC's runtime to the rest of the build — no-op on Linux but
127+
# keeps the project portable if anyone ever builds tests on Windows.
128+
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
129+
130+
FetchContent_Declare(
131+
googletest
132+
GIT_REPOSITORY "${CCBENCH_GOOGLETEST_REPO}"
133+
GIT_TAG "${CCBENCH_GOOGLETEST_TAG}"
134+
GIT_SHALLOW FALSE # SHA pin
135+
)
136+
FetchContent_MakeAvailable(googletest)

include/masstree_wrapper.hh

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,23 @@
1313
// フォーマッターを利用すると,辞書順のために下記2行が入れ替わる.
1414
// しかし,依存関係があるため,config -> compiler の順にしなければ
1515
// 大量のエラーが出てしまう. そのため,改行を防ぐため空行を空けている
16-
#include "../third_party/masstree/config.h"
17-
18-
#include "../third_party/masstree/compiler.hh"
19-
20-
#include "../third_party/masstree/kvthread.hh"
21-
#include "../third_party/masstree/masstree.hh"
22-
#include "../third_party/masstree/masstree_insert.hh"
23-
#include "../third_party/masstree/masstree_print.hh"
24-
#include "../third_party/masstree/masstree_remove.hh"
25-
#include "../third_party/masstree/masstree_scan.hh"
26-
#include "../third_party/masstree/masstree_stats.hh"
27-
#include "../third_party/masstree/masstree_tcursor.hh"
28-
#include "../third_party/masstree/string.hh"
16+
//
17+
// masstree のヘッダは ccbench::masstree (cmake/ThirdParty.cmake) の
18+
// INTERFACE_INCLUDE_DIRECTORIES から angle-bracket 形式で引き当てる。
19+
// FetchContent によりソースは build/_deps/masstree-src/ に置かれる。
20+
#include <config.h>
21+
22+
#include <compiler.hh>
23+
24+
#include <kvthread.hh>
25+
#include <masstree.hh>
26+
#include <masstree_insert.hh>
27+
#include <masstree_print.hh>
28+
#include <masstree_remove.hh>
29+
#include <masstree_scan.hh>
30+
#include <masstree_stats.hh>
31+
#include <masstree_tcursor.hh>
32+
#include <string.hh>
2933

3034
#include "atomic_wrapper.hh"
3135
#include "debug.hh"

third_party/googletest

Lines changed: 0 additions & 1 deletion
This file was deleted.

third_party/masstree

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)