Skip to content

Commit

Permalink
Rework how we handle xed to link xed directly into libhpcrun.so and (#…
Browse files Browse the repository at this point in the history
…574)

libhpcrun.o.  This allows us to hide the xed symbols inside our
library in case the application also uses xed.

This now requires xed to be built statically (.a) with fPIC.
  • Loading branch information
mwkrentel authored May 16, 2022
1 parent c96309c commit 97cefae
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 173 deletions.
1 change: 0 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ install-exec-local:
@$(call copy-libs,$(TBB_COPY),$(TBB_LIB_DIR),libtbb.so*)
@$(call copy-libs,$(TBB_COPY),$(TBB_LIB_DIR),libtbbmalloc.so*)
@$(call copy-libs,$(TBB_COPY),$(TBB_LIB_DIR),libtbbmalloc_proxy.so*)
@$(call copy-libs,$(XED2_COPY),$(XED2_LIB_DIR),lib*)
@$(call copy-libs,$(XERCES_COPY),$(XERCES_LIB),libxerces*)
@$(call copy-libs,$(ZLIB_COPY),$(ZLIB_LIB),libz.a libz.so*)

Expand Down
1 change: 0 additions & 1 deletion Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,6 @@ install-exec-local:
@$(call copy-libs,$(TBB_COPY),$(TBB_LIB_DIR),libtbb.so*)
@$(call copy-libs,$(TBB_COPY),$(TBB_LIB_DIR),libtbbmalloc.so*)
@$(call copy-libs,$(TBB_COPY),$(TBB_LIB_DIR),libtbbmalloc_proxy.so*)
@$(call copy-libs,$(XED2_COPY),$(XED2_LIB_DIR),lib*)
@$(call copy-libs,$(XERCES_COPY),$(XERCES_LIB),libxerces*)
@$(call copy-libs,$(ZLIB_COPY),$(ZLIB_LIB),libz.a libz.so*)

Expand Down
84 changes: 26 additions & 58 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -22255,13 +22255,8 @@ fi
# Option: --with-xed=PATH
#-------------------------------------------------

# Now use static and shared libxed. hpcrun requires .so or .a + fPIC,
# hpclink requires .a, and fnbounds, etc can use either. hpcprof-mpi
# requires .a, but only if fully static (Cray).
#
# We support both old XED (2013) with single .a + fPIC and new (2015)
# XED with separate .so and .a without fPIC, so we test if .a can link
# into a shared library.
# Now require static (.a) archive + fPIC for all cases in order to
# hide the xed symbols.

XED2_INC=
XED2_LIB_DIR=no
Expand Down Expand Up @@ -22293,12 +22288,11 @@ case "$XED2" in
if test ! -f "${XED2}/include/xed-interface.h" ; then
as_fn_error $? "invalid xed2 directory: $XED2" "$LINENO" 5
fi
if test ! -f "${XED2}/lib/libxed.so" && test ! -f "${XED2}/lib/libxed.a" ; then
if test ! -f "${XED2}/lib/libxed.a" ; then
as_fn_error $? "invalid xed2 directory: $XED2" "$LINENO" 5
fi
XED2_INC="${XED2}/include"
XED2_LIB_DIR="${XED2}/lib"
XED2_COPY=yes
xed2_avail=yes
num_pkgs=`expr 1 + $num_pkgs`
;;
Expand Down Expand Up @@ -22368,58 +22362,20 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
CFLAGS="$ORIG_CFLAGS"
LIBS="$ORIG_LIBS"
fi

