Skip to content

Commit 6e34d1c

Browse files
committed
Link jemalloc pool and test with libc
This forces the linker to link with libc before linking with jemalloc. Because of that, jemalloc will not override symbols for malloc/free.
1 parent 74fe7d0 commit 6e34d1c

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/pool/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ endif()
3030
# libumf_pool_jemalloc
3131
if(UMF_BUILD_LIBUMF_POOL_JEMALLOC)
3232
if(LINUX)
33+
# TODO: we link directly with libc to force using malloc from glibc
34+
# This is a temporary fix for https://github.com/oneapi-src/unified-memory-framework/issues/161
3335
add_umf_library(NAME jemalloc_pool
3436
TYPE STATIC
3537
SRCS pool_jemalloc.c
36-
LIBS jemalloc umf_utils)
38+
LIBS c jemalloc umf_utils)
3739
add_library(${PROJECT_NAME}::jemalloc_pool ALIAS jemalloc_pool)
3840
install(TARGETS jemalloc_pool
3941
EXPORT ${PROJECT_NAME}-targets

test/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,11 @@ endif()
8080

8181
if(UMF_BUILD_OS_MEMORY_PROVIDER)
8282
if(UMF_BUILD_LIBUMF_POOL_JEMALLOC)
83+
# TODO: we link directly with libc to force using malloc from glibc
84+
# This is a temporary fix for https://github.com/oneapi-src/unified-memory-framework/issues/161
8385
add_umf_test(NAME jemalloc_pool
8486
SRCS pools/jemalloc_pool.cpp malloc_compliance_tests.cpp
85-
LIBS jemalloc_pool)
87+
LIBS c jemalloc_pool)
8688
endif()
8789
else()
8890
message(STATUS "The jemalloc_pool test is DISABLED, because it uses OS_MEMORY_PROVIDER, while the UMF_BUILD_OS_MEMORY_PROVIDER option is set to OFF")

0 commit comments

Comments
 (0)