From c9ace844ba2adde13a2f7f1d353f38853717426c Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Sat, 5 May 2018 14:38:38 +0000 Subject: [PATCH] build: rewrite libdw detection without pkg-config pkg-config expected to be more convenient way to configure libdw, but in practice it appeared to be less portable than good old AC_CHECK_HEADERS and AC_CHECK_LIB. * ci/install-dependencies.sh (common_packages): Remove pkg-config. (STACKTRACE == "libdw"): Do not install libz-dev and liblzma-dev. * debian/control (Build-Depends): Remove pkg-config. * m4/st_libdw.m4 (st_ARG_LIBDW, st_LIBDW): Rewrite without pkg-config. --- ci/install-dependencies.sh | 4 +- debian/control | 2 +- m4/st_libdw.m4 | 82 +++++++++++++++++--------------------- 3 files changed, 39 insertions(+), 49 deletions(-) diff --git a/ci/install-dependencies.sh b/ci/install-dependencies.sh index e704d44e..99ab56fc 100755 --- a/ci/install-dependencies.sh +++ b/ci/install-dependencies.sh @@ -1,7 +1,7 @@ #!/bin/sh -ex type sudo >/dev/null 2>&1 && sudo=sudo || sudo= -common_packages='autoconf automake faketime file gawk gcc-multilib git gzip make pkg-config xz-utils' +common_packages='autoconf automake faketime file gawk gcc-multilib git gzip make xz-utils' updated= apt_get_install() @@ -92,7 +92,7 @@ esac case "${STACKTRACE-}" in libdw) - apt_get_install libdw-dev libz-dev liblzma-dev + apt_get_install libdw-dev ;; libunwind) apt_get_install libunwind8-dev diff --git a/debian/control b/debian/control index dd2db73f..38e13a13 100644 --- a/debian/control +++ b/debian/control @@ -2,7 +2,7 @@ Source: strace Maintainer: Steve McIntyre <93sam@debian.org> Section: utils Priority: optional -Build-Depends: libc6-dev (>= 2.2.2) [!alpha !ia64], libc6.1-dev (>= 2.2.2) [alpha ia64], gcc-multilib [amd64 i386 powerpc ppc64 ppc64el s390 s390x sparc sparc64 x32], debhelper (>= 7.0.0), gawk, pkg-config, libdw-dev, libiberty-dev, libbluetooth-dev +Build-Depends: libc6-dev (>= 2.2.2) [!alpha !ia64], libc6.1-dev (>= 2.2.2) [alpha ia64], gcc-multilib [amd64 i386 powerpc ppc64 ppc64el s390 s390x sparc sparc64 x32], debhelper (>= 7.0.0), gawk, libdw-dev, libiberty-dev, libbluetooth-dev Standards-Version: 4.1.3 Homepage: https://strace.io Vcs-Git: https://salsa.debian.org/debian/strace.git diff --git a/m4/st_libdw.m4 b/m4/st_libdw.m4 index 5b80fac3..f33ec356 100644 --- a/m4/st_libdw.m4 +++ b/m4/st_libdw.m4 @@ -27,6 +27,11 @@ AC_DEFUN([st_ARG_LIBDW], [dnl +: ${libdw_CPPFLAGS=} +: ${libdw_CFLAGS=} +: ${libdw_LDFLAGS=} +: ${libdw_LIBS=} + AC_ARG_WITH([libdw], [AS_HELP_STRING([--with-libdw], [use libdw to implement stack tracing support] @@ -34,9 +39,9 @@ AC_ARG_WITH([libdw], ], [case "${withval}" in yes|no|check) ;; - *) - AC_MSG_ERROR([Use pkg-config variables instead of giving path to --with-libdw]) - ;; + *) libdw_CPPFLAGS="-I${withval}/include" + libdw_LDFLAGS="-L${withval}/lib" + with_libdw=yes ;; esac ], [with_libdw=check] @@ -46,60 +51,45 @@ AC_ARG_WITH([libdw], AC_DEFUN([st_LIBDW], [dnl -: ${libdw_CPPFLAGS=} -: ${libdw_CFLAGS=} -: ${libdw_LDFLAGS=} -: ${libdw_LIBS=} have_libdw= -AS_IF([test "x$with_libdw" != xno], - [ - dnl If libdw.pc is not available, then libdw is not new enough - dnl to be used for stack tracing. - AS_IF([test "x$with_libdw" = xyes], - [PKG_CHECK_MODULES([libdw], [libdw], [have_libdw=yes])], - [PKG_CHECK_MODULES([libdw], [libdw], [have_libdw=yes], [:])] - ) - ] - ) - -AS_IF([test "x$have_libdw" = xyes], - [ - dnl If libdw.pc is available, check whether libdw can be used - dnl for stack tracing. - saved_CPPFLAGS="$CPPFLAGS" +AS_IF([test "x$with_libdw" != xno && test "x$use_unwinder" = x], + [saved_CPPFLAGS="$CPPFLAGS" saved_CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS $libdw_CPPFLAGS" CFLAGS="$CFLAGS $libdw_CFLAGS" AC_CHECK_HEADERS([elfutils/libdwfl.h], - [ - AC_MSG_CHECKING([for dwfl_linux_proc_attach in libdw]) - saved_LDFLAGS="$LDFLAGS" - saved_LIBS="$LIBS" - LDFLAGS="$LDFLAGS $libdw_LDFLAGS" - LIBS="$LIBS $libdw_LIBS" - - AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], - [[return dwfl_linux_proc_attach(0, 0, 0)]] - ) - ], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no]) - AS_IF([test "x$with_libdw" = xyes], - [AC_MSG_FAILURE([failed to find dwfl_linux_proc_attach in libdw])], - ) - have_libdw= - ] - ) - - LIBS="$saved_LIBS" - LDFLAGS="$saved_LDFLAGS" + [AC_CHECK_LIB([dw], [dwfl_linux_proc_attach], + [libdw_LIBS="-ldw $libdw_LIBS" + AC_CACHE_CHECK([for elfutils version], + [st_cv_ELFUTILS_VERSION], + [[st_cv_ELFUTILS_VERSION="$(echo _ELFUTILS_VERSION | + $CPP $CPPFLAGS -P -imacros elfutils/version.h - | + grep '^[0-9]')" + test -n "$st_cv_ELFUTILS_VERSION" || + st_cv_ELFUTILS_VERSION=0 + ]] + ) + AS_IF([test "$st_cv_ELFUTILS_VERSION" -ge 164], + [have_libdw=yes], + [AS_IF([test "x$with_libdw" = xyes], + [AC_MSG_ERROR([elfutils version >= 164 is required for stack tracing support])], + [AC_MSG_WARN([elfutils version >= 164 is required for stack tracing support])] + ) + ] + ) + ], + [AS_IF([test "x$with_libdw" = xyes], + [AC_MSG_FAILURE([failed to find dwfl_linux_proc_attach in libdw])], + ) + ], + [$libdw_LDFLAGS $libdw_LIBS] + ) ], [AS_IF([test "x$with_libdw" = xyes], [AC_MSG_FAILURE([failed to find elfutils/libdwfl.h])] ) - have_libdw= ] ) -- 2.40.0