Skip to content
This repository was archived by the owner on Apr 2, 2025. It is now read-only.

Commit 97cefae

Browse files
authored
Rework how we handle xed to link xed directly into libhpcrun.so and (#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.
1 parent c96309c commit 97cefae

6 files changed

Lines changed: 105 additions & 173 deletions

File tree

Makefile.am

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ install-exec-local:
152152
@$(call copy-libs,$(TBB_COPY),$(TBB_LIB_DIR),libtbb.so*)
153153
@$(call copy-libs,$(TBB_COPY),$(TBB_LIB_DIR),libtbbmalloc.so*)
154154
@$(call copy-libs,$(TBB_COPY),$(TBB_LIB_DIR),libtbbmalloc_proxy.so*)
155-
@$(call copy-libs,$(XED2_COPY),$(XED2_LIB_DIR),lib*)
156155
@$(call copy-libs,$(XERCES_COPY),$(XERCES_LIB),libxerces*)
157156
@$(call copy-libs,$(ZLIB_COPY),$(ZLIB_LIB),libz.a libz.so*)
158157

Makefile.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,6 @@ install-exec-local:
910910
@$(call copy-libs,$(TBB_COPY),$(TBB_LIB_DIR),libtbb.so*)
911911
@$(call copy-libs,$(TBB_COPY),$(TBB_LIB_DIR),libtbbmalloc.so*)
912912
@$(call copy-libs,$(TBB_COPY),$(TBB_LIB_DIR),libtbbmalloc_proxy.so*)
913-
@$(call copy-libs,$(XED2_COPY),$(XED2_LIB_DIR),lib*)
914913
@$(call copy-libs,$(XERCES_COPY),$(XERCES_LIB),libxerces*)
915914
@$(call copy-libs,$(ZLIB_COPY),$(ZLIB_LIB),libz.a libz.so*)
916915

configure

Lines changed: 26 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -22255,13 +22255,8 @@ fi
2225522255
# Option: --with-xed=PATH
2225622256
#-------------------------------------------------
2225722257

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

2226622261
XED2_INC=
2226722262
XED2_LIB_DIR=no
@@ -22293,12 +22288,11 @@ case "$XED2" in
2229322288
if test ! -f "${XED2}/include/xed-interface.h" ; then
2229422289
as_fn_error $? "invalid xed2 directory: $XED2" "$LINENO" 5
2229522290
fi
22296-
if test ! -f "${XED2}/lib/libxed.so" && test ! -f "${XED2}/lib/libxed.a" ; then
22291+
if test ! -f "${XED2}/lib/libxed.a" ; then
2229722292
as_fn_error $? "invalid xed2 directory: $XED2" "$LINENO" 5
2229822293
fi
2229922294
XED2_INC="${XED2}/include"
2230022295
XED2_LIB_DIR="${XED2}/lib"
22301-
XED2_COPY=yes
2230222296
xed2_avail=yes
2230322297
num_pkgs=`expr 1 + $num_pkgs`
2230422298
;;
@@ -22368,58 +22362,20 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
2236822362
CFLAGS="$ORIG_CFLAGS"
2236922363
LIBS="$ORIG_LIBS"
2237022364
fi
22365+
2237122366
#
22372-
# default lib flags: .so if exists, else .a
22373-
#
22374-
if test -f "${XED2}/lib/libxed.so" ; then
22375-
XED2_LIB_FLAGS="-L${XED2}/lib -lxed"
22376-
elif test -f "${XED2}/lib/libxed.a" ; then
22377-
XED2_LIB_FLAGS="${XED2}/lib/libxed.a"
22378-
else
22379-
as_fn_error $? "unable to find libxed.so or libxed.a" "$LINENO" 5
22380-
fi
22381-
#
22382-
# hpcrun: .so, or .a + fPIC, else fail
22383-
#
22384-
if test -f "${XED2}/lib/libxed.so" ; then
22385-
XED2_HPCRUN_LIBS="-L${XED2}/lib -lxed"
22386-
elif test "$xed2_static_fpic" = yes ; then
22387-
XED2_HPCRUN_LIBS="${XED2}/lib/libxed.a"
22388-
else
22389-
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unable to build hpcrun: no libxed with -fPIC" >&5
22390-
$as_echo "$as_me: WARNING: unable to build hpcrun: no libxed with -fPIC" >&2;}
22391-
no_xed_for_hpcrun=yes
22392-
fi
22393-
#
22394-
# hpclink: .a only (with or without -fPIC)
22395-
#
22396-
if test -f "${XED2}/lib/libxed.a" ; then
22397-
XED2_HPCLINK_LIBS="${XED2}/lib/libxed.a"
22398-
else
22399-
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unable to build hpclink: no static libxed.a" >&5
22400-
$as_echo "$as_me: WARNING: unable to build hpclink: no static libxed.a" >&2;}
22401-
no_xed_for_hpclink=yes
22402-
fi
22403-
#
22404-
# hpcprof-mpi: same as hpclink if fully static, else default
22405-
#
22406-
echo "x$HPCPROFMPI_LT_LDFLAGS" | grep -e all-static >/dev/null 2>&1
22407-
if test $? = 0 ; then
22408-
XED2_PROF_MPI_LIBS="$XED2_HPCLINK_LIBS"
22409-
else
22410-
XED2_PROF_MPI_LIBS="$XED2_LIB_FLAGS"
22411-
fi
22412-
#
22413-
# add libirc.a, if exists for k1om
22367+
# now require .a archive + fPIC for both hpcrun and hpclink
2241422368
#
22415-
if test -f "${XED2}/lib/libirc.a" ; then
22416-
XED2_LIB_FLAGS="${XED2_LIB_FLAGS} ${XED2}/lib/libirc.a"
22417-
XED2_HPCRUN_LIBS="${XED2_HPCRUN_LIBS} ${XED2}/lib/libirc.a"
22418-
XED2_HPCLINK_LIBS="${XED2_HPCLINK_LIBS} ${XED2}/lib/libirc.a"
22419-
XED2_PROF_MPI_LIBS="${XED2_PROF_MPI_LIBS} ${XED2}/lib/libirc.a"
22369+
if test "$xed2_static_fpic" = no ; then
22370+
as_fn_error $? "libxed.a must be compiled with -fPIC" "$LINENO" 5
2242022371
fi
22421-
{ $as_echo "$as_me:${as_lineno-$LINENO}: xed2 lib flags: $XED2_LIB_FLAGS" >&5
22422-
$as_echo "$as_me: xed2 lib flags: $XED2_LIB_FLAGS" >&6;}
22372+
XED2_LIB_FLAGS="${XED2}/lib/libxed.a"
22373+
XED2_HPCRUN_LIBS="${XED2}/lib/libxed.a"
22374+
XED2_HPCLINK_LIBS="${XED2}/lib/libxed.a"
22375+
XED2_PROF_MPI_LIBS="$XED2_LIB_FLAGS"
22376+
22377+
{ $as_echo "$as_me:${as_lineno-$LINENO}: xed2 hpcrun libs: $XED2_HPCRUN_LIBS" >&5
22378+
$as_echo "$as_me: xed2 hpcrun libs: $XED2_HPCRUN_LIBS" >&6;}
2242322379
fi
2242422380

