On Sat, Apr 19, 2025 at 3:31 AM Arnaldo Carvalho de Melo <arnaldo.melo@xxxxxxxxx> wrote: > > > > On Sat, Apr 19, 2025, 1:23 AM Ian Rogers <irogers@xxxxxxxxxx> wrote: >> >> On Fri, Apr 18, 2025 at 2:29 PM Arnaldo Carvalho de Melo >> <acme@xxxxxxxxxx> wrote: >> > >> > On Thu, Apr 17, 2025 at 04:07:21PM -0700, Ian Rogers wrote: >> > > Linking against libcapstone and libLLVM can be a significant increase >> > > in dependencies and file size if building statically. For something >> > > like `perf record` the disassembler and addr2line functionality won't >> > > be used. Support dynamically loading these libraries using dlopen and >> > > then calling the appropriate functions found using dlsym. >> > > >> > > BUILD_NONDISTRO is used to build perf against the license incompatible >> > > libbfd and libiberty libraries. As this has been opt-in for nearly 2 >> > > years, commit dd317df07207 ("perf build: Make binutil libraries opt >> > > in"), remove the code to simplify the code base. >> > > >> > > The patch series: >> > > 1) does some initial clean up; >> > > 2) moves the capstone and LLVM code to their own C files, >> > > 3) simplifies a little the capstone code; >> > > 4) adds perf_ variants of the functions that will either directly call >> > > the function or use dlsym to discover it; >> > > 5) adds BPF JIT disassembly support to LLVM and capstone disassembly; >> > > 6) removes the BUILD_NONDISTRO code, reduces scope and removes what's possible; >> > > 7) adds fallback to srcline's addr2line so that llvm_addr2line is >> > > tried first and then the forked command tried next, moving the code >> > > for forking out of the main srcline.c file in the process. >> > > >> > > The addr2line LLVM functionality is written in C++. To avoid linking >> > > against libLLVM for this, a new LIBLLVM_DYNAMIC option is added where >> > > the C++ code with the libLLVM dependency will be built into a >> > > libperf-llvm.so and that dlsym-ed and called against. Ideally LLVM >> > > would extend their C API to avoid this. >> > > >> > > The libbfd BPF disassembly supported source lines, this wasn't ported >> > > to the capstone and LLVM disassembly. >> > >> > Doing the build tests I noticed, so far: >> > >> > 29 58.92 opensuse:15.4 : FAIL gcc version 7.5.0 (SUSE Linux) >> > <SNIP> >> > + make NO_LIBTRACEEVENT=1 ARCH= CROSS_COMPILE= EXTRA_CFLAGS= NO_LIBBPF=1 -C tools/perf O=/tmp/build/perf >> > make: Entering directory '/git/perf-6.15.0-rc2/tools/perf' >> > BUILD: Doing 'make -j32' parallel build >> > Warning: Skipped check-headers due to missing ../../include >> > Makefile.config:560: No elfutils/debuginfod.h found, no debuginfo server support, please install libdebuginfod-dev/elfutils-debuginfod-client-devel or equivalent >> > Makefile.config:687: Warning: Disabled BPF skeletons as libbpf is required >> > Makefile.config:1039: No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev >> > update-alternatives: error: no alternatives for java >> > update-alternatives: error: no alternatives for java >> > Makefile.config:1100: No openjdk development package found, please install JDK package, e.g. openjdk-8-jdk, java-1.8.0-openjdk-devel >> > Makefile.config:1113: libpfm4 not found, disables libpfm4 support. Please install libpfm4-dev >> > >> > Auto-detecting system features: >> > ... libdw: [ on ] >> > ... glibc: [ on ] >> > ... libelf: [ on ] >> > ... libnuma: [ on ] >> > ... numa_num_possible_cpus: [ on ] >> > ... libperl: [ on ] >> > ... libpython: [ on ] >> > ... libcrypto: [ on ] >> > ... libcapstone: [ on ] >> > ... llvm-perf: [ on ] >> > ... zlib: [ on ] >> > ... lzma: [ on ] >> > ... get_cpuid: [ on ] >> > ... bpf: [ on ] >> > ... libaio: [ on ] >> > ... libzstd: [ on ] >> > >> > PERF_VERSION = 6.15.rc2.gfbcac9367d45 >> > GEN /tmp/build/perf/common-cmds.h >> > GEN /tmp/build/perf/arch/arm64/include/generated/asm/sysreg-defs.h >> > GEN perf-archive >> > GEN perf-iostat >> > CC /tmp/build/perf/dlfilters/dlfilter-test-api-v0.o >> > CC /tmp/build/perf/dlfilters/dlfilter-test-api-v2.o >> > CC /tmp/build/perf/dlfilters/dlfilter-show-cycles.o >> > INSTALL /tmp/build/perf/libapi/include/api/cpu.h >> > INSTALL /tmp/build/perf/libapi/include/api/debug.h >> > INSTALL /tmp/build/perf/libapi/include/api/io.h >> > MKDIR /tmp/build/perf/libapi/fd/ >> > INSTALL /tmp/build/perf/libapi/include/api/io_dir.h >> > CC /tmp/build/perf/libapi/cpu.o >> > MKDIR /tmp/build/perf/libapi/fs/ >> > INSTALL /tmp/build/perf/libapi/include/api/fd/array.h >> > CC /tmp/build/perf/libapi/debug.o >> > MKDIR /tmp/build/perf/libapi/fs/ >> > MKDIR /tmp/build/perf/libapi/fs/ >> > CC /tmp/build/perf/libapi/fd/array.o >> > INSTALL /tmp/build/perf/libapi/include/api/fs/tracing_path.h >> > CC /tmp/build/perf/libapi/str_error_r.o >> > INSTALL /tmp/build/perf/libapi/include/api/fs/fs.h >> > CC /tmp/build/perf/libapi/fs/tracing_path.o >> > CC /tmp/build/perf/libapi/fs/fs.o >> > CC /tmp/build/perf/libapi/fs/cgroup.o >> > INSTALL libapi_headers >> > INSTALL /tmp/build/perf/libperf/include/perf/bpf_perf.h >> > INSTALL /tmp/build/perf/libperf/include/perf/core.h >> > INSTALL /tmp/build/perf/libperf/include/perf/cpumap.h >> > INSTALL /tmp/build/perf/libperf/include/perf/threadmap.h >> > CC /tmp/build/perf/libperf/core.o >> > CC /tmp/build/perf/libperf/cpumap.o >> > CC /tmp/build/perf/libperf/threadmap.o >> > INSTALL /tmp/build/perf/libperf/include/perf/evlist.h >> > CC /tmp/build/perf/libperf/evlist.o >> > CC /tmp/build/perf/libperf/evsel.o >> > CC /tmp/build/perf/libperf/mmap.o >> > CC /tmp/build/perf/libperf/zalloc.o >> > INSTALL /tmp/build/perf/libsubcmd/include/subcmd/exec-cmd.h >> > INSTALL /tmp/build/perf/libperf/include/perf/evsel.h >> > CC /tmp/build/perf/libperf/xyarray.o >> > CC /tmp/build/perf/libperf/lib.o >> > INSTALL /tmp/build/perf/libsubcmd/include/subcmd/help.h >> > INSTALL /tmp/build/perf/libsubcmd/include/subcmd/pager.h >> > LINK /tmp/build/perf/dlfilters/dlfilter-test-api-v0.so >> > INSTALL /tmp/build/perf/libsubcmd/include/subcmd/parse-options.h >> > LD /tmp/build/perf/libapi/fd/libapi-in.o >> > INSTALL /tmp/build/perf/libsubcmd/include/subcmd/run-command.h >> > INSTALL libsubcmd_headers >> > LINK /tmp/build/perf/dlfilters/dlfilter-test-api-v2.so >> > INSTALL /tmp/build/perf/libperf/include/perf/event.h >> > INSTALL /tmp/build/perf/libsymbol/include/symbol/kallsyms.h >> > CC /tmp/build/perf/libsymbol/kallsyms.o >> > INSTALL /tmp/build/perf/libperf/include/perf/mmap.h >> > INSTALL /tmp/build/perf/libperf/include/internal/cpumap.h >> > INSTALL /tmp/build/perf/libperf/include/internal/evlist.h >> > INSTALL /tmp/build/perf/libperf/include/internal/evsel.h >> > INSTALL /tmp/build/perf/libperf/include/internal/rc_check.h >> > INSTALL /tmp/build/perf/libperf/include/internal/mmap.h >> > INSTALL /tmp/build/perf/libperf/include/internal/threadmap.h >> > INSTALL /tmp/build/perf/libperf/include/internal/lib.h >> > INSTALL /tmp/build/perf/libperf/include/internal/xyarray.h >> > LINK /tmp/build/perf/dlfilters/dlfilter-show-cycles.so >> > LD /tmp/build/perf/libapi/fs/libapi-in.o >> > evlist.c:28:6: error: no previous prototype for 'perf_evlist__init' [-Werror=missing-prototypes] >> > void perf_evlist__init(struct perf_evlist *evlist) >> > ^~~~~~~~~~~~~~~~~ >> >> Hmm.. but on line 8 of tools/lib/perf/evlist.c is: >> #include <internal/evlist.h> >> is there a libperf installed somewhere? I thought we were just >> statically linking currently. I'm not sure what I can do to resolve >> this, it seems like a set up issue. > > > I'll investigate and report back. Ping. Thanks, Ian > - Arnaldo > >>