Skip to content

Avoid using non-existing symbols in .map #646

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,18 @@ else()
)
endif()

set(UMF_OPTIONAL_SYMBOLS_LINUX "")
set(UMF_OPTIONAL_SYMBOLS_WINDOWS "")

# Conditional configuration for Level Zero provider
if(UMF_BUILD_LEVEL_ZERO_PROVIDER)
add_optional_symbol(umfLevelZeroMemoryProviderOps)
endif()

if(NOT UMF_DISABLE_HWLOC)
add_optional_symbol(umfOsMemoryProviderOps)
endif()

add_subdirectory(src)

if(UMF_BUILD_TESTS)
Expand All @@ -408,17 +420,6 @@ if(UMF_BUILD_EXAMPLES)
endif()
endif()

# Conditional configuration for Level Zero provider
if(UMF_BUILD_LEVEL_ZERO_PROVIDER)
set(OPTIONAL_SYMBOLS "umfLevelZeroMemoryProviderOps")
else()
set(OPTIONAL_SYMBOLS "")
endif()

# Configure the DEF file based on whether Level Zero provider is built
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/libumf.def.in"
"${CMAKE_CURRENT_BINARY_DIR}/src/libumf.def" @ONLY)

if(UMF_FORMAT_CODE_STYLE)
find_program(CLANG_FORMAT NAMES clang-format-15 clang-format-15.0
clang-format)
Expand Down
9 changes: 9 additions & 0 deletions cmake/helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -417,3 +417,12 @@ macro(add_sanitizer_flag flag)

set(CMAKE_REQUIRED_FLAGS ${SAVED_CMAKE_REQUIRED_FLAGS})
endmacro()

function(add_optional_symbol symbol)
set(UMF_OPTIONAL_SYMBOLS_WINDOWS
"${UMF_OPTIONAL_SYMBOLS_WINDOWS} \n ${symbol}"
PARENT_SCOPE)
set(UMF_OPTIONAL_SYMBOLS_LINUX
"${UMF_OPTIONAL_SYMBOLS_LINUX} \n ${symbol};"
PARENT_SCOPE)
endfunction()
23 changes: 22 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,29 @@ if(NOT UMF_DISABLE_HWLOC)
provider/provider_os_memory_windows.c)

set(UMF_LIBS ${UMF_LIBS} ${LIBHWLOC_LIBRARIES})

if(NOT WINDOWS)
add_optional_symbol(umfMemspaceCreateFromNumaArray)
add_optional_symbol(umfMemspaceHighestBandwidthGet)
add_optional_symbol(umfMemspaceHighestCapacityGet)
add_optional_symbol(umfMemspaceHostAllGet)
add_optional_symbol(umfMemspaceLowestLatencyGet)
endif()
endif()

if(WINDOWS)
message(STATUS "UMF_OPTIONAL_SYMBOLS: ${UMF_OPTIONAL_SYMBOLS_WINDOWS}")
else()
message(STATUS "UMF_OPTIONAL_SYMBOLS: ${UMF_OPTIONAL_SYMBOLS_LINUX}")
endif()

# Configure the DEF file based on whether Level Zero provider is built
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/libumf.def.in"
"${CMAKE_CURRENT_BINARY_DIR}/libumf.def" @ONLY)

configure_file("${CMAKE_CURRENT_SOURCE_DIR}/libumf.map.in"
"${CMAKE_CURRENT_BINARY_DIR}/libumf.map" @ONLY)

set(UMF_PRIVATE_LIBRARY_DIRS ${UMF_PRIVATE_LIBRARY_DIRS}
${LIBHWLOC_LIBRARY_DIRS})

Expand All @@ -140,7 +161,7 @@ if(UMF_BUILD_SHARED_LIBRARY)
TYPE SHARED
SRCS ${UMF_SOURCES}
LIBS ${UMF_LIBS} ${HWLOC_LIB}
LINUX_MAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/libumf.map
LINUX_MAP_FILE ${CMAKE_CURRENT_BINARY_DIR}/libumf.map
WINDOWS_DEF_FILE ${CMAKE_CURRENT_BINARY_DIR}/libumf.def)
set(UMF_COMMON_COMPILE_DEFINITIONS ${UMF_COMMON_COMPILE_DEFINITIONS}
"UMF_SHARED_LIBRARY")
Expand Down
3 changes: 1 addition & 2 deletions src/libumf.def.in
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ EXPORTS
umfMemspaceMemtargetGet
umfMemtargetGetType
umfOpenIPCHandle
umfOsMemoryProviderOps
umfPoolAlignedMalloc
umfPoolByPtr
umfPoolCalloc
Expand All @@ -62,4 +61,4 @@ EXPORTS
umfProxyPoolOps
umfPutIPCHandle
umfScalablePoolOps
@OPTIONAL_SYMBOLS@
@UMF_OPTIONAL_SYMBOLS_WINDOWS@
8 changes: 1 addition & 7 deletions src/libumf.map → src/libumf.map.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ UMF_1.0 {
umfFree;
umfGetIPCHandle;
umfGetLastFailedMemoryProvider;
umfLevelZeroMemoryProviderOps;
umfMemoryTrackerGetAllocInfo;
umfMemoryProviderAlloc;
umfMemoryProviderAllocationMerge;
Expand All @@ -35,17 +34,11 @@ UMF_1.0 {
umfMempolicyDestroy;
umfMempolicySetCustomSplitPartitions;
umfMempolicySetInterleavePartSize;
umfMemspaceCreateFromNumaArray;
umfMemspaceDestroy;
umfMemspaceMemtargetNum;
umfMemspaceMemtargetGet;
umfMemspaceHighestBandwidthGet;
umfMemspaceHighestCapacityGet;
umfMemspaceHostAllGet;
umfMemspaceLowestLatencyGet;
umfMemtargetGetType;
umfOpenIPCHandle;
umfOsMemoryProviderOps;
umfPoolAlignedMalloc;
umfPoolByPtr;
umfPoolCalloc;
Expand All @@ -62,6 +55,7 @@ UMF_1.0 {
umfProxyPoolOps;
umfPutIPCHandle;
umfScalablePoolOps;
@UMF_OPTIONAL_SYMBOLS_LINUX@
local:
*;
};
Loading