2242522381

@@ -28154,6 +28110,18 @@ $as_echo "$as_me: WARNING: Unless you're building hpctoolkit only for docs or ma
2815428110
$as_echo "$as_me: WARNING: this is probably an error. Rerun configure with:" >&2;}
2815528111
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: --with-spack=/path/to/spack/install/gcc-x.y.z" >&5
2815628112
$as_echo "$as_me: WARNING: --with-spack=/path/to/spack/install/gcc-x.y.z" >&2;}
28113+
28114+
elif test "$OPT_ENABLE_HPCRUN" != yes ; then
28115+
{ $as_echo "$as_me:${as_lineno-$LINENO}: " >&5
28116+
$as_echo "$as_me: " >&6;}
28117+
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Missing prerequisites for building hpcrun." >&5
28118+
$as_echo "$as_me: WARNING: Missing prerequisites for building hpcrun." >&2;}
28119+
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unless you're building hpctoolkit only for docs or make dist," >&5
28120+
$as_echo "$as_me: WARNING: Unless you're building hpctoolkit only for docs or make dist," >&2;}
28121+
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: this is probably an error. Rerun configure with:" >&5
28122+
$as_echo "$as_me: WARNING: this is probably an error. Rerun configure with:" >&2;}
28123+
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: --with-spack=/path/to/spack/install/gcc-x.y.z" >&5
28124+
$as_echo "$as_me: WARNING: --with-spack=/path/to/spack/install/gcc-x.y.z" >&2;}
2815728125
fi
2815828126

