Skip to content

Commit 492d1f4

Browse files
authored
Merge pull request #358 from ldorau/Enable_building_on_MacOSX
Enable building on MacOSX
2 parents cd152ea + 49ac267 commit 492d1f4

File tree

6 files changed

+68
-78
lines changed

6 files changed

+68
-78
lines changed

.github/workflows/basic.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ jobs:
285285
run: python3 -m pip install -r third_party/requirements.txt
286286

287287
- name: Install hwloc
288-
run: brew install hwloc
288+
run: brew install hwloc jemalloc tbb
289289

290290
- name: Configure build
291291
run: >
@@ -294,10 +294,11 @@ jobs:
294294
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
295295
-DUMF_FORMAT_CODE_STYLE=OFF
296296
-DUMF_DEVELOPER_MODE=ON
297-
-DUMF_ENABLE_POOL_TRACKING=ON
297+
-DUMF_ENABLE_POOL_TRACKING=ON
298298
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
299-
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=OFF
300-
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=OFF
299+
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
300+
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
301+
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=ON
301302
-DUMF_BUILD_SHARED_LIBRARY=ON
302303
303304
- name: Build UMF
@@ -310,3 +311,7 @@ jobs:
310311
--install-dir ${{env.INSTL_DIR}}
311312
--build-type ${{env.BUILD_TYPE}}
312313
--shared-library
314+
--disjoint-pool
315+
--jemalloc-pool
316+
--scalable-pool
317+
--examples

CMakeLists.txt

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ endif()
172172
set(DLL_PATH_LIST
173173
"${DLL_PATH_LIST};PATH=path_list_append:${LIBHWLOC_LIBRARY_DIRS}/../bin")
174174

175-
if(UMF_BUILD_LIBUMF_POOL_SCALABLE AND (LINUX OR WINDOWS))
175+
if(UMF_BUILD_LIBUMF_POOL_SCALABLE)
176176
pkg_check_modules(TBB tbb)
177177
if(NOT TBB_FOUND)
178178
find_package(TBB REQUIRED tbb)
@@ -182,7 +182,7 @@ if(UMF_BUILD_LIBUMF_POOL_SCALABLE AND (LINUX OR WINDOWS))
182182
"${DLL_PATH_LIST};PATH=path_list_append:${TBB_LIBRARY_DIRS}/../bin")
183183
endif()
184184

185-
if(UMF_BUILD_LIBUMF_POOL_JEMALLOC AND (LINUX OR WINDOWS))
185+
if(UMF_BUILD_LIBUMF_POOL_JEMALLOC)
186186
pkg_check_modules(JEMALLOC jemalloc)
187187
if(NOT JEMALLOC_FOUND)
188188
find_package(JEMALLOC REQUIRED jemalloc)
@@ -194,41 +194,39 @@ if(UMF_BUILD_LIBUMF_POOL_JEMALLOC AND (LINUX OR WINDOWS))
194194
endif()
195195

