Commit f759e67f authored by Shane Snyder's avatar Shane Snyder

simplify static linking implementation

parent 50c4669d
......@@ -20,7 +20,7 @@ DARSHAN_LOG_FORMAT = $(srcdir)/../darshan-log-format.h
DARSHAN_VERSION = @DARSHAN_VERSION@
ifndef DISABLE_STATIC_LIB
all: lib/libdarshan.a lib/libdarshan-stubs.a
all: lib/libdarshan.a
endif
ifndef DISABLE_LDPRELOAD
all: lib/libdarshan.so
......@@ -155,18 +155,12 @@ lib/darshan-hdf5.o: lib/darshan-hdf5.c darshan.h darshan-common.h $(DARSHAN_LOG_
lib/darshan-hdf5.po: lib/darshan-hdf5.c darshan.h darshan-dynamic.h darshan-common.h $(DARSHAN_LOG_FORMAT) $(srcdir)/../darshan-hdf5-log-format.h | lib
$(CC) $(CFLAGS_SHARED) -c $< -o $@
lib/darshan-hdf5-stubs.o: lib/darshan-hdf5-stubs.c darshan.h $(DARSHAN_LOG_FORMAT) | lib
$(CC) $(CFLAGS) -c $< -o $@
lib/darshan-pnetcdf.o: lib/darshan-pnetcdf.c darshan.h darshan-common.h $(DARSHAN_LOG_FORMAT) $(srcdir)/../darshan-pnetcdf-log-format.h | lib
$(CC) $(CFLAGS) -c $< -o $@
lib/darshan-pnetcdf.po: lib/darshan-pnetcdf.c darshan.h darshan-dynamic.h darshan-common.h $(DARSHAN_LOG_FORMAT) $(srcdir)/../darshan-pnetcdf-log-format.h | lib
$(CC) $(CFLAGS_SHARED) -c $< -o $@
lib/darshan-pnetcdf-stubs.o: lib/darshan-pnetcdf-stubs.c darshan.h $(DARSHAN_LOG_FORMAT) | lib
$(CC) $(CFLAGS) -c $< -o $@
lib/darshan-lustre.o: lib/darshan-lustre.c darshan-lustre.h darshan.h darshan-common.h $(DARSHAN_LOG_FORMAT) $(srcdir)/../darshan-lustre-log-format.h | lib
$(CC) $(CFLAGS) -c $< -o $@
......@@ -210,20 +204,11 @@ lib/libdarshan.a: lib/darshan-core-init-finalize.o lib/darshan-core.o lib/darsha
lib/libdarshan.so: lib/darshan-core-init-finalize.po lib/darshan-core.po lib/darshan-common.po $(DARSHAN_DYNAMIC_MOD_OBJS) lib/lookup3.po lib/lookup8.po
$(CC) $(CFLAGS_SHARED) $(LDFLAGS) -o $@ $^ -lpthread -lrt -lz -ldl
ifdef BUILD_HDF5_MODULE
lib/libdarshan-stubs.a: lib/darshan-hdf5-stubs.o lib/darshan-pnetcdf-stubs.o
ar rcs $@ $^
else
lib/libdarshan-stubs.a: lib/darshan-pnetcdf-stubs.o
ar rcs $@ $^
endif
install:: all
install -d $(DESTDIR)$(libdir)
ifndef DISABLE_STATIC_LIB
install -m 755 lib/libdarshan.a $(DESTDIR)$(libdir)
install -m 755 lib/libdarshan-stubs.a $(DESTDIR)$(libdir)
endif
ifndef DISABLE_LDPRELOAD
install -m 755 lib/libdarshan.so $(DESTDIR)$(libdir)
......
......@@ -12,7 +12,7 @@ DARSHAN_LD_FLAGS="@LDFLAGS@"
# app used a library which in turn used one of those HLLs).
PRE_LD_FLAGS="-L$DARSHAN_LIB_PATH $DARSHAN_LD_FLAGS -ldarshan -lz -Wl,@$DARSHAN_SHARE_PATH/ld-opts/darshan-base-ld-opts"
POST_LD_FLAGS="-L$DARSHAN_LIB_PATH -Wl,--start-group -ldarshan -ldarshan-stubs -Wl,--end-group -lz -lrt -lpthread"
POST_LD_FLAGS="-L$DARSHAN_LIB_PATH -ldarshan -lz -lrt -lpthread"
# NOTE:
# - when dynamic linking there is no need for wrapping options, we simply
......
/*
* Copyright (C) 2015 University of Chicago.
* See COPYRIGHT notice in top-level directory.
*
*/
/* This file contains stubs for the H5F functions intercepted by Darshan.
* They are defined as weak symbols in order to satisfy dependencies of the
* hdf5 wrappers in cases where hdf5 is not being used.
*/
#include "darshan-runtime-config.h"
#include <stdio.h>
#include <pthread.h>
#include <string.h>
#include "mpi.h"
#include "darshan.h"
/* hope this doesn't change any time soon */
typedef int hid_t;
typedef int herr_t;
hid_t H5Fcreate(const char *filename, unsigned flags,
hid_t create_plist, hid_t access_plist) __attribute__((weak));
hid_t H5Fcreate(const char *filename, unsigned flags,
hid_t create_plist, hid_t access_plist)
{
int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if(rank == 0)
{
fprintf(stderr, "WARNING: Darshan H5Fcreate() stub called; this is probably the result of a link-time problem.\n");
}
return(-1);
}
hid_t H5Fopen(const char *filename, unsigned flags,
hid_t access_plist) __attribute__((weak));
hid_t H5Fopen(const char *filename, unsigned flags,
hid_t access_plist)
{
int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if(rank == 0)
{
fprintf(stderr, "WARNING: Darshan H5Fopen() stub called; this is probably the result of a link-time problem.\n");
}
return(-1);
}
herr_t H5Fclose(hid_t file_id) __attribute__((weak));
herr_t H5Fclose(hid_t file_id)
{
int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if(rank == 0)
{
fprintf(stderr, "WARNING: Darshan H5Fclose() stub called; this is probably the result of a link-time problem.\n");
}
return(-1);
}
herr_t H5get_libversion(unsigned *majnum, unsigned *minnum, unsigned *relnum) __attribute__((weak));
herr_t H5get_libversion(unsigned *majnum, unsigned *minnum, unsigned *relnum)
{
int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if(rank == 0)
{
fprintf(stderr, "WARNING: Darshan H5get_libversion() stub called; this is probably the result of a link-time problem.\n");
}
return(-1);
}
/*
* Local variables:
* c-indent-level: 4
* c-basic-offset: 4
* End:
*
* vim: ts=8 sts=4 sw=4 expandtab
*/
/*
* Copyright (C) 2015 University of Chicago.
* See COPYRIGHT notice in top-level directory.
*
*/
/* This file contains stubs for the ncmpi functions intercepted by Darshan.
* They are defined as weak symbols in order to satisfy dependencies of the
* pnetcdf wrappers in cases where pnetcdf is not being used.
*/
#include "darshan-runtime-config.h"
#include <stdio.h>
#include <pthread.h>
#include <string.h>
#include "mpi.h"
#include "darshan.h"
int ncmpi_create(MPI_Comm comm, const char *path,
int cmode, MPI_Info info, int *ncidp) __attribute__((weak));
int ncmpi_create(MPI_Comm comm, const char *path,
int cmode, MPI_Info info, int *ncidp)
{
int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if(rank == 0)
{
fprintf(stderr, "WARNING: Darshan ncmpi_create() stub called; this is probably the result of a link-time problem.\n");
}
return(-1);
}
int ncmpi_open(MPI_Comm comm, const char *path,
int omode, MPI_Info info, int *ncidp) __attribute__((weak));
int ncmpi_open(MPI_Comm comm, const char *path,
int omode, MPI_Info info, int *ncidp)
{
int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if(rank == 0)
{
fprintf(stderr, "WARNING: Darshan ncmpi_open() stub called; this is probably the result of a link-time problem.\n");
}
return(-1);
}
int ncmpi_close(int ncid) __attribute__((weak));
int ncmpi_close(int ncid)
{
int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if(rank == 0)
{
fprintf(stderr, "WARNING: Darshan ncmpi_close() stub called; this is probably the result of a link-time problem.\n");
}
return(-1);
}
/*
* Local variables:
* c-indent-level: 4
* c-basic-offset: 4
* End:
*
* vim: ts=8 sts=4 sw=4 expandtab
*/
......@@ -16,4 +16,4 @@ darshan_linkopts="-Wl,@${darshan_share}/ld-opts/darshan-base-ld-opts"
Cflags:
Libs: -ldarshan
Libs.private: ${darshan_linkopts} ${darshan_libdir} -lfmpich -lmpichcxx -Wl,--start-group -ldarshan -ldarshan-stubs -Wl,--end-group
Libs.private: ${darshan_linkopts} ${darshan_libdir} -lfmpich -lmpichcxx -ldarshan
--undefined=__wrap_H5Fcreate
--wrap=H5Fcreate
--wrap=H5Fopen
--wrap=H5Fclose
--undefined=__wrap_ncmpi_create
--wrap=ncmpi_create
--wrap=ncmpi_open
--wrap=ncmpi_close
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