Skip to content

Commit c5b38da

Browse files
committed
Enable building on MacOSX
Signed-off-by: Lukasz Dorau <[email protected]>
1 parent b758327 commit c5b38da

File tree

6 files changed

+59
-65
lines changed

6 files changed

+59
-65
lines changed

.github/workflows/basic.yml

Lines changed: 8 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,6 @@ 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

CMakeLists.txt

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ endif()
150150
# add PATH to DLL on Windows
151151
set(DLL_PATH_LIST "${DLL_PATH_LIST};PATH=path_list_append:${LIBHWLOC_LIBRARY_DIRS}/../bin")
152152

153-
if(UMF_BUILD_LIBUMF_POOL_SCALABLE AND (LINUX OR WINDOWS))
153+
if(UMF_BUILD_LIBUMF_POOL_SCALABLE)
154154
pkg_check_modules(TBB tbb)
155155
if(NOT TBB_FOUND)
156156
find_package(TBB REQUIRED tbb)
@@ -159,7 +159,7 @@ if(UMF_BUILD_LIBUMF_POOL_SCALABLE AND (LINUX OR WINDOWS))
159159
set(DLL_PATH_LIST "${DLL_PATH_LIST};PATH=path_list_append:${TBB_LIBRARY_DIRS}/../bin")
160160
endif()
161161

162-
if(UMF_BUILD_LIBUMF_POOL_JEMALLOC AND (LINUX OR WINDOWS))
162+
if(UMF_BUILD_LIBUMF_POOL_JEMALLOC)
163163
pkg_check_modules(JEMALLOC jemalloc)
164164
if(NOT JEMALLOC_FOUND)
165165
find_package(JEMALLOC REQUIRED jemalloc)
@@ -169,29 +169,26 @@ if(UMF_BUILD_LIBUMF_POOL_JEMALLOC AND (LINUX OR WINDOWS))
169169
endif()
170170

171171
# set UMF_PROXY_LIB_ENABLED
172-
if(LINUX OR WINDOWS)
173-
# TODO: enable the proxy library in the Debug build on Windows
174-
if(WINDOWS AND NOT (CMAKE_BUILD_TYPE STREQUAL "Release"))
175-
message(STATUS "Disabling the proxy library, because it is supported only in the Release build on Windows (CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE})")
176-
elseif(UMF_PROXY_LIB_BASED_ON_POOL STREQUAL SCALABLE)
177-
if(UMF_BUILD_LIBUMF_POOL_SCALABLE)
178-
set(UMF_PROXY_LIB_ENABLED ON)
179-
set(PROXY_LIB_USES_SCALABLE_POOL ON)
180-
set(PROXY_LIBS umf scalable_pool)
181-
else()
182-
message(STATUS "Disabling the proxy library, because UMF_PROXY_LIB_BASED_ON_POOL==SCALABLE but UMF_BUILD_LIBUMF_POOL_SCALABLE is OFF")
183-
endif()
184-
elseif(UMF_PROXY_LIB_BASED_ON_POOL STREQUAL JEMALLOC)
185-
if(UMF_BUILD_LIBUMF_POOL_JEMALLOC)
186-
set(UMF_PROXY_LIB_ENABLED ON)
187-
set(PROXY_LIB_USES_JEMALLOC_POOL ON)
188-
set(PROXY_LIBS umf jemalloc_pool)
189-
else()
190-
message(STATUS "Disabling the proxy library, because UMF_PROXY_LIB_BASED_ON_POOL==JEMALLOC but UMF_BUILD_LIBUMF_POOL_JEMALLOC is OFF")
191-
endif()
172+
if(WINDOWS AND NOT (CMAKE_BUILD_TYPE STREQUAL "Release")) # TODO: enable the proxy library in the Debug build on Windows
173+
message(STATUS "Disabling the proxy library, because it is supported only in the Release build on Windows (CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE})")
174+
elseif(UMF_PROXY_LIB_BASED_ON_POOL STREQUAL SCALABLE)
175+
if(UMF_BUILD_LIBUMF_POOL_SCALABLE)
176+
set(UMF_PROXY_LIB_ENABLED ON)
177+
set(PROXY_LIB_USES_SCALABLE_POOL ON)
178+
set(PROXY_LIBS umf scalable_pool)
179+
else()
180+
message(STATUS "Disabling the proxy library, because UMF_PROXY_LIB_BASED_ON_POOL==SCALABLE but UMF_BUILD_LIBUMF_POOL_SCALABLE is OFF")
181+
endif()
182+
elseif(UMF_PROXY_LIB_BASED_ON_POOL STREQUAL JEMALLOC)
183+
if(UMF_BUILD_LIBUMF_POOL_JEMALLOC)
184+
set(UMF_PROXY_LIB_ENABLED ON)
185+
set(PROXY_LIB_USES_JEMALLOC_POOL ON)
186+
set(PROXY_LIBS umf jemalloc_pool)
192187
else()
193-
message(FATAL_ERROR "Proxy library: pool manager not chosen or set to a non-supported one (see UMF_PROXY_LIB_BASED_ON_POOL)")
188+
message(STATUS "Disabling the proxy library, because UMF_PROXY_LIB_BASED_ON_POOL==JEMALLOC but UMF_BUILD_LIBUMF_POOL_JEMALLOC is OFF")
194189
endif()
190+
else()
191+
message(FATAL_ERROR "Proxy library: pool manager not chosen or set to a non-supported one (see UMF_PROXY_LIB_BASED_ON_POOL)")
195192
endif()
196193

