Client library: make code gc-sections friendly
The problem we want to solve is the following: on Android
some targets (e.g. libsurfaceflinger) rely on the system
backend for production code but then want the in-process
backend for tests. Both backends are big in terms of binary
size (~200 KB).
Instead of relying on dedicated build targets this code
arranges the build targets in a way that allows the linker to
dead-code-eliminate unused backends if the caller doesn't
require them.
Test: manual: the size of /system/lib64/libsurfaceflinger.so
is == the size when completely removing the in-process
target.
Bug: 148198993
Change-Id: Ie891a9b2e6ec38a3781318d1204a694899b01656
diff --git a/BUILD b/BUILD
index e7a59ac..5c0cb4b 100644
--- a/BUILD
+++ b/BUILD
@@ -475,6 +475,8 @@
"include/perfetto/tracing/event_context.h",
"include/perfetto/tracing/internal/basic_types.h",
"include/perfetto/tracing/internal/data_source_internal.h",
+ "include/perfetto/tracing/internal/in_process_tracing_backend.h",
+ "include/perfetto/tracing/internal/system_tracing_backend.h",
"include/perfetto/tracing/internal/tracing_muxer.h",
"include/perfetto/tracing/internal/tracing_tls.h",
"include/perfetto/tracing/internal/track_event_data_source.h",
@@ -1220,15 +1222,13 @@
],
)
-# GN target: //src/tracing:client_api_base
+# GN target: //src/tracing:client_api_without_backends
filegroup(
- name = "src_tracing_client_api_base",
+ name = "src_tracing_client_api_without_backends",
srcs = [
"src/tracing/data_source.cc",
"src/tracing/debug_annotation.cc",
"src/tracing/event_context.cc",
- "src/tracing/internal/in_process_tracing_backend.h",
- "src/tracing/internal/system_tracing_backend.h",
"src/tracing/internal/tracing_muxer_impl.cc",
"src/tracing/internal/tracing_muxer_impl.h",
"src/tracing/internal/track_event_internal.cc",
@@ -1264,9 +1264,9 @@
],
)
-# GN target: //src/tracing:system_process_backend
+# GN target: //src/tracing:system_backend
filegroup(
- name = "src_tracing_system_process_backend",
+ name = "src_tracing_system_backend",
srcs = [
"src/tracing/internal/system_tracing_backend.cc",
],
@@ -2479,7 +2479,7 @@
":src_ipc_common",
":src_ipc_host",
":src_protozero_protozero",
- ":src_tracing_client_api_base",
+ ":src_tracing_client_api_without_backends",
":src_tracing_common",
":src_tracing_core_core",
":src_tracing_core_service",
@@ -2489,7 +2489,7 @@
":src_tracing_ipc_producer_producer",
":src_tracing_ipc_service_service",
":src_tracing_platform_posix",
- ":src_tracing_system_process_backend",
+ ":src_tracing_system_backend",
],
hdrs = [
":include_perfetto_base_base",