2815928127
if test "$warn_non_gnu" = yes ; then

configure.ac

Lines changed: 20 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -3523,13 +3523,8 @@ AC_SUBST([TBB_COPY])
35233523
# Option: --with-xed=PATH
35243524
#-------------------------------------------------
35253525

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

35343529
XED2_INC=
35353530
XED2_LIB_DIR=no
@@ -3559,12 +3554,11 @@ case "$XED2" in
35593554
if test ! -f "${XED2}/include/xed-interface.h" ; then
35603555
AC_MSG_ERROR([invalid xed2 directory: $XED2])
35613556
fi
3562-
if test ! -f "${XED2}/lib/libxed.so" && test ! -f "${XED2}/lib/libxed.a" ; then
3557+
if test ! -f "${XED2}/lib/libxed.a" ; then
35633558
AC_MSG_ERROR([invalid xed2 directory: $XED2])
35643559
fi
35653560
XED2_INC="${XED2}/include"
35663561
XED2_LIB_DIR="${XED2}/lib"
3567-
XED2_COPY=yes
35683562
xed2_avail=yes
35693563
num_pkgs=`expr 1 + $num_pkgs`
35703564
;;
@@ -3610,55 +3604,19 @@ int my_xed_init(void)
36103604
CFLAGS="$ORIG_CFLAGS"
36113605
LIBS="$ORIG_LIBS"
36123606
fi
3607+
36133608
#
3614-
# default lib flags: .so if exists, else .a
3615-
#
3616-
if test -f "${XED2}/lib/libxed.so" ; then
3617-
XED2_LIB_FLAGS="-L${XED2}/lib -lxed"
3618-
elif test -f "${XED2}/lib/libxed.a" ; then
3619-
XED2_LIB_FLAGS="${XED2}/lib/libxed.a"
3620-
else
3621-
AC_MSG_ERROR([unable to find libxed.so or libxed.a])
3622-
fi
3623-
#
3624-
# hpcrun: .so, or .a + fPIC, else fail
3625-
#
3626-
if test -f "${XED2}/lib/libxed.so" ; then
3627-
XED2_HPCRUN_LIBS="-L${XED2}/lib -lxed"
3628-
elif test "$xed2_static_fpic" = yes ; then
3629-
XED2_HPCRUN_LIBS="${XED2}/lib/libxed.a"
3630-
else
3631-
AC_MSG_WARN([unable to build hpcrun: no libxed with -fPIC])
3632-
no_xed_for_hpcrun=yes
3633-
fi
3634-
#
3635-
# hpclink: .a only (with or without -fPIC)
3636-
#
3637-
if test -f "${XED2}/lib/libxed.a" ; then
3638-
XED2_HPCLINK_LIBS="${XED2}/lib/libxed.a"
3639-
else
3640-
AC_MSG_WARN([unable to build hpclink: no static libxed.a])
3641-
no_xed_for_hpclink=yes
3642-
fi
3643-
#
3644-
# hpcprof-mpi: same as hpclink if fully static, else default
3645-
#
3646-
echo "x$HPCPROFMPI_LT_LDFLAGS" | grep -e all-static >/dev/null 2>&1
3647-
if test $? = 0 ; then
3648-
XED2_PROF_MPI_LIBS="$XED2_HPCLINK_LIBS"
3649-
else
3650-
XED2_PROF_MPI_LIBS="$XED2_LIB_FLAGS"
3651-
fi
3652-
#
3653-
# add libirc.a, if exists for k1om
3609+
# now require .a archive + fPIC for both hpcrun and hpclink
36543610
#
3655-
if test -f "${XED2}/lib/libirc.a" ; then
3656-
XED2_LIB_FLAGS="${XED2_LIB_FLAGS} ${XED2}/lib/libirc.a"
3657-
XED2_HPCRUN_LIBS="${XED2_HPCRUN_LIBS} ${XED2}/lib/libirc.a"
3658-
XED2_HPCLINK_LIBS="${XED2_HPCLINK_LIBS} ${XED2}/lib/libirc.a"
3659-
XED2_PROF_MPI_LIBS="${XED2_PROF_MPI_LIBS} ${XED2}/lib/libirc.a"
3611+
if test "$xed2_static_fpic" = no ; then
3612+
AC_MSG_ERROR([libxed.a must be compiled with -fPIC])
36603613
fi
3661-
AC_MSG_NOTICE([xed2 lib flags: $XED2_LIB_FLAGS])
3614+
XED2_LIB_FLAGS="${XED2}/lib/libxed.a"
3615+
XED2_HPCRUN_LIBS="${XED2}/lib/libxed.a"
3616+
XED2_HPCLINK_LIBS="${XED2}/lib/libxed.a"
3617+
XED2_PROF_MPI_LIBS="$XED2_LIB_FLAGS"
3618+
3619+
AC_MSG_NOTICE([xed2 hpcrun libs: $XED2_HPCRUN_LIBS])
36623620
fi
36633621