197194
add_subdirectory(src)
@@ -201,11 +198,7 @@ if(UMF_BUILD_TESTS)
201198
endif()
202199

203200
if(UMF_BUILD_BENCHMARKS)
204-
if(LINUX OR WINDOWS)
205-
add_subdirectory(benchmark)
206-
else()
207-
message(FATAL_ERROR "benchmarks are supported on Linux and Windows only")
208-
endif()
201+
add_subdirectory(benchmark)
209202
endif()
210203

211204
if(UMF_BUILD_EXAMPLES)

cmake/helpers.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ function(add_umf_library)
123123

124124
target_include_directories(${ARG_NAME} PRIVATE
125125
${UMF_CMAKE_SOURCE_DIR}/include
126+
${UMF_CMAKE_SOURCE_DIR}/src/utils
126127
${UMF_CMAKE_SOURCE_DIR}/src/base_alloc)
127128
add_umf_target_compile_options(${ARG_NAME})
128129
add_umf_target_link_options(${ARG_NAME})

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ else()
121121
endif()
122122

123123
# Currently, Level Zero provider is only built for Linux and Windows
124-
if((LINUX OR WINDOWS) AND UMF_BUILD_LEVEL_ZERO_PROVIDER)
124+
if(UMF_BUILD_LEVEL_ZERO_PROVIDER)
125125
target_sources(umf PRIVATE
126126
provider/provider_level_zero.c)
127127

src/pool/CMakeLists.txt

Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -35,42 +35,34 @@ endif()
3535

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

5450
# libumf_pool_scalable
5551
if(UMF_BUILD_LIBUMF_POOL_SCALABLE)
56-
if(LINUX OR WINDOWS)
57-
if(LINUX)
58-
set(LIBS_POOL_SCALABLE dl umf_utils)
59-
elseif(WINDOWS)
60-
set(LIBS_POOL_SCALABLE umf_utils)
61-
endif()
62-
63-
add_umf_library(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 PUBLIC ${POOL_COMPILE_DEFINITIONS})
69-
add_library(${PROJECT_NAME}::scalable_pool ALIAS scalable_pool)
70-
install(TARGETS scalable_pool
71-
EXPORT ${PROJECT_NAME}-targets
72-
)
52+
if(LINUX)
53+
set(LIBS_POOL_SCALABLE dl umf_utils)
7354
else()
74-
message(FATAL_ERROR "libumf_pool_scalable is supported on Linux and Windows only")
55+
set(LIBS_POOL_SCALABLE umf_utils)
7556
endif()
57+
58+
add_umf_library(NAME scalable_pool
59+
TYPE STATIC
60+
SRCS pool_scalable.c ${POOL_EXTRA_SRCS}
61+
LIBS ${LIBS_POOL_SCALABLE})
62+
target_include_directories(scalable_pool PRIVATE ${TBB_INCLUDE_DIRS})
63+
target_compile_definitions(scalable_pool PUBLIC ${POOL_COMPILE_DEFINITIONS})
64+
add_library(${PROJECT_NAME}::scalable_pool ALIAS scalable_pool)
65+
install(TARGETS scalable_pool
66+
EXPORT ${PROJECT_NAME}-targets
67+
)
7668
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)