strace: upgraded package to upstream

Upgraded dev-util/strace to version 5.8 on amd64, arm

BUG=chromium:1161760
TEST=Build and ran strace on nami(amd64) and hana(arm).

Change-Id: I5c5d1d07b0a21454995fcaec5d05922cd5356832
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/overlays/portage-stable/+/2602298
Tested-by: John L Chen <zuan@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: John L Chen <zuan@chromium.org>
diff --git a/dev-util/strace/Manifest b/dev-util/strace/Manifest
index 6e9bddc..b53ab4c 100644
--- a/dev-util/strace/Manifest
+++ b/dev-util/strace/Manifest
@@ -1 +1 @@
-DIST strace-4.22.tar.xz 1232884 SHA256 068cd09264c95e4d591bbcd3ea08f99a693ed8663cd5169b0fdad72eb5bdb39d SHA512 624c3f27921b6df2eb8ff409a35fa9153c4571cd5f703e6cac18f024bccd5ff4acb81f88ca33f81d1046d9718dec7b2705e8940e80bb8447ec3e62a6fd5f8350 WHIRLPOOL e0ac5c9d088f5791e4c9769a639437464a65d814555582a356310f85cf4f684b6295fa09f2cb4eb2ae4280218656ce03dc54e8ce35a782e1ad07c0940ab14de2
+DIST strace-5.8.tar.xz 1813640 BLAKE2B 315edf404fa57890dcff512f9fd76818e8e7d5ad06bc297b68561ec7073297c2e5aaf2c3d9a102382f5833bedacb2a54540068a9f9438094c9180f45b5dc4715 SHA512 633c3daa2dd3d273839cbb8ebd7f6512a38b39af0d0d89f4676c2067e199f346615406d85e3e13f9e4da8dbeb62095185895ffae986eb99b64775a4287e38f4c
diff --git a/dev-util/strace/files/strace-5.4-fix-LTO-CFLAGS-handling.patch b/dev-util/strace/files/strace-5.4-fix-LTO-CFLAGS-handling.patch
new file mode 100644
index 0000000..0f27796
--- /dev/null
+++ b/dev-util/strace/files/strace-5.4-fix-LTO-CFLAGS-handling.patch
@@ -0,0 +1,24 @@
+Based on 52ac53e96143f6aac52738f6e385f75203a68a7b
+[PATCH] configure.ac: do not copy CFLAGS to CFLAGS_FOR_{M32,MX32}
+
+--- a/configure.ac
++++ b/configure.ac
+@@ -984,11 +984,14 @@ AS_IF([test x$arch = xaarch64],
+ 	     ])
+       ])
+ 
+-# Setting default compiler variables for personalities
++# Set default compiler variables for personalities.
+ m4_foreach([pers], [M32, MX32], dnl
+-	[m4_foreach([var], [CC, CPP, CFLAGS, CPPFLAGS], dnl
+-	[[: ${]var[_FOR_]pers[=$]var[}]
+-	AC_SUBST(var[_FOR_]pers)])])
++	   [m4_foreach([var], [CC, CPP, CPPFLAGS], dnl
++		       [[: ${]var[_FOR_]pers[=$]var[}]
++		        AC_SUBST(var[_FOR_]pers)]) dnl
++	    m4_foreach([var], [CFLAGS], dnl
++		       [[: ${]var[_FOR_]pers[=][}]
++		        AC_SUBST(var[_FOR_]pers)])])
+ 
+ st_MPERS([m32], [aarch64|powerpc64|s390x|sparc64|tile|x32|x86_64])
+ st_MPERS([mx32], [x86_64])
diff --git a/dev-util/strace/files/strace-5.5-static.patch b/dev-util/strace/files/strace-5.5-static.patch
new file mode 100644
index 0000000..da57ee0
--- /dev/null
+++ b/dev-util/strace/files/strace-5.5-static.patch
@@ -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
diff --git a/dev-util/strace/strace-4.22.ebuild b/dev-util/strace/strace-5.8.ebuild
similarity index 69%
rename from dev-util/strace/strace-4.22.ebuild
rename to dev-util/strace/strace-5.8.ebuild
index 1a084e5..16a1291 100644
--- a/dev-util/strace/strace-4.22.ebuild
+++ b/dev-util/strace/strace-5.8.ebuild
@@ -1,9 +1,9 @@
-# Copyright 1999-2018 Gentoo Foundation
+# Copyright 1999-2020 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
-EAPI=6
+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"
@@ -18,9 +18,17 @@
 
 LICENSE="BSD"
 SLOT="0"
-IUSE="aio perl static unwind"
+IUSE="aio perl static unwind elfutils"
 
-LIB_DEPEND="unwind? ( sys-libs/libunwind[static-libs(+)] )"
+REQUIRED_USE="?? ( unwind elfutils )"
+
+BDEPEND="
+	virtual/pkgconfig
+"
+LIB_DEPEND="
+	unwind? ( sys-libs/libunwind[static-libs(+)] )
+	elfutils? ( dev-libs/elfutils[static-libs(+)] )
+"
 # strace only uses the header from libaio to decode structs
 DEPEND="
 	static? ( ${LIB_DEPEND} )
@@ -32,20 +40,24 @@
 	perl? ( dev-lang/perl )
 "
 