36643622
AC_SUBST([XED2_INC])
@@ -5907,6 +5865,13 @@ if test "x$with_spack" = xno && test "$num_pkgs" -lt 7 ; then
59075865
AC_MSG_WARN([Unless you're building hpctoolkit only for docs or make dist,])
59085866
AC_MSG_WARN([this is probably an error. Rerun configure with:])
59095867
AC_MSG_WARN([ --with-spack=/path/to/spack/install/gcc-x.y.z])
5868+
5869+
elif test "$OPT_ENABLE_HPCRUN" != yes ; then
5870+
AC_MSG_NOTICE([])
5871+
AC_MSG_WARN([Missing prerequisites for building hpcrun.])
5872+
AC_MSG_WARN([Unless you're building hpctoolkit only for docs or make dist,])
5873+
AC_MSG_WARN([this is probably an error. Rerun configure with:])
5874+
AC_MSG_WARN([ --with-spack=/path/to/spack/install/gcc-x.y.z])
59105875
fi
59115876

59125877
if test "$warn_non_gnu" = yes ; then

src/tool/hpcrun/Makefile.am

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,11 @@ libhpcrun_o_LDADD = \
869869
$(OUR_LIBUNWIND_A) \
870870
$(OUR_LZMA_A)
871871

872+
if HOST_CPU_X86_FAMILY
873+
libhpcrun_la_LIBADD += $(XED2_HPCRUN_LIBS)
874+
libhpcrun_o_LDADD += $(XED2_HPCRUN_LIBS)
875+
endif
876+
872877

873878
#-----------------------------------------------------------
874879
# whirled peas
@@ -929,7 +934,6 @@ if HOST_CPU_X86_FAMILY
929934
libhpcrun_o_CPPFLAGS += $(MY_X86_INCLUDE_DIRS)
930935
libhpcrun_la_CCASFLAGS = $(AM_CCASFLAGS)
931936
libhpcrun_o_CCASFLAGS = $(AM_CCASFLAGS)
932-
libhpcrun_la_LDFLAGS += $(XED2_HPCRUN_LIBS)
933937
libhpcrun_o_LDADD += $(XED2_HPCLINK_LIBS)
934938
libhpcrun_ga_la_CPPFLAGS += $(MY_X86_INCLUDE_DIRS)
935939
libhpcrun_ga_wrap_a_CPPFLAGS += $(MY_X86_INCLUDE_DIRS)
@@ -1036,7 +1040,6 @@ endif
10361040
if UNW_X86
10371041
UNW_SOURCE_FILES = $(UNW_X86_FILES)
10381042
UNW_INCLUDE_DIRS = $(UNW_X86_INCLUDE_DIRS)
1039-
UNW_DYNAMIC_LD_FLAGS = $(XED2_HPCRUN_LIBS)
10401043
UNW_STATIC_LD_FLAGS = $(XED2_HPCLINK_LIBS)
10411044
endif
10421045

0 commit comments

Comments
 (0)