Skip to content

Commit

Permalink
Fixing .dylib/.so for apple configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
khuck committed Mar 20, 2024
1 parent e3bcade commit 9f3e810
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/apex/memory_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ void enable_memory_wrapper() {
static apex_memory_initialized_t apex_memory_initialized = NULL;
void * memory_so;

#if defined(__APPLE__)
memory_so = dlopen("libapex_memory_wrapper.dylib", RTLD_NOW);
#else
memory_so = dlopen("libapex_memory_wrapper.so", RTLD_NOW);
#endif

if (memory_so) {
char const * err;
Expand Down Expand Up @@ -74,7 +78,11 @@ void disable_memory_wrapper() {
static apex_memory_finalized_t apex_memory_finalized = NULL;
void * memory_so;

#if defined(__APPLE__)
memory_so = dlopen("libapex_memory_wrapper.dylib", RTLD_NOW);
#else
memory_so = dlopen("libapex_memory_wrapper.so", RTLD_NOW);
#endif

if (memory_so) {
char const * err;
Expand Down
3 changes: 3 additions & 0 deletions src/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ if(OPENMP_FOUND)
set_property(TEST ExampleOpenMP_Policy APPEND PROPERTY ENVIRONMENT "APEX_PLUGINS=libapex_openmp_policy")
set_property(TEST ExampleOpenMP_Policy APPEND PROPERTY ENVIRONMENT "APEX_OPENMP_SPACE=${PROJECT_SOURCE_DIR}/src/examples/OpenMP_Policy/space.json")
set_property(TEST ExampleOpenMP_Policy APPEND PROPERTY ENVIRONMENT "LD_PRELOAD=${PROJECT_BINARY_DIR}/src/apex/libapex.so:${OMPT_LIBRARY}")
set_property(TEST ExampleOpenMP_Policy APPEND PROPERTY ENVIRONMENT "DYLD_INSERT_LIBRARIES=${PROJECT_BINARY_DIR}/src/apex/libapex.dylib:${OMPT_LIBRARY}")
set_property(TEST ExampleOpenMP_Policy APPEND PROPERTY ENVIRONMENT "DYLD_LIBRARY_PATH=${PROJECT_BINARY_DIR}/src/apex")
set_property(TEST ExampleOpenMP_Policy APPEND PROPERTY ENVIRONMENT "DYLD_FORCE_FLAT_NAMESPACE=1")
endif()
endif(PROCESSOR_COUNT)
endif()
Expand Down
2 changes: 1 addition & 1 deletion src/examples/PeriodicPlugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export BUILDROOT=/path/to/build/directory
export APEX_PLUGINS_PATH=${BUILDROOT}/src/examples/PeriodicPlugin
export APEX_PLUGINS=libapex_periodic_policy
export DYLD_LIBRARY_PATH=${BUILDROOT}/src/apex
export DYLD_INSERT_LIBRARIES=${BUILDROOT}/src/apex/libapex.so:${BUILDROOT}/src/wrappers/libapex_pthread_wrapper.so
export DYLD_INSERT_LIBRARIES=${BUILDROOT}/src/apex/libapex.dylib:${BUILDROOT}/src/wrappers/libapex_pthread_wrapper.dylib
export DYLD_FORCE_FLAT_NAMESPACE=1
```

Expand Down
2 changes: 1 addition & 1 deletion src/scripts/apex_exec
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ while (( "$#" )); do
export HSA_VEN_AMD_AQLPROFILE_LOG=1
export AQLPROFILE_READ_API=1
export ROCP_METRICS=@ROCPROFILER_XML_DIRS@/metrics.xml
export HSA_TOOLS_LIB=@ROCPROFILER_HSA_DIRS@/librocprofiler64.so
export HSA_TOOLS_LIB=@ROCPROFILER_HSA_DIRS@/librocprofiler64${SHLIBX}
export LD_LIBRARY_PATH=@ROCPROFILER_HSA_DIRS@:$LD_LIBRARY_PATH
shift
;;
Expand Down
2 changes: 1 addition & 1 deletion src/unit_tests/C++/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ endif (OPENMP_FOUND)


set_property (TEST test_apex_malloc_cpp APPEND PROPERTY ENVIRONMENT
"LD_PRELOAD=${APEX_BINARY_DIR}/src/wrappers/libapex_memory_wrapper.so")
"LD_PRELOAD=${APEX_BINARY_DIR}/src/wrappers/libapex_memory_wrapper${CMAKE_SHARED_LIBRARY_SUFFIX}")
set_property (TEST test_apex_malloc_cpp APPEND PROPERTY ENVIRONMENT
"APEX_PROC_STAT=0")
set_property (TEST test_apex_malloc_cpp APPEND PROPERTY ENVIRONMENT
Expand Down
4 changes: 4 additions & 0 deletions src/wrappers/dl_auditor.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ void la_preinit(uintptr_t *cookie)
static apex_memory_dl_initialized_t apex_memory_dl_initialized = NULL;
void * memory_so;

#if defined(__APPLE__)
memory_so = dlmopen(LM_ID_BASE, "libapex_memory_wrapper.dylib", RTLD_NOW);
#else
memory_so = dlmopen(LM_ID_BASE, "libapex_memory_wrapper.so", RTLD_NOW);
#endif

if (memory_so) {
char const * err;
Expand Down

0 comments on commit 9f3e810

Please sign in to comment.