Commit 910486f8 authored by Shane Snyder's avatar Shane Snyder

changes to get new wrappers working for static builds

parent fc3d349d
...@@ -31,8 +31,8 @@ ...@@ -31,8 +31,8 @@
/* creates P* variant of MPI symbols for LD_PRELOAD so that we can handle /* creates P* variant of MPI symbols for LD_PRELOAD so that we can handle
* language bindings that map to MPI or PMPI symbols under the covers. * language bindings that map to MPI or PMPI symbols under the covers.
*/ */
#define DARSHAN_PMPI_MAP(__func,__ret,__args,__fcall) \ #define DARSHAN_WRAPPER_MAP(__func,__ret,__args,__fcall) \
__ret P ## __func __args { \ __ret __func __args { \
__ret i; \ __ret i; \
i = __fcall; \ i = __fcall; \
return i; \ return i; \
...@@ -47,11 +47,8 @@ ...@@ -47,11 +47,8 @@
{ \ { \
__real_ ## __func = dlsym(RTLD_NEXT, #__func); \ __real_ ## __func = dlsym(RTLD_NEXT, #__func); \
if(!(__real_ ## __func)) { \ if(!(__real_ ## __func)) { \
__real_ ## __func = dlsym(RTLD_NEXT, "P" #__func); \ fprintf(stderr, "Darshan failed to map symbol: %s\n", #__func); \
if(!(__real_ ## __func)) { \ exit(1); \
fprintf(stderr, "Darshan failed to map symbol: %s\n", #__func); \
exit(1); \
} \
} \ } \
} }
...@@ -62,7 +59,15 @@ ...@@ -62,7 +59,15 @@
#define DARSHAN_DECL(__name) __wrap_ ## __name #define DARSHAN_DECL(__name) __wrap_ ## __name
#define DARSHAN_PMPI_MAP(__func,__ret,__args,__fcall) /* creates P* variant of MPI symbols for static linking so that we can handle
* language bindings that map to MPI or PMPI symbols under the covers.
*/
#define DARSHAN_WRAPPER_MAP(__func,__ret,__args,__fcall) \
__ret __wrap_ ## __func __args { \
__ret i; \
i = __wrap_ ## __fcall; \
return i; \
}
#define MAP_OR_FAIL(__func) #define MAP_OR_FAIL(__func)
......
...@@ -17,18 +17,18 @@ ...@@ -17,18 +17,18 @@
#include "darshan-core.h" #include "darshan-core.h"
#include "darshan-dynamic.h" #include "darshan-dynamic.h"
DARSHAN_FORWARD_DECL(MPI_Finalize, int, ()); DARSHAN_FORWARD_DECL(PMPI_Finalize, int, ());
DARSHAN_FORWARD_DECL(MPI_Init, int, (int *argc, char ***argv)); DARSHAN_FORWARD_DECL(PMPI_Init, int, (int *argc, char ***argv));
DARSHAN_FORWARD_DECL(MPI_Init_thread, int, (int *argc, char ***argv, int required, int *provided)); DARSHAN_FORWARD_DECL(PMPI_Init_thread, int, (int *argc, char ***argv, int required, int *provided));
DARSHAN_PMPI_MAP(MPI_Init, int, (int *argc, char ***argv), MPI_Init(argc,argv)) DARSHAN_WRAPPER_MAP(PMPI_Init, int, (int *argc, char ***argv), MPI_Init(argc,argv))
int DARSHAN_DECL(MPI_Init)(int *argc, char ***argv) int DARSHAN_DECL(MPI_Init)(int *argc, char ***argv)
{ {
int ret; int ret;
MAP_OR_FAIL(MPI_Init); MAP_OR_FAIL(PMPI_Init);
ret = __real_MPI_Init(argc, argv); ret = __real_PMPI_Init(argc, argv);
if(ret != MPI_SUCCESS) if(ret != MPI_SUCCESS)
{ {
return(ret); return(ret);
...@@ -47,14 +47,14 @@ int DARSHAN_DECL(MPI_Init)(int *argc, char ***argv) ...@@ -47,14 +47,14 @@ int DARSHAN_DECL(MPI_Init)(int *argc, char ***argv)
return(ret); return(ret);
} }
DARSHAN_PMPI_MAP(MPI_Init_thread, int, (int *argc, char ***argv, int required, int *provided), MPI_Init_thread(argc,argv,required,provided)) DARSHAN_WRAPPER_MAP(PMPI_Init_thread, int, (int *argc, char ***argv, int required, int *provided), MPI_Init_thread(argc,argv,required,provided))
int DARSHAN_DECL(MPI_Init_thread)(int *argc, char ***argv, int required, int *provided) int DARSHAN_DECL(MPI_Init_thread)(int *argc, char ***argv, int required, int *provided)
{ {
int ret; int ret;
MAP_OR_FAIL(MPI_Init_thread); MAP_OR_FAIL(PMPI_Init_thread);
ret = __real_MPI_Init_thread(argc, argv, required, provided); ret = __real_PMPI_Init_thread(argc, argv, required, provided);
if(ret != MPI_SUCCESS) if(ret != MPI_SUCCESS)
{ {
return(ret); return(ret);
...@@ -73,16 +73,16 @@ int DARSHAN_DECL(MPI_Init_thread)(int *argc, char ***argv, int required, int *pr ...@@ -73,16 +73,16 @@ int DARSHAN_DECL(MPI_Init_thread)(int *argc, char ***argv, int required, int *pr
return(ret); return(ret);
} }
DARSHAN_PMPI_MAP(MPI_Finalize, int, (void), MPI_Finalize()) DARSHAN_WRAPPER_MAP(PMPI_Finalize, int, (void), MPI_Finalize())
int DARSHAN_DECL(MPI_Finalize)(void) int DARSHAN_DECL(MPI_Finalize)(void)
{ {
int ret; int ret;
MAP_OR_FAIL(MPI_Finalize); MAP_OR_FAIL(PMPI_Finalize);
darshan_core_shutdown(); darshan_core_shutdown();
ret = __real_MPI_Finalize(); ret = __real_PMPI_Finalize();
return(ret); return(ret);
} }
......
This diff is collapsed.
--undefined=MPI_Init --undefined=MPI_Init
--undefined=MPI_Wtime --undefined=MPI_Wtime
--wrap=MPI_Init
--wrap=MPI_Init_thread
--wrap=MPI_Finalize
--wrap=PMPI_Init
--wrap=PMPI_Init_thread
--wrap=PMPI_Finalize
@@darshan_share_path@/ld-opts/darshan-posix-ld-opts @@darshan_share_path@/ld-opts/darshan-posix-ld-opts
@@darshan_share_path@/ld-opts/darshan-pnetcdf-ld-opts @@darshan_share_path@/ld-opts/darshan-pnetcdf-ld-opts
@@darshan_share_path@/ld-opts/darshan-stdio-ld-opts @@darshan_share_path@/ld-opts/darshan-stdio-ld-opts
......
--wrap=MPI_Finalize
--wrap=MPI_Init
--wrap=MPI_Init_thread
--wrap=MPI_File_close --wrap=MPI_File_close
--wrap=MPI_File_iread_at --wrap=MPI_File_iread_at
--wrap=MPI_File_iread --wrap=MPI_File_iread
...@@ -43,3 +40,45 @@ ...@@ -43,3 +40,45 @@
--wrap=MPI_File_write_ordered --wrap=MPI_File_write_ordered
--wrap=MPI_File_write_shared --wrap=MPI_File_write_shared
--wrap=MPI_File_write_shared --wrap=MPI_File_write_shared
--wrap=PMPI_File_close
--wrap=PMPI_File_iread_at
--wrap=PMPI_File_iread
--wrap=PMPI_File_iread_shared
--wrap=PMPI_File_iwrite_at
--wrap=PMPI_File_iwrite_at
--wrap=PMPI_File_iwrite
--wrap=PMPI_File_iwrite
--wrap=PMPI_File_iwrite_shared
--wrap=PMPI_File_iwrite_shared
--wrap=PMPI_File_open
--wrap=PMPI_File_open
--wrap=PMPI_File_read_all_begin
--wrap=PMPI_File_read_all
--wrap=PMPI_File_read_at_all
--wrap=PMPI_File_read_at_all_begin
--wrap=PMPI_File_read_at
--wrap=PMPI_File_read
--wrap=PMPI_File_read_ordered_begin
--wrap=PMPI_File_read_ordered
--wrap=PMPI_File_read_shared
--wrap=PMPI_File_set_view
--wrap=PMPI_File_set_view
--wrap=PMPI_File_sync
--wrap=PMPI_File_write_all_begin
--wrap=PMPI_File_write_all_begin
--wrap=PMPI_File_write_all
--wrap=PMPI_File_write_all
--wrap=PMPI_File_write_at_all_begin
--wrap=PMPI_File_write_at_all_begin
--wrap=PMPI_File_write_at_all
--wrap=PMPI_File_write_at_all
--wrap=PMPI_File_write_at
--wrap=PMPI_File_write_at
--wrap=PMPI_File_write
--wrap=PMPI_File_write
--wrap=PMPI_File_write_ordered_begin
--wrap=PMPI_File_write_ordered_begin
--wrap=PMPI_File_write_ordered
--wrap=PMPI_File_write_ordered
--wrap=PMPI_File_write_shared
--wrap=PMPI_File_write_shared
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment