google / perfetto

Performance instrumentation and tracing for Android, Linux and Chrome (read-only mirror of https://android.googlesource.com/platform/external/perfetto/)
https://www.perfetto.dev
Apache License 2.0
2.86k stars 358 forks source link

build perfetto on ubuntu 22.04 fail #883

Closed wjj1928 closed 1 month ago

wjj1928 commented 1 month ago

I try to build perfetto on ubuntu 22.04 per official document: https://perfetto.dev/docs/contributing/getting-started,

When I execute command: tools/ninja -C out/linux_clang_release

I got below error: python3 ../../gn/standalone/protoc.py ./protoc --proto_path ../../ --cpp_out lite=true:gen/ ../../protos/perfetto/common/android_energy_consumer_descriptor.proto ../../protos/perfetto/common/android_log_constants.proto ../../protos/perfetto/common/builtin_clock.proto ../../protos/perfetto/common/commit_data_request.proto ../../protos/perfetto/common/data_source_descriptor.proto ../../protos/perfetto/common/descriptor.proto ../../protos/perfetto/common/ftrace_descriptor.proto ../../protos/perfetto/common/gpu_counter_descriptor.proto ../../protos/perfetto/common/interceptor_descriptor.proto ../../protos/perfetto/common/observable_events.proto ../../protos/perfetto/common/perf_events.proto ../../protos/perfetto/common/protolog_common.proto ../../protos/perfetto/common/sys_stats_counters.proto ../../protos/perfetto/common/trace_stats.proto ../../protos/perfetto/common/tracing_service_capabilities.proto ../../protos/perfetto/common/tracing_service_state.proto ../../protos/perfetto/common/track_event_descriptor.proto

[5/3063] compile ../../src/shared_lib/intern_map_unittest.cc

ninja: build stopped: subcommand failed.

Wish anyone can help me out.

Thanks.

LalitMaganti commented 1 month ago

Are you sure you have Python3 installed? That's a required dependency for building Perfetto.

wjj1928 commented 1 month ago

Yes, I found it as below:

/media/sf_work$ which python3

/usr/bin/python3

/media/sf_work$ python3 --version

Python 3.10.12

Does this version work?

LalitMaganti commented 1 month ago

Yes that should work.

Your error message in #1 does not actually indicate the failure: there is no failure message there. Can you rerun ninja with -v and find the line of output with the actual error and paste that instead?

wjj1928 commented 1 month ago

attached log with -v option:

tools/ninja -v -C out/linux_clang_release

error.log

LalitMaganti commented 1 month ago

I'm very confused because your log does not show any error messages. It just shows the protoc Python script failing which is quite baffling.

Can you run:

cd out/linux_clang_release
python3 ../../gn/standalone/protoc.py ./protoc --proto_path ../../ --cpp_out lite=true:gen/ ../../protos/perfetto/common/android_energy_consumer_descriptor.proto ../../protos/perfetto/common/android_log_constants.proto ../../protos/perfetto/common/builtin_clock.proto ../../protos/perfetto/common/commit_data_request.proto ../../protos/perfetto/common/data_source_descriptor.proto ../../protos/perfetto/common/descriptor.proto ../../protos/perfetto/common/ftrace_descriptor.proto ../../protos/perfetto/common/gpu_counter_descriptor.proto ../../protos/perfetto/common/interceptor_descriptor.proto ../../protos/perfetto/common/observable_events.proto ../../protos/perfetto/common/perf_events.proto ../../protos/perfetto/common/protolog_common.proto ../../protos/perfetto/common/sys_stats_counters.proto ../../protos/perfetto/common/trace_stats.proto ../../protos/perfetto/common/tracing_service_capabilities.proto ../../protos/perfetto/common/tracing_service_state.proto ../../protos/perfetto/common/track_event_descriptor.proto

manually to see what gets printed

wjj1928 commented 1 month ago

Nothing output from that command. I reinstall python3 as well but no luck.

wjj1928 commented 1 month ago

I just search the FAILED line, and it says:

FAILED: gen/protos/perfetto/common/android_energy_consumer_descriptor.pb.h gen/protos/perfetto/common/android_energy_consumer_descriptor.pb.cc gen/protos/perfetto/common/android_log_constants.pb.h gen/protos/perfetto/common/android_log_constants.pb.cc gen/protos/perfetto/common/builtin_clock.pb.h gen/protos/perfetto/common/builtin_clock.pb.cc gen/protos/perfetto/common/commit_data_request.pb.h gen/protos/perfetto/common/commit_data_request.pb.cc gen/protos/perfetto/common/data_source_descriptor.pb.h gen/protos/perfetto/common/data_source_descriptor.pb.cc gen/protos/perfetto/common/descriptor.pb.h gen/protos/perfetto/common/descriptor.pb.cc gen/protos/perfetto/common/ftrace_descriptor.pb.h gen/protos/perfetto/common/ftrace_descriptor.pb.cc gen/protos/perfetto/common/gpu_counter_descriptor.pb.h gen/protos/perfetto/common/gpu_counter_descriptor.pb.cc gen/protos/perfetto/common/interceptor_descriptor.pb.h gen/protos/perfetto/common/interceptor_descriptor.pb.cc gen/protos/perfetto/common/observable_events.pb.h gen/protos/perfetto/common/observable_events.pb.cc gen/protos/perfetto/common/perf_events.pb.h gen/protos/perfetto/common/perf_events.pb.cc gen/protos/perfetto/common/protolog_common.pb.h gen/protos/perfetto/common/protolog_common.pb.cc gen/protos/perfetto/common/sys_stats_counters.pb.h gen/protos/perfetto/common/sys_stats_counters.pb.cc gen/protos/perfetto/common/trace_stats.pb.h gen/protos/perfetto/common/trace_stats.pb.cc gen/protos/perfetto/common/tracing_service_capabilities.pb.h gen/protos/perfetto/common/tracing_service_capabilities.pb.cc gen/protos/perfetto/common/tracing_service_state.pb.h gen/protos/perfetto/common/tracing_service_state.pb.cc gen/protos/perfetto/common/track_event_descriptor.pb.h gen/protos/perfetto/common/track_event_descriptor.pb.cc

Below file not exist:

$ ls out/linux_clang_release/gen/protos/perfetto/common/android_energy_consumer_descriptor.pb.h

ls: cannot access 'out/linux_clang_release/gen/protos/perfetto/common/android_energy_consumer_descriptor.pb.h': No such file or directory
$ find . -name android_energy_consumer_descriptor.*

./protos/perfetto/common/android_energy_consumer_descriptor.proto
LalitMaganti commented 1 month ago

That's working as intended: the script will create that file.

wjj1928 commented 1 month ago

I try to reinstall ubuntu24.04 with virtualbox7.0.20. and build failed as well. so I almost do nothing with the new installation, I guess it's a issue specific for virtualbox + ubuntu environment.

LalitMaganti commented 1 month ago

I think I might have an idea when you say Virtualbox. Can you do the following:

tools/gn args out/linux_clang_release

In the text editor that pops up, add the line:

enable_perfetto_x64_cpu_opt = false

to the bottom.

Then rerun the tools/ninja command.

wjj1928 commented 1 month ago

exactly, it works fine now.

BTW, how can I add this parameter when config? then I can do it in a bash script to avoid manual interaction.

LalitMaganti commented 1 month ago

So the root cause of your problem here is that AVX/AVX2 instructions are not enabled on VirtualBox: you can see forum posts like https://forums.virtualbox.org/viewtopic.php?t=106867 which explain how they could be turned on.

The option I proposed above is a workaround not a fix (the fix is to enable AVX): it significantly reduces performance of a bunch of Perfetto based tooling which take advantage of AVX instructions.

If you want to script the workaround though, you can do something like this:

tools/gn gen out/linux_clang_release '--args "is_debug=false is_clang=true enable_perfetto_x64_cpu_opt=false"'