196196
# set UMF_PROXY_LIB_ENABLED
197-
if(LINUX OR WINDOWS)
197+
if(WINDOWS AND NOT (CMAKE_BUILD_TYPE STREQUAL "Release"))
198198
# TODO: enable the proxy library in the Debug build on Windows
199-
if(WINDOWS AND NOT (CMAKE_BUILD_TYPE STREQUAL "Release"))
199+
message(
200+
STATUS
201+
"Disabling the proxy library, because it is supported only in the Release build on Windows (CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE})"
202+
)
203+
elseif(UMF_PROXY_LIB_BASED_ON_POOL STREQUAL SCALABLE)
204+
if(UMF_BUILD_LIBUMF_POOL_SCALABLE)
205+
set(UMF_PROXY_LIB_ENABLED ON)
206+
set(PROXY_LIB_USES_SCALABLE_POOL ON)
207+
set(PROXY_LIBS umf scalable_pool)
208+
else()
200209
message(
201210
STATUS
202-
"Disabling the proxy library, because it is supported only in the Release build on Windows (CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE})"
211+
"Disabling the proxy library, because UMF_PROXY_LIB_BASED_ON_POOL==SCALABLE but UMF_BUILD_LIBUMF_POOL_SCALABLE is OFF"
203212
)
204-
elseif(UMF_PROXY_LIB_BASED_ON_POOL STREQUAL SCALABLE)
205-
if(UMF_BUILD_LIBUMF_POOL_SCALABLE)
206-
set(UMF_PROXY_LIB_ENABLED ON)
207-
set(PROXY_LIB_USES_SCALABLE_POOL ON)
208-
set(PROXY_LIBS umf scalable_pool)
209-
else()
210-
message(
211-
STATUS
212-
"Disabling the proxy library, because UMF_PROXY_LIB_BASED_ON_POOL==SCALABLE but UMF_BUILD_LIBUMF_POOL_SCALABLE is OFF"
213-
)
214-
endif()
215-
elseif(UMF_PROXY_LIB_BASED_ON_POOL STREQUAL JEMALLOC)
216-
if(UMF_BUILD_LIBUMF_POOL_JEMALLOC)
217-
set(UMF_PROXY_LIB_ENABLED ON)
218-
set(PROXY_LIB_USES_JEMALLOC_POOL ON)
219-
set(PROXY_LIBS umf jemalloc_pool)
220-
else()
221-
message(
222-
STATUS
223-
"Disabling the proxy library, because UMF_PROXY_LIB_BASED_ON_POOL==JEMALLOC but UMF_BUILD_LIBUMF_POOL_JEMALLOC is OFF"
224-
)
225-
endif()
213+
endif()
214+
elseif(UMF_PROXY_LIB_BASED_ON_POOL STREQUAL JEMALLOC)
215+
if(UMF_BUILD_LIBUMF_POOL_JEMALLOC)
216+
set(UMF_PROXY_LIB_ENABLED ON)
217+
set(PROXY_LIB_USES_JEMALLOC_POOL ON)
218+
set(PROXY_LIBS umf jemalloc_pool)
226219
else()
227220
message(
228-
FATAL_ERROR
229-
"Proxy library: pool manager not chosen or set to a non-supported one (see UMF_PROXY_LIB_BASED_ON_POOL)"
221+
STATUS
222+
"Disabling the proxy library, because UMF_PROXY_LIB_BASED_ON_POOL==JEMALLOC but UMF_BUILD_LIBUMF_POOL_JEMALLOC is OFF"
230223
)
231224
endif()
225+
else()
226+
message(
227+
FATAL_ERROR
228+
"Proxy library: pool manager not chosen or set to a non-supported one (see UMF_PROXY_LIB_BASED_ON_POOL)"
229+
)
232230
endif()
233231

234232
add_subdirectory(src)
@@ -238,12 +236,7 @@ if(UMF_BUILD_TESTS)
238236
endif()
239237

240238
if(UMF_BUILD_BENCHMARKS)
241-
if(LINUX OR WINDOWS)
242-
add_subdirectory(benchmark)
243-
else()
244-
message(
245-
FATAL_ERROR "benchmarks are supported on Linux and Windows only")
246-
endif()
239+
add_subdirectory(benchmark)
247240
endif()
248241

249242
if(UMF_BUILD_EXAMPLES)

cmake/helpers.cmake

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,10 @@ function(add_umf_library)
138138
target_link_libraries(${ARG_NAME} PRIVATE ${ARG_LIBS})
139139

140140
target_include_directories(
141-
${ARG_NAME} PRIVATE ${UMF_CMAKE_SOURCE_DIR}/include
142-
${UMF_CMAKE_SOURCE_DIR}/src/base_alloc)
141+
${ARG_NAME}
142+
PRIVATE ${UMF_CMAKE_SOURCE_DIR}/include
143+
${UMF_CMAKE_SOURCE_DIR}/src/utils
144+
${UMF_CMAKE_SOURCE_DIR}/src/base_alloc)
143145
add_umf_target_compile_options(${ARG_NAME})
144146
add_umf_target_link_options(${ARG_NAME})
145147
endfunction()

src/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,7 @@ else()
126126
target_sources(umf PRIVATE memory_pool_default.c)
127127
endif()
128128

129-
# Currently, Level Zero provider is only built for Linux and Windows
130-
if((LINUX OR WINDOWS) AND UMF_BUILD_LEVEL_ZERO_PROVIDER)
129+
if(UMF_BUILD_LEVEL_ZERO_PROVIDER)
131130
target_sources(umf PRIVATE provider/provider_level_zero.c)
132131

