Skip to content

Commit 539ffa8

Browse files
committed
Build the mcrouter extension
1 parent ff0c3a3 commit 539ffa8

File tree

10 files changed

+110
-135
lines changed

10 files changed

+110
-135
lines changed

CMake/HPHPFindLibs.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,9 @@ if (PAM_INCLUDE_PATH)
291291
include_directories(${PAM_INCLUDE_PATH})
292292
endif()
293293

294+
# Needed by fbthrift.
295+
find_package(Xxhash REQUIRED)
296+
294297
include_directories(${HPHP_HOME}/hphp)
295298

296299
macro(hphp_link target)
@@ -386,6 +389,8 @@ macro(hphp_link target)
386389

387390
target_link_libraries(${target} ${VISIBILITY} ${LBER_LIBRARIES})
388391

392+
target_link_libraries(${target} ${VISIBILITY} ${Xxhash_LIBRARY})
393+
389394
if (CRYPT_LIB)
390395
target_link_libraries(${target} ${VISIBILITY} ${CRYPT_LIB})
391396
endif()

CMake/Options.cmake

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,7 @@ option(ENABLE_COTIRE "Speed up the build by precompiling headers" OFF)
2828

2929
include(CheckCXXSymbolExists)
3030

31-
# Mcrouter uses Folly's AtomicSharedPtr, which only supports libstdc++
32-
# See https://github.com/facebook/hhvm/blob/156a77d5a301033200601ddefb4dcaf26eb1ff9c/third-party/folly/src/folly/concurrency/detail/AtomicSharedPtr-detail.h#L28-L34
33-
check_cxx_symbol_exists(__GLIBCXX__ cstdlib DEFAULT_STDLIB_IS_LIBSTDCXX)
34-
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CLANG_FORCE_LIBSTDCXX OR DEFAULT_STDLIB_IS_LIBSTDCXX)
35-
option(ENABLE_MCROUTER "Build the mcrouter library and extension" ON)
36-
else()
37-
option(ENABLE_MCROUTER "Build the mcrouter library and extension" OFF)
38-
endif()
31+
option(ENABLE_MCROUTER "Build the mcrouter library and extension" OFF)
3932

4033
option(ENABLE_PROXYGEN_SERVER "Build the Proxygen HTTP server" ON)
4134

ci/ubuntu-24.04-noble/debian/rules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ override_dh_auto_configure:
1818
-DFORCE_BUNDLED_LZ4=Off \
1919
-DENABLE_XED=On \
2020
-DENABLE_EXTENSION_MCRYPT=Off \
21-
-DENABLE_MCROUTER=Off \
21+
-DENABLE_MCROUTER=On \
2222
-DENABLE_EXTENSION_IMAGICK=Off
2323

2424
override_dh_auto_build:

hphp/runtime/ext/mcrouter/config.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
option(ENABLE_EXTENSION_MCROUTER "Build the imap extension" ${ENABLE_MCROUTER})
1+
option(ENABLE_EXTENSION_MCROUTER "Build the mcrouter extension" ${ENABLE_MCROUTER})
22

