Skip to content

Commit e912c8c

Browse files
committed
fix(cmake,userspace): fix usage and build of mimalloc.
Signed-off-by: Federico Di Pierro <[email protected]>
1 parent a63dad7 commit e912c8c

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

cmake/modules/mimalloc.cmake

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,30 @@ else()
4747
set(MIMALLOC_LIB_BASENAME "libmimalloc")
4848
endif()
4949
set(MALLOC_LIB "${MIMALLOC_SRC}/malloc-build/${MIMALLOC_LIB_BASENAME}${MIMALLOC_LIB_SUFFIX}")
50-
set(MIMALLOC_INCLUDE ${MIMALLOC_SRC}/include/)
50+
set(MIMALLOC_INCLUDE ${MIMALLOC_SRC}/malloc/include/)
5151

52+
# To avoid recent clang versions complaining with "error: expansion of date or time macro is not
53+
# reproducible" while building mimalloc, we force-set both variables.
54+
string(TIMESTAMP DATE "%Y%m%d")
55+
string(TIMESTAMP TIME "%H:%M")
56+
set(MIMALLOC_EXTRA_CPPDEFS __DATE__="${DATE}",__TIME__="${TIME}")
57+
58+
# We disable arch specific optimization because of issues with building with zig. Optimizations
59+
# would be only effective on arm64. See MI_NO_OPT_ARCH=On.
5260
ExternalProject_Add(
5361
malloc
5462
PREFIX "${PROJECT_BINARY_DIR}/mimalloc-prefix"
5563
URL "https://github.com/microsoft/mimalloc/archive/refs/tags/v3.1.5.tar.gz"
5664
URL_HASH "SHA256=1c6949032069d5ebea438ec5cedd602d06f40a92ddf0f0d9dcff0993e5f6635c"
65+
LIST_SEPARATOR "," # to pass MIMALLOC_EXTRA_CPPDEFS as list
5766
CMAKE_ARGS -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
5867
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
5968
-DMI_BUILD_SHARED=${BUILD_SHARED_LIBS}
6069
-DMI_BUILD_STATIC=${BUILD_STATIC}
6170
-DMI_BUILD_TESTS=Off
6271
-DMI_BUILD_OBJECT=Off
63-
-DMI_OPT_ARCH=On
72+
-DMI_NO_OPT_ARCH=On
73+
-DMI_EXTRA_CPPDEFS=${MIMALLOC_EXTRA_CPPDEFS}
6474
INSTALL_COMMAND ""
6575
UPDATE_COMMAND ""
6676
BUILD_BYPRODUCTS ${MALLOC_LIB}

userspace/falco/CMakeLists.txt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,12 @@ endif()
137137
target_compile_definitions(falco_application PRIVATE CPPHTTPLIB_OPENSSL_SUPPORT)
138138

139139
add_dependencies(falco_application ${FALCO_DEPENDENCIES})
140-
141-
target_link_libraries(falco_application ${FALCO_LIBRARIES})
142-
140+
target_link_libraries(falco_application PUBLIC ${FALCO_LIBRARIES})
143141
target_include_directories(falco_application PUBLIC ${FALCO_INCLUDE_DIRECTORIES})
144142

145143
add_executable(falco falco.cpp)
146-
add_dependencies(falco falco_application ${FALCO_DEPENDENCIES})
147-
target_link_libraries(falco falco_application ${FALCO_LIBRARIES})
144+
add_dependencies(falco falco_application)
145+
target_link_libraries(falco falco_application)
148146
target_include_directories(falco PUBLIC ${FALCO_INCLUDE_DIRECTORIES})
149147

150148
if(EMSCRIPTEN)

userspace/falco/falco.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ See the License for the specific language governing permissions and
1515
limitations under the License.
1616
*/
1717

18-
#ifdef HAS_MIMALLOC
19-
#include <mimalloc-new-delete.h>
20-
#endif
21-
2218
#include <stdio.h>
2319
#include <string>
2420

0 commit comments

Comments
 (0)