From 2f2c168b71a87cdc571d1c7f052688e41bcf5812 Mon Sep 17 00:00:00 2001 From: William Cohen Date: Fri, 14 Jan 2022 14:00:02 -0500 Subject: [PATCH] configure finds appropriate default 32-bit or 64-bit Dyninst libraries Earlier versions of the systemtap configuration would just include two -L paths to both 32-bit and 64-bit versions of the Dyninst libraries. However, attempting to link a 32-bit library with a 64-bit build (and vice versa) may cause the build to fail. This revision of the configure tests determines which default Dyninst library works with the compiler being used and selects it. The configure can't bindly use ${libdir}/dyninst to select the path to the default Dyninst libary as this only selects the ${prefix}/lib64 on appropriate machines if the prefix is /usr. If the prefix is set to something else, ${libdir} is always ${prefix}/lib. The would cause the build to attempt to link with nonexistent Dyninst libaries in the ${prefix} directory. If systemtap needs to be use a version of Dysninst in a non-standard place, the --with-dyninst= should be used. --- configure | 44 +++++++++++++++++++++++++++++++++++++++++++- configure.ac | 20 +++++++++++++++++++- 2 files changed, 62 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 56fc51c24..6ac022ec4 100755 --- a/configure +++ b/configure @@ -12043,7 +12043,49 @@ case "$with_dyninst" in no) ;; ''|yes) # Try a simple-minded distro search DYNINST_CXXFLAGS="" - DYNINST_LDFLAGS="-L/usr/lib64/dyninst" + old_LIBS="$LIBS" + old_LDFLAGS="$LDFLAGS" + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + for location in /usr/lib64/dyninst /usr/lib/dyninst ${libdir}/dyninst; do + LDFLAGS="-L${location}" + LIBS="-lparseAPI ${BOOST_SYSTEM_LIB}" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +char *s; Dyninst::ParseAPI::SymtabCodeSource *sts = new Dyninst::ParseAPI::SymtabCodeSource(s); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + found_DYNINST_LDFLAGS=yes +else + found_DYNINST_LDFLAGS=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + if test "$found_DYNINST_LDFLAGS" = "yes"; then + DYNINST_LDFLAGS="$LDFLAGS" + break + fi + done + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + LDFLAGS="$old_LDFLAGS" + LIBS="$old_LIBS" + # Add Dyninst libraries only if they are available if test -d "/usr/include/dyninst"; then save_LIBS="$LIBS" diff --git a/configure.ac b/configure.ac index 0ad1c3105..895f50695 100644 --- a/configure.ac +++ b/configure.ac @@ -616,7 +616,25 @@ case "$with_dyninst" in no) ;; ''|yes) # Try a simple-minded distro search DYNINST_CXXFLAGS="" - DYNINST_LDFLAGS="-L/usr/lib64/dyninst" + old_LIBS="$LIBS" + old_LDFLAGS="$LDFLAGS" + AC_LANG_PUSH(C++) + for location in /usr/lib64/dyninst /usr/lib/dyninst ${libdir}/dyninst; do + LDFLAGS="-L${location}" + LIBS="-lparseAPI ${BOOST_SYSTEM_LIB}" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], + [[char *s; Dyninst::ParseAPI::SymtabCodeSource *sts = new Dyninst::ParseAPI::SymtabCodeSource(s);]])], + + [found_DYNINST_LDFLAGS=yes],[found_DYNINST_LDFLAGS=no]) + if test "$found_DYNINST_LDFLAGS" = "yes"; then + DYNINST_LDFLAGS="$LDFLAGS" + break + fi + done + AC_LANG_POP(C++) + LDFLAGS="$old_LDFLAGS" + LIBS="$old_LIBS" + # Add Dyninst libraries only if they are available if test -d "/usr/include/dyninst"; then save_LIBS="$LIBS" -- 2.43.5