#
# default lib flags: .so if exists, else .a
#
if test -f "${XED2}/lib/libxed.so" ; then
XED2_LIB_FLAGS="-L${XED2}/lib -lxed"
elif test -f "${XED2}/lib/libxed.a" ; then
XED2_LIB_FLAGS="${XED2}/lib/libxed.a"
else
as_fn_error $? "unable to find libxed.so or libxed.a" "$LINENO" 5
fi
#
# hpcrun: .so, or .a + fPIC, else fail
#
if test -f "${XED2}/lib/libxed.so" ; then
XED2_HPCRUN_LIBS="-L${XED2}/lib -lxed"
elif test "$xed2_static_fpic" = yes ; then
XED2_HPCRUN_LIBS="${XED2}/lib/libxed.a"
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unable to build hpcrun: no libxed with -fPIC" >&5
$as_echo "$as_me: WARNING: unable to build hpcrun: no libxed with -fPIC" >&2;}
no_xed_for_hpcrun=yes
fi
#
# hpclink: .a only (with or without -fPIC)
#
if test -f "${XED2}/lib/libxed.a" ; then
XED2_HPCLINK_LIBS="${XED2}/lib/libxed.a"
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unable to build hpclink: no static libxed.a" >&5
$as_echo "$as_me: WARNING: unable to build hpclink: no static libxed.a" >&2;}
no_xed_for_hpclink=yes
fi
#
# hpcprof-mpi: same as hpclink if fully static, else default
#
echo "x$HPCPROFMPI_LT_LDFLAGS" | grep -e all-static >/dev/null 2>&1
if test $? = 0 ; then
XED2_PROF_MPI_LIBS="$XED2_HPCLINK_LIBS"
else
XED2_PROF_MPI_LIBS="$XED2_LIB_FLAGS"
fi
#
# add libirc.a, if exists for k1om
# now require .a archive + fPIC for both hpcrun and hpclink
#
if test -f "${XED2}/lib/libirc.a" ; then
XED2_LIB_FLAGS="${XED2_LIB_FLAGS} ${XED2}/lib/libirc.a"
XED2_HPCRUN_LIBS="${XED2_HPCRUN_LIBS} ${XED2}/lib/libirc.a"
XED2_HPCLINK_LIBS="${XED2_HPCLINK_LIBS} ${XED2}/lib/libirc.a"
XED2_PROF_MPI_LIBS="${XED2_PROF_MPI_LIBS} ${XED2}/lib/libirc.a"
if test "$xed2_static_fpic" = no ; then
as_fn_error $? "libxed.a must be compiled with -fPIC" "$LINENO" 5
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: xed2 lib flags: $XED2_LIB_FLAGS" >&5
$as_echo "$as_me: xed2 lib flags: $XED2_LIB_FLAGS" >&6;}
XED2_LIB_FLAGS="${XED2}/lib/libxed.a"
XED2_HPCRUN_LIBS="${XED2}/lib/libxed.a"
XED2_HPCLINK_LIBS="${XED2}/lib/libxed.a"
XED2_PROF_MPI_LIBS="$XED2_LIB_FLAGS"

{ $as_echo "$as_me:${as_lineno-$LINENO}: xed2 hpcrun libs: $XED2_HPCRUN_LIBS" >&5
$as_echo "$as_me: xed2 hpcrun libs: $XED2_HPCRUN_LIBS" >&6;}
fi


Expand Down Expand Up @@ -28154,6 +28110,18 @@ $as_echo "$as_me: WARNING: Unless you're building hpctoolkit only for docs or ma
$as_echo "$as_me: WARNING: this is probably an error. Rerun configure with:" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: --with-spack=/path/to/spack/install/gcc-x.y.z" >&5
$as_echo "$as_me: WARNING: --with-spack=/path/to/spack/install/gcc-x.y.z" >&2;}

elif test "$OPT_ENABLE_HPCRUN" != yes ; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: " >&5
$as_echo "$as_me: " >&6;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Missing prerequisites for building hpcrun." >&5
$as_echo "$as_me: WARNING: Missing prerequisites for building hpcrun." >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unless you're building hpctoolkit only for docs or make dist," >&5
$as_echo "$as_me: WARNING: Unless you're building hpctoolkit only for docs or make dist," >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: this is probably an error. Rerun configure with:" >&5
$as_echo "$as_me: WARNING: this is probably an error. Rerun configure with:" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: --with-spack=/path/to/spack/install/gcc-x.y.z" >&5
$as_echo "$as_me: WARNING: --with-spack=/path/to/spack/install/gcc-x.y.z" >&2;}
fi

