* LTO builds
@ 2023-05-28 22:48 Ian Rogers
0 siblings, 0 replies; only message in thread
From: Ian Rogers @ 2023-05-28 22:48 UTC (permalink / raw)
To: linux-perf-users
Hi,
I just wanted to post on this as I think others may be interested,
perhaps in the future the standard non-"DEBUG=1" build can be LTO. I
played around a bit with LTO builds for the perf tool. clang worked if
I did:
$ make -C tools/perf O=/tmp/perf EXTRA_CFLAGS="-flto"
EXTRA_CXXFLAGS="-flto" CC=clang CXX=clang++ LD=ld.lld
However, gcc didn't compile without the hacky patch at the end, and
then it failed with link time issues:
```
$ make -C tools/perf O=/tmp/perf EXTRA_CFLAGS="-flto"
EXTRA_CXXFLAGS="-flto" CC=gcc CXX=g++ LD=ld.lld
make: Entering directory '~/kernel.org/tools/perf'
BUILD: Doing 'make -j16' parallel build
Warning: Kernel ABI header at 'tools/include/uapi/linux/perf_event.h'
differs from latest version at 'include/uapi/linux/perf_event.h'
diff -u tools/include/uapi/linux/perf_event.h include/uapi/linux/perf_event.h
Warning: Kernel ABI header at
'tools/arch/arm64/include/uapi/asm/perf_regs.h' differs from latest
version at 'arch/arm64/include/uapi/asm/perf_regs.h'
diff -u tools/arch/arm64/include/uapi/asm/perf_regs.h
arch/arm64/include/uapi/asm/perf_regs.h
Warning: Kernel ABI header at 'tools/include/linux/coresight-pmu.h'
differs from latest version at 'include/linux/coresight-pmu.h'
diff -u tools/include/linux/coresight-pmu.h include/linux/coresight-pmu.h
Makefile.config:602: No sys/sdt.h found, no SDT events are defined,
please install systemtap-sdt-devel or systemtap-sdt-dev
Makefile.config:985: No libcap found, disables capability support,
please install libcap-devel/libcap-dev
Makefile.config:998: No numa.h found, disables 'perf bench numa mem'
benchmark, please install numactl-devel/libnuma-devel/libnuma-dev
Makefile.config:1057: No libbabeltrace found, disables 'perf data' CTF
format support, please install
libbabeltrace-dev[el]/libbabeltrace-ctf-dev
Auto-detecting system features:
... dwarf: [ on ]
... dwarf_getlocations: [ on ]
... glibc: [ on ]
... libbfd: [ on ]
... libbfd-buildid: [ on ]
... libcap: [ OFF ]
... libelf: [ on ]
... libnuma: [ OFF ]
... numa_num_possible_cpus: [ OFF ]
... libperl: [ on ]
... libpython: [ on ]
... libcrypto: [ on ]
... libunwind: [ on ]
... libdw-dwarf-unwind: [ on ]
... zlib: [ on ]
... lzma: [ on ]
... get_cpuid: [ on ]
... bpf: [ on ]
... libaio: [ on ]
... libzstd: [ on ]
INSTALL libsubcmd_headers
INSTALL libapi_headers
INSTALL libperf_headers
INSTALL libsymbol_headers
INSTALL libbpf_headers
LINK /tmp/perf/perf
lto-wrapper: warning: using serial compilation of 50 LTRANS jobs
lto-wrapper: note: see the ‘-flto’ option documentation for more information
/usr/bin/ld: /tmp/cclv2Qid.ltrans3.ltrans.o: in function `script_fetch_insn':
~/kernel.org/tools/perf/arch/x86/util/archinsn.c:23: undefined
reference to `insn_decode'
/usr/bin/ld: /tmp/cclv2Qid.ltrans32.ltrans.o: in function
`inline_list__append_record':
~/kernel.org/tools/perf/util/symbol-elf.c:286: undefined reference to
`cxx_demangle_sym'
/usr/bin/ld: /tmp/cclv2Qid.ltrans37.ltrans.o: in function
`dso__synthesize_plt_symbols':
~/kernel.org/tools/perf/util/symbol-elf.c:286: undefined reference to
`cxx_demangle_sym'
/usr/bin/ld: ~/kernel.org/tools/perf/util/symbol-elf.c:286: undefined
reference to `cxx_demangle_sym'
/usr/bin/ld: /tmp/cclv2Qid.ltrans37.ltrans.o: in function `dso__demangle_sym':
~/kernel.org/tools/perf/util/symbol-elf.c:286: undefined reference to
`cxx_demangle_sym'
/usr/bin/ld: /tmp/cclv2Qid.ltrans37.ltrans.o: in function
`dso__load_sym_internal.lto_priv.0':
~/kernel.org/tools/perf/util/symbol-elf.c:286: undefined reference to
`cxx_demangle_sym'
/usr/bin/ld: /tmp/cclv2Qid.ltrans41.ltrans.o: in function `arch_fetch_insn':
~/kernel.org/tools/perf/arch/x86/util/archinsn.c:23: undefined
reference to `insn_decode'
/usr/bin/ld: /tmp/cclv2Qid.ltrans49.ltrans.o: in function
`perf_sample__fprintf_insn.isra.0':
~/kernel.org/tools/perf/arch/x86/util/archinsn.c:23: undefined
reference to `insn_decode'
/usr/bin/ld: /tmp/cclv2Qid.ltrans10.ltrans.o:(.data.rel.ro+0x28):
undefined reference to `memset_orig'
/usr/bin/ld: /tmp/cclv2Qid.ltrans10.ltrans.o:(.data.rel.ro+0x40):
undefined reference to `__memset'
/usr/bin/ld: /tmp/cclv2Qid.ltrans10.ltrans.o:(.data.rel+0x28):
undefined reference to `memcpy_orig'
/usr/bin/ld: /tmp/cclv2Qid.ltrans10.ltrans.o:(.data.rel+0x40):
undefined reference to `__memcpy'
/usr/bin/ld: /tmp/cclv2Qid.ltrans33.ltrans.o: in function `__intel_pt_log_insn':
~/kernel.org/tools/perf/util/intel-pt-decoder/intel-pt-log.c:236:
undefined reference to `intel_pt_insn_desc'
/usr/bin/ld: /tmp/cclv2Qid.ltrans33.ltrans.o: in function
`__intel_pt_log_insn_no_data':
~/kernel.org/tools/perf/util/intel-pt-decoder/intel-pt-log.c:251:
undefined reference to `intel_pt_insn_desc'
/usr/bin/ld: /tmp/cclv2Qid.ltrans34.ltrans.o: in function
`intel_pt_sample_flags':
~/kernel.org/tools/perf/util/intel-pt.c:1503: undefined reference to
`intel_pt_insn_type'
/usr/bin/ld: /tmp/cclv2Qid.ltrans34.ltrans.o: in function
`intel_pt_walk_next_insn':
~/kernel.org/tools/perf/util/intel-pt.c:860: undefined reference to
`intel_pt_get_insn'
/usr/bin/ld: /tmp/cclv2Qid.ltrans35.ltrans.o: in function
`intel_bts_process_queue':
~/kernel.org/tools/perf/util/intel-bts.c:335: undefined reference to
`intel_pt_get_insn'
/usr/bin/ld: ~/kernel.org/tools/perf/util/intel-bts.c:390: undefined
reference to `intel_pt_insn_type'
/usr/bin/ld: /tmp/cclv2Qid.ltrans42.ltrans.o: in function `test_data_item':
~/kernel.org/tools/perf/arch/x86/tests/insn-x86.c:106: undefined
reference to `insn_decode'
/usr/bin/ld: ~/kernel.org/tools/perf/arch/x86/tests/insn-x86.c:122:
undefined reference to `intel_pt_get_insn'
/usr/bin/ld: /tmp/cclv2Qid.ltrans42.ltrans.o: in function
`test__arch_unwind_sample':
~/kernel.org/tools/perf/arch/x86/tests/dwarf-unwind.c:72: undefined
reference to `perf_regs_load'
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile.perf:682: /tmp/perf/perf] Error 1
make[1]: *** [Makefile.perf:236: sub-make] Error 2
make: *** [Makefile:70: all] Error 2
make: Leaving directory '~/kernel.org/tools/perf'
```
A number of the link time issues are with C++ code and assembly code.
I played around with options like AR=gcc-ar but without success. I
wondered if people on the list had thoughts on how to get this to
work.
Thanks,
Ian
Patch:
```
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index aa44fdc84763..6bf13e052fff 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -33,9 +33,7 @@
static bool dont_fork;
const char *dso_to_test;
-struct test_suite *__weak arch_tests[] = {
- NULL,
-};
+extern struct test_suite *__weak arch_tests[];
static struct test_suite *generic_tests[] = {
&suite__vmlinux_matches_kallsyms,
diff --git a/tools/perf/tests/stat.c b/tools/perf/tests/stat.c
index 500974040fe3..706780fb5695 100644
--- a/tools/perf/tests/stat.c
+++ b/tools/perf/tests/stat.c
@@ -27,7 +27,7 @@ static int process_stat_config_event(struct
perf_tool *tool __maybe_unused,
struct machine *machine __maybe_unused)
{
struct perf_record_stat_config *config = &event->stat_config;
- struct perf_stat_config stat_config;
+ struct perf_stat_config stat_config = {};
#define HAS(term, val) \
has_term(config, PERF_STAT_CONFIG_TERM__##term, val)
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index e0c3f2037477..80ac426b7e6a 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -754,7 +754,7 @@ parse_events_config_bpf(struct parse_events_state
*parse_state,
struct list_head *head_config)
{
struct parse_events_term *term;
- int error_pos;
+ int error_pos = 0;
if (!head_config || list_empty(head_config))
return 0;
diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c
index 0f7b8a8cdea6..cef1d4a41c05 100644
--- a/tools/perf/util/stat.c
+++ b/tools/perf/util/stat.c
@@ -707,7 +707,7 @@ size_t perf_event__fprintf_stat_round(union
perf_event *event, FILE *fp)
size_t perf_event__fprintf_stat_config(union perf_event *event, FILE *fp)
{
- struct perf_stat_config sc;
+ struct perf_stat_config sc = {};
size_t ret;
perf_event__read_stat_config(&sc, &event->stat_config);
```
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2023-05-28 22:49 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-28 22:48 LTO builds Ian Rogers
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.