33
HHVM_DEFINE_EXTENSION("mcrouter"
44
SOURCES

third-party/mcrouter/CMakeLists.txt

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ ExternalProject_Add(
4141
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
4242
-DCMAKE_INSTALL_INCLUDEDIR=include
4343
-DCMAKE_INSTALL_LIBDIR=lib
44+
-DCMAKE_MODULE_PATH=${CMAKE_SOURCE_DIR}/build/fbcode_builder/CMake
4445

4546
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
4647
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
@@ -61,6 +62,7 @@ ExternalProject_Add(
6162
"-Dfizz_DIR=${FIZZ_INSTALL_DIR}/lib/cmake/fizz"
6263
"-DFBThrift_DIR=${THRIFT_INSTALL_DIR}/lib/cmake/fbthrift"
6364
"-Dwangle_DIR=${WANGLE_INSTALL_DIR}/lib/cmake/wangle"
65+
"-Dmvfst_DIR=${MVFST_INSTALL_DIR}/lib/cmake/mvfst"
6466
DEPENDS ${MCROUTER_DEPS} ragel
6567
EXCLUDE_FROM_ALL
6668
)
@@ -76,10 +78,26 @@ target_include_directories(
7678
"${BINARY_DIR}"
7779
"${BINARY_DIR}/thrift-gen/src"
7880
)
81+
82+
list(APPEND MCROUTER_INSTALL_TARGETS
83+
mcrouter
84+
mcrouter_memcache_service_thrift
85+
mcrouter_memcache_thrift
86+
mcrouter_common_thrift
87+
mcrouter_carbon_result_thrift
88+
mcrouter_carbon_thrift
89+
)
90+
91+
foreach(target ${MCROUTER_INSTALL_TARGETS})
92+
target_link_libraries(
93+
mcrouter
94+
INTERFACE
95+
"${INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}${target}${CMAKE_STATIC_LIBRARY_SUFFIX}"
96+
)
97+
endforeach()
98+
7999
target_link_libraries(
80100
mcrouter
81101
INTERFACE
82-
"${INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}mcrouter${CMAKE_STATIC_LIBRARY_SUFFIX}"
83-
"${INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}mcrouter_thrift_lib${CMAKE_STATIC_LIBRARY_SUFFIX}"
84102
mcrouter_deps
85103
)

third-party/mcrouter/mcrouter-CMakeLists.txt

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
cmake_minimum_required(VERSION 3.10)
22
project(watchman CXX C)
33
include(GNUInstallDirs)
4-
set(CMAKE_CXX_STANDARD 17)
4+
set(CMAKE_CXX_STANDARD 20)
55
set(CMAKE_CXX_STANDARD_REQUIRED ON)
66
set(CMAKE_CXX_EXTENSIONS OFF)
77

8-
98
set(C_SOURCES)
109

1110
# TODO when Ubuntu 18.04 support is dropped:
@@ -102,12 +101,69 @@ find_package(wangle REQUIRED)
102101

103102
find_path(JEMALLOC_INCLUDE_DIR NAMES jemalloc/jemalloc.h REQUIRED)
104103

105-
include(mcrouter-thrift-codegen.cmake)
104+
include(FBThriftCppLibrary)
105+
set(THRIFT_OPTIONS stack_arguments sync_methods_return_try
106+
deprecated_terse_writes)
107+
108+
add_fbthrift_cpp_library(mcrouter_carbon_result_thrift mcrouter/lib/carbon/carbon_result.thrift OPTIONS ${THRIFT_OPTIONS})
109+
add_fbthrift_cpp_library(mcrouter_carbon_thrift mcrouter/lib/carbon/carbon.thrift OPTIONS ${THRIFT_OPTIONS})
110+
add_fbthrift_cpp_library(mcrouter_common_thrift mcrouter/lib/network/gen/Common.thrift
111+
OPTIONS ${THRIFT_OPTIONS}
112+
DEPENDS
113+
mcrouter_carbon_thrift
114+
mcrouter_carbon_result_thrift
115+
)
116+
add_fbthrift_cpp_library(mcrouter_memcache_thrift mcrouter/lib/network/gen/Memcache.thrift
117+
OPTIONS ${THRIFT_OPTIONS}
118+
DEPENDS
119+
mcrouter_carbon_thrift
120+
mcrouter_carbon_result_thrift
121+
mcrouter_common_thrift
122+
)
123+
add_fbthrift_cpp_library(mcrouter_memcache_service_thrift mcrouter/lib/network/gen/MemcacheService.thrift
124+
OPTIONS ${THRIFT_OPTIONS}
125+
DEPENDS
126+
mcrouter_common_thrift
127+
mcrouter_memcache_thrift
128+
SERVICES
129+
Memcache
130+
)
106131

107-
target_link_libraries(mcrouter mcrouter_thrift_lib Folly::folly boost fizz fmt)
132+
target_link_libraries(
133+
mcrouter
134+
mcrouter_carbon_result_thrift
135+
mcrouter_carbon_thrift
136+
mcrouter_common_thrift
137+
mcrouter_memcache_thrift
138+
mcrouter_memcache_service_thrift
139+
Folly::folly
140+
boost
141+
fizz
142+
fmt
143+
FBThrift::thriftcpp2
144+
FBThrift::async
145+
FBThrift::serverdbginfo
146+
FBThrift::transport
147+
FBThrift::thriftanyrep
148+
FBThrift::thrifttype
149+
FBThrift::thrifttyperep
150+
FBThrift::thriftprotocol
151+
FBThrift::rpcmetadata
152+
FBThrift::thriftannotation
153+
FBThrift::thriftmetadata
154+
FBThrift::concurrency
155+
FBThrift::runtime
156+
FBThrift::thrift-core
157+
)
108158
target_include_directories(mcrouter PUBLIC "${CMAKE_CURRENT_BINARY_DIR}" "${JEMALLOC_INCLUDE_DIR}")
109159

110160
install(
111-
TARGETS mcrouter
161+
TARGETS
162+
mcrouter
163+
mcrouter_carbon_result_thrift
164+
mcrouter_carbon_thrift
165+
mcrouter_common_thrift
166+
mcrouter_memcache_thrift
167+
mcrouter_memcache_service_thrift
112168
LIBRARY ARCHIVE DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}
113169
)

third-party/mcrouter/mcrouter-thrift-codegen.cmake

Lines changed: 0 additions & 75 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/home/catullus/data/hhvm/third-party/mcrouter/mcrouter-CMakeLists.txt
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/home/catullus/data/hhvm/third-party/mcrouter/mcrouter-thrift-codegen.cmake

third-party/thrift/CMakeLists.txt

Lines changed: 19 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -84,50 +84,26 @@ target_include_directories(thrift INTERFACE "${INSTALL_DIR}/include")
8484
target_link_libraries(thrift INTERFACE ${THRIFT_DEPS} ${OPENSSL_LIBRARIES})
8585
set(THRIFT_INSTALL_DIR "${INSTALL_DIR}" PARENT_SCOPE)
8686

87-
# ----- Export a single 'thrift' library target -----
88-
89-
# Usage: thrift_lib NAME [DEP1 [DEP2...]]
90-
macro(thrift_lib NAME)
91-
set(DEPENDENCIES)
92-
foreach(DEP ${ARGN})
93-
list(APPEND DEPENDENCIES "thrift_lib_${DEP}")
94-
endforeach()
95-
add_library("thrift_lib_${NAME}" STATIC IMPORTED)
96-
set_target_properties(
97-
"thrift_lib_${NAME}"
98-
PROPERTIES
99-
IMPORTED_LOCATION
100-
"${INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}${NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}"
101-
)
102-
103-
if(DEPENDENCIES)
104-
# On newer versions of CMake, we can use `target_link_libraries()`, but this isn't supported
105-
# on `IMPORTED` targets in the oldest versions we currently support.
106-
set_target_properties(
107-
"thrift_lib_${NAME}"
108-
PROPERTIES
109-
INTERFACE_LINK_LIBRARIES
110-
"${DEPENDENCIES}"
111-
)
112-
endif()
113-
114-
target_link_libraries(thrift INTERFACE "thrift_lib_${NAME}")
115-
endmacro()
116-
117-
thrift_lib(concurrency)
118-
thrift_lib(rpcmetadata)
119-
thrift_lib(thrift-core)
120-
thrift_lib(thriftmetadata)
121-
thrift_lib(thriftannotation)
122-
thrift_lib(thrifttype)
123-
thrift_lib(thrifttyperep thriftannotation)
124-
thrift_lib(thriftanyrep thriftannotation thrifttype)
87+
list(APPEND THRIFT_INSTALL_TARGETS
88+
thriftcpp2
89+
async
90+
serverdbginfo
91+
transport
92+
thriftanyrep
93+
thrifttype
94+
thrifttyperep
95+
thriftprotocol
96+
rpcmetadata
97+
thriftannotation
98+
thriftmetadata
99+
concurrency
100+
runtime
101+
thrift-core
102+
)
125103

126-
thrift_lib(transport concurrency thrift-core rpcmetadata)
127-
thrift_lib(async concurrency transport)
128-
thrift_lib(thriftprotocol thrift-core)
129-
thrift_lib(thriftfrozen2 thriftmetadata thriftprotocol)
130-
thrift_lib(thriftcpp2 rpcmetadata thriftmetadata thriftannotation thriftanyrep thrifttyperep thriftfrozen2 thriftprotocol transport async)
104+
foreach (target ${THRIFT_INSTALL_TARGETS})
105+
target_link_libraries(thrift INTERFACE "${INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}${target}${CMAKE_STATIC_LIBRARY_SUFFIX}")
106+
endforeach()
131107

132108
# ----- Export the thrift compiler as a target -----
133109

0 commit comments

Comments
 (0)