Skip to content

Commit 56d8e7f

Browse files
authored
Link against snmalloc (#7137)
1 parent 99fd651 commit 56d8e7f

File tree

3 files changed

+18
-30
lines changed

3 files changed

+18
-30
lines changed

CMakeLists.txt

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ endif()
117117
# This option controls whether to link virtual builds against snmalloc rather
118118
# than use the system allocator.
119119
option(USE_SNMALLOC "Link against snmalloc" ON)
120+
if(USE_SNMALLOC)
121+
set(SNMALLOC_BUILD_TESTING OFF)
122+
set(SNMALLOC_STATIC_LIBRARY_PREFIX "")
123+
add_subdirectory(3rdparty/exported/snmalloc EXCLUDE_FROM_ALL)
124+
endif()
120125

121126
# Useful for debugging with libc++ hardening options
122127
option(USE_LIBCXX "Use libc++ instead of libstdc++" OFF)
@@ -208,19 +213,6 @@ include(${CCF_DIR}/cmake/qcbor.cmake)
208213
include(${CCF_DIR}/cmake/t_cose.cmake)
209214

210215
# Launcher library
211-
if(SAN
212-
OR TSAN
213-
OR NOT USE_SNMALLOC
214-
)
215-
set(SNMALLOC_COMPILE_OPTIONS "")
216-
else()
217-
set(SNMALLOC_HEADER_ONLY_LIBRARY ON)
218-
add_subdirectory(3rdparty/exported/snmalloc EXCLUDE_FROM_ALL)
219-
set(SNMALLOC_COMPILE_OPTIONS "-mcx16")
220-
set(SNMALLOC_INCLUDE_DIRS 3rdparty/exported/snmalloc/src)
221-
list(APPEND CCF_LAUNCHER_SOURCES src/host/snmalloc.cpp)
222-
endif()
223-
224216
list(APPEND CCF_LAUNCHER_SOURCES ${CCF_DIR}/src/host/run.cpp
225217
${CCF_DIR}/src/host/env.cpp
226218
)
@@ -238,10 +230,7 @@ add_ccf_static_library(
238230
http_parser
239231
)
240232

241-
target_include_directories(
242-
ccf_launcher PRIVATE ${CCF_GENERATED_DIR} ${SNMALLOC_INCLUDE_DIRS}
243-
)
244-
target_compile_options(ccf_launcher PRIVATE ${SNMALLOC_COMPILE_OPTIONS})
233+
target_include_directories(ccf_launcher PRIVATE ${CCF_GENERATED_DIR})
245234

246235
# HTTP parser
247236
add_library(http_parser "${HTTP_PARSER_SOURCES}")

cmake/ccf_app.cmake

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ function(add_ccf_app name)
4848
add_san(${name})
4949
add_tidy(${name})
5050

51+
if(USE_SNMALLOC)
52+
target_link_libraries(
53+
${name} INTERFACE snmalloc-new-override snmallocshim-static
54+
)
55+
endif()
56+
5157
add_dependencies(${name} ${name})
5258
if(PARSED_ARGS_DEPS)
5359
add_dependencies(${name} ${PARSED_ARGS_DEPS})
@@ -81,4 +87,10 @@ function(add_ccf_static_library name)
8187
DESTINATION lib
8288
)
8389
endif()
90+
91+
if(USE_SNMALLOC)
92+
target_link_libraries(
93+
${name} INTERFACE snmalloc-new-override snmallocshim-static
94+
)
95+
endif()
8496
endfunction()

src/host/snmalloc.cpp

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

0 commit comments

Comments
 (0)