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

132 lines, 97 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 if echo $py_version | egrep 'Python 3.11'; then
53 # fix for this crap too
54 # TODO: should upgrade to uftrace 0.16 probably
55 # https://github.com/namhyung/uftrace/releases
56 # - 0.13 is from 2023-01
57 # - 0.16 is from 2024-04
58
59 # uke@67e418a2a45d:/wedge/oils-for-unix.org/pkg/uftrace/0.13/bin$ ls -l /usr/lib/x86_64-linux-gnu/libpython3.11*
60 # lrwxrwxrwx 1 root root 20 Mar 13 2023 /usr/lib/x86_64-linux-gnu/libpython3.11.so.1 -> libpython3.11.so.1.0
61 # -rw-r--r-- 1 root root 7732544 Mar 13 2023 /usr/lib/x86_64-linux-gnu/libpython3.11.so.1.0
62
63 local c_file=$src_dir/utils/script-python.c
64 sed -i 's/".so"/".so.1.0"/' $c_file
65 fi
66
67 pushd $build_dir
68
69 $src_dir/configure --help || true
70 echo
71
72 # Note: smoke test should look like this, with Python 3 plugins
73 #
74 # uftrace v0.13 ( x86_64 python3 perf sched )
75 #
76 # It depends on 'pkg-config python3 --cflags'
77 #
78 # There is a misleading message at the beginning that says libpython OFF
79 #
80 # I tried --with-libpython, and it doesn't seem to affect it either way.
81
82 # 2023-07: Debian 12 Bookworm needs:
83 #
84 # apt-get install pkgconfig
85
86 $src_dir/configure --prefix=$install_dir
87 echo
88
89 time make
90
91 popd
92}
93
94wedge-install() {
95 local build_dir=$1
96
97 pushd $build_dir
98
99 # install-strip is a GNU thing! It discards symbols.
100
101 # TODO: copy them from the original binary in $BUILD_DIR
102 # objcopy --add-debug-link, etc.
103
104 # Does not have 'install-strip' target
105
106 time make install
107
108 popd
109}
110
111wedge-smoke-test() {
112 local install_dir=$1
113 local wedge_dir=$2
114
115 local uftrace=$install_dir/bin/uftrace
116 $uftrace --version | tee version.txt
117
118 if grep python3 version.txt; then
119 echo 'Python 3 support found'
120 else
121 echo 'FAILED to build with Python 3 support'
122 return 1
123 fi
124
125 cc -pg -o hello $wedge_dir/hello.c
126
127 $uftrace record hello
128 $uftrace replay hello
129 $uftrace script -S $wedge_dir/plugin.py
130}
131
132# vim: filetype=sh