uftrace: Properly enable Python scripting support

This commit is contained in:
Tee KOBAYASHI 2022-10-31 08:12:25 +09:00 committed by xtkoba
parent 36a7c68a8f
commit e089f7ba46
5 changed files with 57 additions and 11 deletions

View File

@ -3,25 +3,21 @@ TERMUX_PKG_DESCRIPTION="Function (graph) tracer for user-space"
TERMUX_PKG_LICENSE="GPL-2.0"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION="0.12"
TERMUX_PKG_REVISION=1
TERMUX_PKG_SRCURL=https://github.com/namhyung/uftrace/archive/v${TERMUX_PKG_VERSION}.tar.gz
TERMUX_PKG_SHA256=2aad01f27d4f18717b681824c7a28ac3e1efd5e7bbed3ec888a3ea5af60e3700
TERMUX_PKG_DEPENDS="capstone, libandroid-glob, libandroid-spawn, libelf, libdw, ncurses, python"
# On x86_64 utils/script-luajit.c:154:12 uses some sse2 feature even if sse2 is disabled.
# `error: sse2 register return with sse2 disabled`
[[ "${TERMUX_ARCH}" != "x86_64" ]] && TERMUX_PKG_DEPENDS+=", libluajit"
# Hardcoded libpython${_PYTHON_VERSION}.so is dlopen(3)ed by uftrace.
# Please revbump and rebuild when bumping _PYTHON_VERSION, where
# _PYTHON_VERSION == _MAJOR_VERSION in build.sh of python package.
TERMUX_PKG_DEPENDS="capstone, libandroid-glob, libandroid-spawn, libc++, libdw, libelf, libluajit, ncurses, python"
TERMUX_PKG_BUILD_DEPENDS="argp"
TERMUX_PKG_AUTO_UPDATE=true
TERMUX_PKG_UPDATE_TAG_TYPE="newest-tag"
termux_step_pre_configure() {
# uftrace uses custom configure script implementation, so we need to provide some flags
local _PYTHON_VERSION
_PYTHON_VERSION=$(
source $TERMUX_SCRIPTDIR/packages/python/build.sh
echo $_MAJOR_VERSION
)
export CFLAGS="${CFLAGS} -I${TERMUX_PREFIX}/include -I${TERMUX_PREFIX}/include/python${_PYTHON_VERSION} -DEFD_SEMAPHORE=1 -DEF_ARM_ABI_FLOAT_HARD=0x400 -w"
export LDFLAGS="${LDFLAGS} -Wl,--wrap=_Unwind_Resume -landroid-glob -largp -lpython${_PYTHON_VERSION}"
CFLAGS+=" -DEFD_SEMAPHORE=1 -DEF_ARM_ABI_FLOAT_HARD=0x400 -w"
LDFLAGS+=" -Wl,--wrap=_Unwind_Resume -landroid-glob -largp"
if [ "$TERMUX_ARCH" = "i686" ]; then
export ARCH="i386"

View File

@ -0,0 +1,11 @@
--- a/check-deps/Makefile.check
+++ b/check-deps/Makefile.check
@@ -15,7 +15,7 @@
LIB_CFLAGS += -mno-sse2
endif
-ifneq ($(wildcard $(srcdir)/check-deps/have_libpython3),)
+ifneq ($(wildcard $(objdir)/check-deps/have_libpython3),)
# libpython3 provides an embed verison of pkg-config file since python3.8
ifeq ($(shell pkg-config python3-embed --exists 2> /dev/null; echo $$?), 0)
EMBED := -embed

View File

@ -0,0 +1,11 @@
--- a/check-deps/Makefile
+++ b/check-deps/Makefile
@@ -19,7 +19,7 @@
# This is needed for checking build dependency
#
-CHECK_CFLAGS = $(CFLAGS) $(CFLAGS_$@) -Werror
+CHECK_CFLAGS = $(CFLAGS) $(CFLAGS_$@) $(CPPFLAGS) -Werror
CHECK_LDFLAGS = $(LDFLAGS) $(LDFLAGS_$@)
# libpython3 provides an embed verison of pkg-config file since python3.8

View File

@ -0,0 +1,14 @@
--- a/utils/script-luajit.c
+++ b/utils/script-luajit.c
@@ -150,9 +150,11 @@
case 8:
dval = val.d;
break;
+#if !(defined __ANDROID__ && defined __x86_64__)
case 10:
dval = (double)val.D;
break;
+#endif
default:
pr_dbg("invalid floating-point type size %d\n",
spec->size);

View File

@ -0,0 +1,14 @@
--- a/utils/script-python.c
+++ b/utils/script-python.c
@@ -469,9 +469,11 @@
case 8:
dval = val.d;
break;
+#if !(defined __ANDROID__ && defined __x86_64__)
case 10:
dval = (double)val.D;
break;
+#endif
default:
pr_dbg("invalid floating-point type size %d\n",
spec->size);