if test "$warn_non_gnu" = yes ; then
Expand Down
75 changes: 20 additions & 55 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -3523,13 +3523,8 @@ AC_SUBST([TBB_COPY])
# Option: --with-xed=PATH
#-------------------------------------------------

# Now use static and shared libxed. hpcrun requires .so or .a + fPIC,
# hpclink requires .a, and fnbounds, etc can use either. hpcprof-mpi
# requires .a, but only if fully static (Cray).
#
# We support both old XED (2013) with single .a + fPIC and new (2015)
# XED with separate .so and .a without fPIC, so we test if .a can link
# into a shared library.
# Now require static (.a) archive + fPIC for all cases in order to
# hide the xed symbols.

XED2_INC=
XED2_LIB_DIR=no
Expand Down Expand Up @@ -3559,12 +3554,11 @@ case "$XED2" in
if test ! -f "${XED2}/include/xed-interface.h" ; then
AC_MSG_ERROR([invalid xed2 directory: $XED2])
fi
if test ! -f "${XED2}/lib/libxed.so" && test ! -f "${XED2}/lib/libxed.a" ; then
if test ! -f "${XED2}/lib/libxed.a" ; then
AC_MSG_ERROR([invalid xed2 directory: $XED2])
fi
XED2_INC="${XED2}/include"
XED2_LIB_DIR="${XED2}/lib"
XED2_COPY=yes
xed2_avail=yes
num_pkgs=`expr 1 + $num_pkgs`
;;
Expand Down Expand Up @@ -3610,55 +3604,19 @@ int my_xed_init(void)
CFLAGS="$ORIG_CFLAGS"
LIBS="$ORIG_LIBS"
fi

#
# default lib flags: .so if exists, else .a
#
if test -f "${XED2}/lib/libxed.so" ; then
XED2_LIB_FLAGS="-L${XED2}/lib -lxed"
elif test -f "${XED2}/lib/libxed.a" ; then
XED2_LIB_FLAGS="${XED2}/lib/libxed.a"
else
AC_MSG_ERROR([unable to find libxed.so or libxed.a])
fi
#
# hpcrun: .so, or .a + fPIC, else fail
#
if test -f "${XED2}/lib/libxed.so" ; then
XED2_HPCRUN_LIBS="-L${XED2}/lib -lxed"
elif test "$xed2_static_fpic" = yes ; then
XED2_HPCRUN_LIBS="${XED2}/lib/libxed.a"
else
AC_MSG_WARN([unable to build hpcrun: no libxed with -fPIC])
no_xed_for_hpcrun=yes
fi
#
# hpclink: .a only (with or without -fPIC)
#
if test -f "${XED2}/lib/libxed.a" ; then
XED2_HPCLINK_LIBS="${XED2}/lib/libxed.a"
else
AC_MSG_WARN([unable to build hpclink: no static libxed.a])
no_xed_for_hpclink=yes
fi
#
# hpcprof-mpi: same as hpclink if fully static, else default
#
echo "x$HPCPROFMPI_LT_LDFLAGS" | grep -e all-static >/dev/null 2>&1
if test $? = 0 ; then
XED2_PROF_MPI_LIBS="$XED2_HPCLINK_LIBS"
else
XED2_PROF_MPI_LIBS="$XED2_LIB_FLAGS"
fi
#
# add libirc.a, if exists for k1om
# now require .a archive + fPIC for both hpcrun and hpclink
#
if test -f "${XED2}/lib/libirc.a" ; then
XED2_LIB_FLAGS="${XED2_LIB_FLAGS} ${XED2}/lib/libirc.a"
XED2_HPCRUN_LIBS="${XED2_HPCRUN_LIBS} ${XED2}/lib/libirc.a"
XED2_HPCLINK_LIBS="${XED2_HPCLINK_LIBS} ${XED2}/lib/libirc.a"
XED2_PROF_MPI_LIBS="${XED2_PROF_MPI_LIBS} ${XED2}/lib/libirc.a"
if test "$xed2_static_fpic" = no ; then
AC_MSG_ERROR([libxed.a must be compiled with -fPIC])
fi
AC_MSG_NOTICE([xed2 lib flags: $XED2_LIB_FLAGS])
XED2_LIB_FLAGS="${XED2}/lib/libxed.a"
XED2_HPCRUN_LIBS="${XED2}/lib/libxed.a"
XED2_HPCLINK_LIBS="${XED2}/lib/libxed.a"
XED2_PROF_MPI_LIBS="$XED2_LIB_FLAGS"

