Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf build: Check what binutils's 'disassembler()' signature to use

Commit 003ca0fd2286 ("Refactor disassembler selection") in the binutils
repo, which changed the disassembler() function signature, so we must
use the feature test introduced in fb982666e380 ("tools/bpftool: fix
bpftool build with bintutils >= 2.9") to deal with that.

Committer testing:

After adding the missing function call to test-all.c, and:

FEATURE_CHECK_LDFLAGS-disassembler-four-args = -bfd -lopcodes

And the fallbacks for cases where we need -liberty and sometimes -lz to
tools/perf/Makefile.config, we get:

$ make -C tools/perf O=/tmp/build/perf install-bin
make: Entering directory '/home/acme/git/perf/tools/perf'
BUILD: Doing 'make -j8' parallel build

Auto-detecting system features:
... dwarf: [ on ]
... dwarf_getlocations: [ on ]
... glibc: [ on ]
... gtk2: [ on ]
... libaudit: [ on ]
... libbfd: [ on ]
... libelf: [ on ]
... libnuma: [ on ]
... numa_num_possible_cpus: [ on ]
... libperl: [ on ]
... libpython: [ on ]
... libslang: [ on ]
... libcrypto: [ on ]
... libunwind: [ on ]
... libdw-dwarf-unwind: [ on ]
... zlib: [ on ]
... lzma: [ on ]
... get_cpuid: [ on ]
... bpf: [ on ]
... libaio: [ on ]
... disassembler-four-args: [ on ]
CC /tmp/build/perf/jvmti/libjvmti.o
CC /tmp/build/perf/builtin-bench.o
<SNIP>
$
$

The feature detection test-all.bin gets successfully built and linked:

$ ls -la /tmp/build/perf/feature/test-all.bin
-rwxrwxr-x. 1 acme acme 2680352 Mar 19 11:07 /tmp/build/perf/feature/test-all.bin
$ nm /tmp/build/perf/feature/test-all.bin | grep -w disassembler
0000000000061f90 T disassembler
$

Time to move on to the patches that make use of this disassembler()
routine in binutils's libopcodes.

Signed-off-by: Song Liu <songliubraving@fb.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Jakub Kicinski <jakub.kicinski@netronome.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Roman Gushchin <guro@fb.com>
Cc: Stanislav Fomichev <sdf@google.com>
Link: http://lkml.kernel.org/r/20190312053051.2690567-13-songliubraving@fb.com
[ split from a larger patch, added missing FEATURE_CHECK_LDFLAGS-disassembler-four-args ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Song Liu and committed by
Arnaldo Carvalho de Melo
8a1b1718 3ca3877a

+18 -2
+4 -2
tools/build/Makefile.feature
··· 66 66 sched_getcpu \ 67 67 sdt \ 68 68 setns \ 69 - libaio 69 + libaio \ 70 + disassembler-four-args 70 71 71 72 # FEATURE_TESTS_BASIC + FEATURE_TESTS_EXTRA is the complete list 72 73 # of all feature tests ··· 119 118 lzma \ 120 119 get_cpuid \ 121 120 bpf \ 122 - libaio 121 + libaio \ 122 + disassembler-four-args 123 123 124 124 # Set FEATURE_CHECK_(C|LD)FLAGS-all for all FEATURE_TESTS features. 125 125 # If in the future we need per-feature checks/flags for features not
+5
tools/build/feature/test-all.c
··· 178 178 # include "test-reallocarray.c" 179 179 #undef main 180 180 181 + #define main main_test_disassembler_four_args 182 + # include "test-disassembler-four-args.c" 183 + #undef main 184 + 181 185 int main(int argc, char *argv[]) 182 186 { 183 187 main_test_libpython(); ··· 223 219 main_test_setns(); 224 220 main_test_libaio(); 225 221 main_test_reallocarray(); 222 + main_test_disassembler_four_args(); 226 223 227 224 return 0; 228 225 }
+9
tools/perf/Makefile.config
··· 227 227 228 228 FEATURE_CHECK_LDFLAGS-libaio = -lrt 229 229 230 + FEATURE_CHECK_LDFLAGS-disassembler-four-args = -lbfd -lopcodes 231 + 230 232 CFLAGS += -fno-omit-frame-pointer 231 233 CFLAGS += -ggdb3 232 234 CFLAGS += -funwind-tables ··· 727 725 728 726 ifeq ($(feature-libbfd-liberty), 1) 729 727 EXTLIBS += -lbfd -lopcodes -liberty 728 + FEATURE_CHECK_LDFLAGS-disassembler-four-args += -liberty -ldl 730 729 else 731 730 ifeq ($(feature-libbfd-liberty-z), 1) 732 731 EXTLIBS += -lbfd -lopcodes -liberty -lz 732 + FEATURE_CHECK_LDFLAGS-disassembler-four-args += -liberty -lz -ldl 733 733 endif 734 734 endif 735 + $(call feature_check,disassembler-four-args) 735 736 endif 736 737 737 738 ifdef NO_DEMANGLE ··· 811 806 812 807 ifdef HAVE_KVM_STAT_SUPPORT 813 808 CFLAGS += -DHAVE_KVM_STAT_SUPPORT 809 + endif 810 + 811 + ifeq ($(feature-disassembler-four-args), 1) 812 + CFLAGS += -DDISASM_FOUR_ARGS_SIGNATURE 814 813 endif 815 814 816 815 ifeq (${IS_64_BIT}, 1)