dev-util/strace: Fix building with USE="static".

Closes: https://bugs.gentoo.org/673934
Closes: https://bugs.gentoo.org/686946
Signed-off-by: Arfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org>
Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
This commit is contained in:
Arfrever Frehtes Taifersar Arahesis
2020-04-09 10:29:02 +02:00
committed by Lars Wendler
parent 10159e26b4
commit a6b222b1be
3 changed files with 200 additions and 6 deletions
@@ -0,0 +1,178 @@
--- /Makefile.am
+++ /Makefile.am
@@ -379,7 +379,6 @@
if USE_LIBDW
strace_SOURCES += unwind-libdw.c
strace_CPPFLAGS += $(libdw_CPPFLAGS)
-strace_CFLAGS += $(libdw_CFLAGS)
strace_LDFLAGS += $(libdw_LDFLAGS)
strace_LDADD += $(libdw_LIBS)
endif
--- /configure.ac
+++ /configure.ac
@@ -48,6 +48,15 @@
AC_DEFINE([MANPAGE_DATE], "[manpage_date]", [Date])
AC_SUBST([MANPAGE_DATE], [manpage_date])
+AC_ARG_ENABLE([static],
+ [AS_HELP_STRING([--enable-static],
+ [link strace statically])],
+ [], [enable_static=no])
+if test "$enable_static" = "yes"; then
+ # Add -pthread since strace wants -lrt for timer_create, and -lrt uses -lpthread.
+ LDFLAGS="$LDFLAGS -pthread -static"
+fi
+
AC_C_BIGENDIAN
AC_MSG_CHECKING([for supported architecture])
--- /m4/st_libdw.m4
+++ /m4/st_libdw.m4
@@ -8,7 +8,6 @@
AC_DEFUN([st_ARG_LIBDW], [dnl
: ${libdw_CPPFLAGS=}
-: ${libdw_CFLAGS=}
: ${libdw_LDFLAGS=}
: ${libdw_LIBS=}
@@ -34,48 +33,14 @@
have_libdw=
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_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])]
- )
- ]
- )
-
- CFLAGS="$saved_CFLAGS"
- CPPFLAGS="$saved_CPPFLAGS"
- ]
+ [if test "$enable_static" = "yes"; then
+ PKG_CHECK_MODULES_STATIC([LIBDW], [libdw >= 0.164])
+ else
+ PKG_CHECK_MODULES([LIBDW], [libdw >= 0.164])
+ fi
+ have_libdw=yes
+ libdw_CPPFLAGS="$LIBDW_CFLAGS"
+ libdw_LIBS="$LIBDW_LIBS"]
)
AS_IF([test "x$have_libdw" = xyes],
@@ -84,7 +49,6 @@
[Whether to use libdw for stack tracing]
)
AC_SUBST(libdw_CPPFLAGS)
- AC_SUBST(libdw_CFLAGS)
AC_SUBST(libdw_LDFLAGS)
AC_SUBST(libdw_LIBS)
]
--- /m4/st_libunwind.m4
+++ /m4/st_libunwind.m4
@@ -28,64 +28,14 @@
libunwind_LIBS=
AS_IF([test "x$with_libunwind" != xno && test "x$use_unwinder" = x],
- [saved_CPPFLAGS="$CPPFLAGS"
- CPPFLAGS="$CPPFLAGS $libunwind_CPPFLAGS"
-
- AC_CHECK_HEADERS([libunwind-ptrace.h],
- [saved_LDFLAGS="$LDFLAGS"
- LDFLAGS="$LDFLAGS $libunwind_LDFLAGS"
-
- AC_CHECK_LIB([unwind], [backtrace],
- [libunwind_LIBS="-lunwind $libunwind_LIBS"
-
- AC_MSG_CHECKING([for unw_create_addr_space in libunwind-generic])
- saved_LIBS="$LIBS"
- LIBS="-lunwind-generic $libunwind_LIBS $LIBS"
-
- AC_LINK_IFELSE(
- [AC_LANG_PROGRAM([[#include <libunwind-ptrace.h>]],
- [[return !unw_create_addr_space(0, 0)]])
- ],
- [AC_MSG_RESULT([yes])
- libunwind_LIBS="-lunwind-generic $libunwind_LIBS"
-
- AC_CHECK_LIB([unwind-ptrace], [_UPT_create],
- [libunwind_LIBS="-lunwind-ptrace $libunwind_LIBS"
- use_unwinder=libunwind
- ],
- [if test "x$with_libunwind" != xcheck; then
- AC_MSG_FAILURE([failed to find _UPT_create in libunwind-ptrace])
- fi
- ],
- [$libunwind_LIBS]
- )
- ],
- [AC_MSG_RESULT([no])
- if test "x$with_libunwind" != xcheck; then
- AC_MSG_FAILURE([failed to find unw_create_addr_space in libunwind-generic])
- fi
- ]
- )
-
- LIBS="$saved_LIBS"
- ],
- [if test "x$with_libunwind" != xcheck; then
- AC_MSG_FAILURE([failed to find libunwind])
- fi
- ],
- [$libunwind_LIBS]
- )
-
- LDFLAGS="$saved_LDFLAGS"
- ],
- [if test "x$with_libunwind" != xcheck; then
- AC_MSG_FAILURE([failed to find libunwind-ptrace.h])
- fi
- ]
- )
-
- CPPFLAGS="$saved_CPPFLAGS"
- ]
+ [if test "$enable_static" = "yes"; then
+ PKG_CHECK_MODULES_STATIC([LIBUNWIND], [libunwind libunwind-generic libunwind-ptrace])
+ else
+ PKG_CHECK_MODULES([LIBUNWIND], [libunwind libunwind-generic libunwind-ptrace])
+ fi
+ use_unwinder="libunwind"
+ libunwind_CPPFLAGS="$LIBUNWIND_CFLAGS"
+ libunwind_LIBS="$LIBUNWIND_LIBS"]
)
if test "x$use_unwinder" = xlibunwind; then
+11 -3
View File
@@ -3,7 +3,7 @@
EAPI=7
inherit flag-o-matic toolchain-funcs
inherit autotools flag-o-matic toolchain-funcs
if [[ ${PV} == "9999" ]] ; then
EGIT_REPO_URI="https://github.com/strace/strace.git"
@@ -22,6 +22,9 @@ IUSE="aio perl static unwind elfutils"
REQUIRED_USE="?? ( unwind elfutils )"
BDEPEND="
virtual/pkgconfig
"
LIB_DEPEND="
unwind? ( sys-libs/libunwind[static-libs(+)] )
elfutils? ( dev-libs/elfutils[static-libs(+)] )
@@ -37,9 +40,15 @@ RDEPEND="
perl? ( dev-lang/perl )
"
PATCHES=(
"${FILESDIR}/${PN}-5.5-static.patch"
)
src_prepare() {
default
eautoreconf
if [[ ! -e configure ]] ; then
# git generation
sed /autoreconf/d -i bootstrap || die
@@ -49,8 +58,6 @@ src_prepare() {
fi
filter-lfs-flags # configure handles this sanely
# Add -pthread since strace wants -lrt for timer_create, and -lrt uses -lpthread.
use static && append-ldflags -static -pthread
export ac_cv_header_libaio_h=$(usex aio)
use elibc_musl && export ac_cv_header_stdc=no
@@ -71,6 +78,7 @@ src_configure() {
# Don't require mpers support on non-multilib systems. #649560
local myeconfargs=(
--enable-mpers=check
$(use_enable static)
$(use_with unwind libunwind)
$(use_with elfutils libdw)
)
+11 -3
View File
@@ -3,7 +3,7 @@
EAPI=7
inherit flag-o-matic toolchain-funcs
inherit autotools flag-o-matic toolchain-funcs
if [[ ${PV} == "9999" ]] ; then
EGIT_REPO_URI="https://github.com/strace/strace.git"
@@ -22,6 +22,9 @@ IUSE="aio perl static unwind elfutils"
REQUIRED_USE="?? ( unwind elfutils )"
BDEPEND="
virtual/pkgconfig
"
LIB_DEPEND="
unwind? ( sys-libs/libunwind[static-libs(+)] )
elfutils? ( dev-libs/elfutils[static-libs(+)] )
@@ -37,9 +40,15 @@ RDEPEND="
perl? ( dev-lang/perl )
"
PATCHES=(
"${FILESDIR}/${PN}-5.5-static.patch"
)
src_prepare() {
default
eautoreconf
if [[ ! -e configure ]] ; then
# git generation
sed /autoreconf/d -i bootstrap || die
@@ -49,8 +58,6 @@ src_prepare() {
fi
filter-lfs-flags # configure handles this sanely
# Add -pthread since strace wants -lrt for timer_create, and -lrt uses -lpthread.
use static && append-ldflags -static -pthread
export ac_cv_header_libaio_h=$(usex aio)
use elibc_musl && export ac_cv_header_stdc=no
@@ -71,6 +78,7 @@ src_configure() {
# Don't require mpers support on non-multilib systems. #649560
local myeconfargs=(
--enable-mpers=check
$(use_enable static)
$(use_with unwind libunwind)
$(use_with elfutils libdw)
)