Skip to content

Commit c9ace84

Browse files
committed
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.
1 parent ee5d88c commit c9ace84

File tree

3 files changed

+39
-49
lines changed

3 files changed

+39
-49
lines changed

ci/install-dependencies.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh -ex
22

33
type sudo >/dev/null 2>&1 && sudo=sudo || sudo=
4-
common_packages='autoconf automake faketime file gawk gcc-multilib git gzip make pkg-config xz-utils'
4+
common_packages='autoconf automake faketime file gawk gcc-multilib git gzip make xz-utils'
55

66
updated=
77
apt_get_install()
@@ -92,7 +92,7 @@ esac
9292

9393
case "${STACKTRACE-}" in
9494
libdw)
95-
apt_get_install libdw-dev libz-dev liblzma-dev
95+
apt_get_install libdw-dev
9696
;;
9797
libunwind)
9898
apt_get_install libunwind8-dev

debian/control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Source: strace
22
Maintainer: Steve McIntyre <[email protected]>
33
Section: utils
44
Priority: optional
5-
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
5+
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
66
Standards-Version: 4.1.3
77
Homepage: https://strace.io
88
Vcs-Git: https://salsa.debian.org/debian/strace.git

m4/st_libdw.m4

Lines changed: 36 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,21 @@
2727

2828
AC_DEFUN([st_ARG_LIBDW], [dnl
2929
30+
: ${libdw_CPPFLAGS=}
31+
: ${libdw_CFLAGS=}
32+
: ${libdw_LDFLAGS=}
33+
: ${libdw_LIBS=}
34+
3035
AC_ARG_WITH([libdw],
3136
[AS_HELP_STRING([--with-libdw],
3237
[use libdw to implement stack tracing support]
3338
)
3439
],
3540
[case "${withval}" in
3641
yes|no|check) ;;
37-
*)
38-
AC_MSG_ERROR([Use pkg-config variables instead of giving path to --with-libdw])
39-
;;
42+
*) libdw_CPPFLAGS="-I${withval}/include"
43+
libdw_LDFLAGS="-L${withval}/lib"
44+
with_libdw=yes ;;
4045
esac
4146
],
4247
[with_libdw=check]
@@ -46,60 +51,45 @@ AC_ARG_WITH([libdw],
4651

4752
AC_DEFUN([st_LIBDW], [dnl
4853
49-
: ${libdw_CPPFLAGS=}
50-
: ${libdw_CFLAGS=}
51-
: ${libdw_LDFLAGS=}
52-
: ${libdw_LIBS=}
5354
have_libdw=
5455
55-
AS_IF([test "x$with_libdw" != xno],
56-
[
57-
dnl If libdw.pc is not available, then libdw is not new enough
58-
dnl to be used for stack tracing.
59-
AS_IF([test "x$with_libdw" = xyes],
60-
[PKG_CHECK_MODULES([libdw], [libdw], [have_libdw=yes])],
61-
[PKG_CHECK_MODULES([libdw], [libdw], [have_libdw=yes], [:])]
62-
)
63-
]
64-
)
65-
66-
AS_IF([test "x$have_libdw" = xyes],
67-
[
68-
dnl If libdw.pc is available, check whether libdw can be used
69-
dnl for stack tracing.
70-
saved_CPPFLAGS="$CPPFLAGS"
56+
AS_IF([test "x$with_libdw" != xno && test "x$use_unwinder" = x],
57+
[saved_CPPFLAGS="$CPPFLAGS"
7158
saved_CFLAGS="$CFLAGS"
7259
CPPFLAGS="$CPPFLAGS $libdw_CPPFLAGS"
7360
CFLAGS="$CFLAGS $libdw_CFLAGS"
7461
7562
AC_CHECK_HEADERS([elfutils/libdwfl.h],
76-
[
77-
AC_MSG_CHECKING([for dwfl_linux_proc_attach in libdw])
78-
saved_LDFLAGS="$LDFLAGS"
79-
saved_LIBS="$LIBS"
80-
LDFLAGS="$LDFLAGS $libdw_LDFLAGS"
81-
LIBS="$LIBS $libdw_LIBS"
82-
83-
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <elfutils/libdwfl.h>]],
84-
[[return dwfl_linux_proc_attach(0, 0, 0)]]
85-
)
86-
],
87-
[AC_MSG_RESULT([yes])],
88-
[AC_MSG_RESULT([no])
89-
AS_IF([test "x$with_libdw" = xyes],
90-
[AC_MSG_FAILURE([failed to find dwfl_linux_proc_attach in libdw])],
91-
)
92-
have_libdw=
93-
]
94-
)
95-
96-
LIBS="$saved_LIBS"
97-
LDFLAGS="$saved_LDFLAGS"
63+
[AC_CHECK_LIB([dw], [dwfl_linux_proc_attach],
64+
[libdw_LIBS="-ldw $libdw_LIBS"
65+
AC_CACHE_CHECK([for elfutils version],
66+
[st_cv_ELFUTILS_VERSION],
67+
[[st_cv_ELFUTILS_VERSION="$(echo _ELFUTILS_VERSION |
68+
$CPP $CPPFLAGS -P -imacros elfutils/version.h - |
69+
grep '^[0-9]')"
70+
test -n "$st_cv_ELFUTILS_VERSION" ||
71+
st_cv_ELFUTILS_VERSION=0
72+
]]
73+
)
74+
AS_IF([test "$st_cv_ELFUTILS_VERSION" -ge 164],
75+
[have_libdw=yes],
76+
[AS_IF([test "x$with_libdw" = xyes],
77+
[AC_MSG_ERROR([elfutils version >= 164 is required for stack tracing support])],
78+
[AC_MSG_WARN([elfutils version >= 164 is required for stack tracing support])]
79+
)
80+
]
81+
)
82+
],
83+
[AS_IF([test "x$with_libdw" = xyes],
84+
[AC_MSG_FAILURE([failed to find dwfl_linux_proc_attach in libdw])],
85+
)
86+
],
87+
[$libdw_LDFLAGS $libdw_LIBS]
88+
)
9889
],
9990
[AS_IF([test "x$with_libdw" = xyes],
10091
[AC_MSG_FAILURE([failed to find elfutils/libdwfl.h])]
10192
)
102-
have_libdw=
10393
]
10494
)
10595

0 commit comments

Comments
 (0)