AC_MSG_NOTICE([xed2 hpcrun libs: $XED2_HPCRUN_LIBS])
fi

AC_SUBST([XED2_INC])
Expand Down Expand Up @@ -5907,6 +5865,13 @@ if test "x$with_spack" = xno && test "$num_pkgs" -lt 7 ; then
AC_MSG_WARN([Unless you're building hpctoolkit only for docs or make dist,])
AC_MSG_WARN([this is probably an error. Rerun configure with:])
AC_MSG_WARN([ --with-spack=/path/to/spack/install/gcc-x.y.z])

elif test "$OPT_ENABLE_HPCRUN" != yes ; then
AC_MSG_NOTICE([])
AC_MSG_WARN([Missing prerequisites for building hpcrun.])
AC_MSG_WARN([Unless you're building hpctoolkit only for docs or make dist,])
AC_MSG_WARN([this is probably an error. Rerun configure with:])
AC_MSG_WARN([ --with-spack=/path/to/spack/install/gcc-x.y.z])
fi

if test "$warn_non_gnu" = yes ; then
Expand Down
7 changes: 5 additions & 2 deletions src/tool/hpcrun/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,11 @@ libhpcrun_o_LDADD = \
$(OUR_LIBUNWIND_A) \
$(OUR_LZMA_A)

if HOST_CPU_X86_FAMILY
libhpcrun_la_LIBADD += $(XED2_HPCRUN_LIBS)
libhpcrun_o_LDADD += $(XED2_HPCRUN_LIBS)
endif


#-----------------------------------------------------------
# whirled peas
Expand Down Expand Up @@ -929,7 +934,6 @@ if HOST_CPU_X86_FAMILY
libhpcrun_o_CPPFLAGS += $(MY_X86_INCLUDE_DIRS)
libhpcrun_la_CCASFLAGS = $(AM_CCASFLAGS)
libhpcrun_o_CCASFLAGS = $(AM_CCASFLAGS)
libhpcrun_la_LDFLAGS += $(XED2_HPCRUN_LIBS)
libhpcrun_o_LDADD += $(XED2_HPCLINK_LIBS)
libhpcrun_ga_la_CPPFLAGS += $(MY_X86_INCLUDE_DIRS)
libhpcrun_ga_wrap_a_CPPFLAGS += $(MY_X86_INCLUDE_DIRS)
Expand Down Expand Up @@ -1036,7 +1040,6 @@ endif
if UNW_X86
UNW_SOURCE_FILES = $(UNW_X86_FILES)
UNW_INCLUDE_DIRS = $(UNW_X86_INCLUDE_DIRS)
UNW_DYNAMIC_LD_FLAGS = $(XED2_HPCRUN_LIBS)
UNW_STATIC_LD_FLAGS = $(XED2_HPCLINK_LIBS)
endif

Expand Down
Loading

0 comments on commit 97cefae

Please sign in to comment.