+PATCHES=(
+	"${FILESDIR}/strace-5.5-static.patch"
+)
+
 src_prepare() {
 	default
 
+	eautoreconf
+
 	if [[ ! -e configure ]] ; then
 		# git generation
-		./xlat/gen.sh || die
-		./generate_mpers_am.sh || die
+		sed /autoreconf/d -i bootstrap || die
+		./bootstrap || die
 		eautoreconf
 		[[ ! -e CREDITS ]] && cp CREDITS{.in,}
 	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
@@ -64,13 +76,18 @@
 	done
 
 	# Don't require mpers support on non-multilib systems. #649560
-	econf \
-		--enable-mpers=check \
+	local myeconfargs=(
+		--disable-gcc-Werror
+		--enable-mpers=check
+		$(use_enable static)
 		$(use_with unwind libunwind)
+		$(use_with elfutils libdw)
+	)
+	econf "${myeconfargs[@]}"
 }
 
 src_test() {
-	if has usersandbox $FEATURES ; then
+	if has usersandbox ${FEATURES} ; then
 		ewarn "Test suite is known to fail with FEATURES=usersandbox -- skipping ..." #643044
 		return 0
 	fi
@@ -80,6 +97,8 @@
 
 src_install() {
 	default
-	use perl || rm "${ED%/}"/usr/bin/strace-graph
+	if ! use perl ; then
+		rm "${ED}"/usr/bin/strace-graph || die
+	fi
 	dodoc CREDITS
 }
diff --git a/metadata/md5-cache/dev-util/strace-4.22 b/metadata/md5-cache/dev-util/strace-4.22
deleted file mode 100644
index 14e83b9..0000000
--- a/metadata/md5-cache/dev-util/strace-4.22
+++ /dev/null
@@ -1,13 +0,0 @@
-DEFINED_PHASES=configure install prepare test
-DEPEND=static? ( unwind? ( sys-libs/libunwind[static-libs(+)] ) ) aio? ( >=dev-libs/libaio-0.3.106 ) sys-kernel/linux-headers
-DESCRIPTION=A useful diagnostic, instructional, and debugging tool
-EAPI=6
-HOMEPAGE=https://strace.io/
-IUSE=aio perl static unwind
-KEYWORDS=*
-LICENSE=BSD
-RDEPEND=!static? ( unwind? ( sys-libs/libunwind ) ) perl? ( dev-lang/perl )
-SLOT=0
-SRC_URI=https://github.com/strace/strace/releases/download/v4.22/strace-4.22.tar.xz
-_eclasses_=desktop	b1d22ac8bdd4679ab79c71aca235009d	epatch	ed88001f77c6dd0d5f09e45c1a5b480e	estack	686eaab303305a908fd57b2fd7617800	eutils	fcb2aa98e1948b835b5ae66ca52868c5	flag-o-matic	5d5921a298e95441da2f85be419894c0	ltprune	2729691420b6deeda2a90b1f1183fb55	multilib	2477ebe553d3e4d2c606191fe6c33602	preserve-libs	ef207dc62baddfddfd39a164d9797648	toolchain-funcs	605c126bed8d87e4378d5ff1645330cb	vcs-clean	2a0f74a496fa2b1552c4f3398258b7bf
-_md5_=d071e19f913ab0081b0d4af3a25a74b8
diff --git a/metadata/md5-cache/dev-util/strace-5.8 b/metadata/md5-cache/dev-util/strace-5.8
new file mode 100644
index 0000000..edd8231
--- /dev/null
+++ b/metadata/md5-cache/dev-util/strace-5.8
@@ -0,0 +1,15 @@
+BDEPEND=virtual/pkgconfig >=app-portage/elt-patches-20170815
+DEFINED_PHASES=configure install prepare test
+DEPEND=static? ( unwind? ( sys-libs/libunwind[static-libs(+)] ) elfutils? ( dev-libs/elfutils[static-libs(+)] ) ) aio? ( >=dev-libs/libaio-0.3.106 ) sys-kernel/linux-headers !<sys-devel/gettext-0.18.1.1-r3 || ( >=sys-devel/automake-1.16.1:1.16 >=sys-devel/automake-1.15.1:1.15 ) >=sys-devel/autoconf-2.69 >=sys-devel/libtool-2.4
+DESCRIPTION=A useful diagnostic, instructional, and debugging tool
+EAPI=7
+HOMEPAGE=https://strace.io/
+IUSE=aio perl static unwind elfutils
+KEYWORDS=*
+LICENSE=BSD
+RDEPEND=!static? ( unwind? ( sys-libs/libunwind ) elfutils? ( dev-libs/elfutils ) ) perl? ( dev-lang/perl )
+REQUIRED_USE=?? ( unwind elfutils )
+SLOT=0
+SRC_URI=https://github.com/strace/strace/releases/download/v5.8/strace-5.8.tar.xz
+_eclasses_=autotools	d0e5375d47f4c809f406eb892e531513	eutils	fcb2aa98e1948b835b5ae66ca52868c5	flag-o-matic	5d5921a298e95441da2f85be419894c0	libtool	f143db5a74ccd9ca28c1234deffede96	multilib	2477ebe553d3e4d2c606191fe6c33602	toolchain-funcs	605c126bed8d87e4378d5ff1645330cb
+_md5_=3ba65cb08baf363a4e0bc6a9068b5f4b