OILS / deps / source.medo / uftrace / WEDGE View on Github | oilshell.org

117 lines, 85 significant
1# Wedge definition for uftrace.
2#
3# Loaded by deps/wedge.sh.
4
5set -o nounset
6set -o pipefail
7set -o errexit
8
9WEDGE_NAME='uftrace'
10WEDGE_VERSION='0.13'
11WEDGE_IS_ABSOLUTE=1 # TODO: consider relaxing
12
13wedge-make() {
14 local src_dir=$1
15 local build_dir=$2
16 local install_dir=$3
17
18 # PATCH SOURCE FOR SHARED LIB PROBLEM
19 # TODO:
20 # - use 'diff' util
21 # - upgrade all containers to Debian bullseye / Python 3.9, to get rid of
22 # this garbage
23 # - there was no 'm' ABI flag in python 2.7 or 3.9, but there is in 3.6 and 3.7
24
25 local makefile=$src_dir/check-deps/Makefile.check
26
27 # look for libpython3.6m.so, not libpython3.6.so
28 # 2023-07: not needed on Debian 12 Bookworm, outside container
29 # 2024-06: need it inside the container
30 #if test -n "${PY_36_37_HACK:-}"; then
31
32 local py_version
33 py_version=$(python3 -V)
34
35 #echo
36 #echo "*** Got $py_version ***"
37 #echo
38
39 if echo $py_version | egrep 'Python 3.[67]'; then
40
41 echo
42 echo "*** PATCHING utrace $makefile because we detected $py_version"
43 echo
44
45 sed -i 's/--modversion)$/--modversion)m/' $makefile
46
47 # additionally, look for libpython3.6m.so.1.0 !!!
48 local c_file=$src_dir/utils/script-python.c
49 sed -i 's/".so"/".so.1.0"/' $c_file
50 fi
51
52 pushd $build_dir
53
54 $src_dir/configure --help || true
55 echo
56
57 # Note: smoke test should look like this, with Python 3 plugins
58 #
59 # uftrace v0.13 ( x86_64 python3 perf sched )
60 #
61 # It depends on 'pkg-config python3 --cflags'
62 #
63 # There is a misleading message at the beginning that says libpython OFF
64 #
65 # I tried --with-libpython, and it doesn't seem to affect it either way.
66
67 # 2023-07: Debian 12 Bookworm needs:
68 #
69 # apt-get install pkgconfig
70
71 $src_dir/configure --prefix=$install_dir
72 echo
73
74 time make
75
76 popd
77}
78
79wedge-install() {
80 local build_dir=$1
81
82 pushd $build_dir
83
84 # install-strip is a GNU thing! It discards symbols.
85
86 # TODO: copy them from the original binary in $BUILD_DIR
87 # objcopy --add-debug-link, etc.
88
89 # Does not have 'install-strip' target
90
91 time make install
92
93 popd
94}
95
96wedge-smoke-test() {
97 local install_dir=$1
98 local wedge_dir=$2
99
100 local uftrace=$install_dir/bin/uftrace
101 $uftrace --version | tee version.txt
102
103 if grep python3 version.txt; then
104 echo 'Python 3 support found'
105 else
106 echo 'FAILED to build with Python 3 support'
107 return 1
108 fi
109
110 cc -pg -o hello $wedge_dir/hello.c
111
112 $uftrace record hello
113 $uftrace replay hello
114 $uftrace script -S $wedge_dir/plugin.py
115}
116
117# vim: filetype=sh