133132
if(LINUX)

src/pool/CMakeLists.txt

Lines changed: 22 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -32,45 +32,32 @@ endif()
3232

3333
# libumf_pool_jemalloc
3434
if(UMF_BUILD_LIBUMF_POOL_JEMALLOC)
35-
if(LINUX OR WINDOWS)
36-
add_umf_library(
37-
NAME jemalloc_pool
38-
TYPE STATIC
39-
SRCS pool_jemalloc.c ${POOL_EXTRA_SRCS}
40-
LIBS jemalloc umf_utils)
41-
target_include_directories(jemalloc_pool
42-
PRIVATE ${JEMALLOC_INCLUDE_DIRS})
43-
target_compile_definitions(jemalloc_pool
44-
PUBLIC ${POOL_COMPILE_DEFINITIONS})
45-
add_library(${PROJECT_NAME}::jemalloc_pool ALIAS jemalloc_pool)
46-
install(TARGETS jemalloc_pool EXPORT ${PROJECT_NAME}-targets)
47-
else()
48-
message(FATAL_ERROR "libumf_pool_jemalloc is supported on Linux and "
49-
"Windows only")
50-
endif()
35+
add_umf_library(
36+
NAME jemalloc_pool
37+
TYPE STATIC
38+
SRCS pool_jemalloc.c ${POOL_EXTRA_SRCS}
39+
LIBS jemalloc umf_utils)
40+
target_include_directories(jemalloc_pool PRIVATE ${JEMALLOC_INCLUDE_DIRS})
41+
target_compile_definitions(jemalloc_pool PUBLIC ${POOL_COMPILE_DEFINITIONS})
42+
add_library(${PROJECT_NAME}::jemalloc_pool ALIAS jemalloc_pool)
43+
install(TARGETS jemalloc_pool EXPORT ${PROJECT_NAME}-targets)
5144
endif()
5245

5346
# libumf_pool_scalable
5447
if(UMF_BUILD_LIBUMF_POOL_SCALABLE)
55-
if(LINUX OR WINDOWS)
56-
if(LINUX)
57-
set(LIBS_POOL_SCALABLE dl umf_utils)
58-
elseif(WINDOWS)
59-
set(LIBS_POOL_SCALABLE umf_utils)
60-
endif()
61-
62-
add_umf_library(
63-
NAME scalable_pool
64-
TYPE STATIC
65-
SRCS pool_scalable.c ${POOL_EXTRA_SRCS}
66-
LIBS ${LIBS_POOL_SCALABLE})
67-
target_include_directories(scalable_pool PRIVATE ${TBB_INCLUDE_DIRS})
68-
target_compile_definitions(scalable_pool
69-
PUBLIC ${POOL_COMPILE_DEFINITIONS})
70-
add_library(${PROJECT_NAME}::scalable_pool ALIAS scalable_pool)
71-
install(TARGETS scalable_pool EXPORT ${PROJECT_NAME}-targets)
48+
if(LINUX)
49+
set(LIBS_POOL_SCALABLE dl umf_utils)
7250
else()
73-
message(FATAL_ERROR "libumf_pool_scalable is supported on Linux and "
74-
"Windows only")
51+
set(LIBS_POOL_SCALABLE umf_utils)
7552
endif()
53+
54+
add_umf_library(
55+
NAME scalable_pool
56+
TYPE STATIC
57+
SRCS pool_scalable.c ${POOL_EXTRA_SRCS}
58+
LIBS ${LIBS_POOL_SCALABLE})
59+
target_include_directories(scalable_pool PRIVATE ${TBB_INCLUDE_DIRS})
60+
target_compile_definitions(scalable_pool PUBLIC ${POOL_COMPILE_DEFINITIONS})
61+
add_library(${PROJECT_NAME}::scalable_pool ALIAS scalable_pool)
62+
install(TARGETS scalable_pool EXPORT ${PROJECT_NAME}-targets)
7663
endif()

test/test_proxy_lib.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
*/
77

8+
#if defined(__APPLE__)
9+
#include <malloc/malloc.h>
10+
#else
811
#include <malloc.h>
12+
#endif
913

1014
#include "base.hpp"
1115
#include "test_helpers.h"

0 commit comments

Comments
 (0)