ci/container: Add script to build Perfetto tracebox
Add a script to build Perfetto’s tracebox tool for x86_64 and arm64 targets on Linux and Android. Signed-off-by: Laura Nao <laura.nao@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38517>
This commit is contained in:
77
.gitlab-ci/container/build-perfetto.sh
Executable file
77
.gitlab-ci/container/build-perfetto.sh
Executable file
@@ -0,0 +1,77 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -uex
|
||||||
|
|
||||||
|
section_start perfetto "Building perfetto"
|
||||||
|
|
||||||
|
BASE_PWD=$PWD
|
||||||
|
|
||||||
|
PERFETTO_REVISION=$(grep 'revision =' subprojects/perfetto.wrap | cut -d ' ' -f3)
|
||||||
|
|
||||||
|
patch_files=(
|
||||||
|
"build-perfetto-Fix-C-standard-library-build-errors-with-Debian-13.patch"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Set PERFETTO_ARCH based on DEBIAN_ARCH
|
||||||
|
if [[ -z "${PERFETTO_ARCH:-}" ]]; then
|
||||||
|
case "$DEBIAN_ARCH" in
|
||||||
|
amd64) PERFETTO_ARCH=x64;;
|
||||||
|
arm64) PERFETTO_ARCH=arm64;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
git clone --branch "$PERFETTO_REVISION" --depth 1 https://github.com/google/perfetto /perfetto
|
||||||
|
|
||||||
|
pushd /perfetto
|
||||||
|
|
||||||
|
for patch in "${patch_files[@]}"; do
|
||||||
|
echo "Applying patch: $patch"
|
||||||
|
git am "$BASE_PWD/.gitlab-ci/container/patches/$patch"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Base GN args
|
||||||
|
mkdir -p _build
|
||||||
|
cat >_build/args.gn <<EOF
|
||||||
|
is_debug=false
|
||||||
|
target_cpu="${PERFETTO_ARCH}"
|
||||||
|
target_os="${PERFETTO_TARGET}"
|
||||||
|
EOF
|
||||||
|
|
||||||
|
case "$PERFETTO_TARGET" in
|
||||||
|
linux)
|
||||||
|
# Override Perfetto’s default toolchain selection here, as the bundled
|
||||||
|
# arm64 toolchain is an x86-64 -> arm64 cross-compiler.
|
||||||
|
cat >>_build/args.gn <<EOF
|
||||||
|
is_system_compiler = true
|
||||||
|
is_hermetic_clang = false
|
||||||
|
ar = "ar"
|
||||||
|
cc = "clang-${LLVM_VERSION}"
|
||||||
|
cxx = "clang++-${LLVM_VERSION}"
|
||||||
|
extra_ldflags = "-fuse-ld=lld-${LLVM_VERSION} -lpthread -ldl"
|
||||||
|
EOF
|
||||||
|
./tools/install-build-deps
|
||||||
|
;;
|
||||||
|
android)
|
||||||
|
# No additional args needed when cross-building for Android
|
||||||
|
./tools/install-build-deps --android
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unexpected PERFETTO_TARGET value: $PERFETTO_TARGET"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
./tools/gn gen _build/
|
||||||
|
./tools/ninja -C _build/ tracebox
|
||||||
|
|
||||||
|
mkdir -p build
|
||||||
|
cp _build/tracebox build/
|
||||||
|
|
||||||
|
"${STRIP_CMD:-strip}" build/tracebox || true
|
||||||
|
|
||||||
|
# Cleanup everything except build/
|
||||||
|
find . -mindepth 1 -maxdepth 1 ! -name build -exec rm -rf {} +
|
||||||
|
|
||||||
|
popd
|
||||||
|
|
||||||
|
section_end perfetto
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
From 7a5a9e5be4306637cd3a0ef0f770832f4b4cf4b4 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Laura Nao <laura.nao@collabora.com>
|
||||||
|
Date: Wed, 12 Nov 2025 14:45:32 +0100
|
||||||
|
Subject: [PATCH] Fix C++ standard library build errors with Debian 13
|
||||||
|
|
||||||
|
Address missing <algorithm> and <optional> includes that caused build
|
||||||
|
failures ("no member named 'find' in namespace 'std'" and
|
||||||
|
"error: no template named 'optional' in namespace 'std'") when building
|
||||||
|
with the native toolchain on Debian 13.
|
||||||
|
|
||||||
|
This was fixed upstream in v48[1] and v49[2] respectively, so this patch
|
||||||
|
can be dropped once Perfetto is updated to v48+.
|
||||||
|
|
||||||
|
[1] https://github.com/google/perfetto/commit/d005c0123b2f929b918359a53ffe61d7ca2212a0
|
||||||
|
[2] https://github.com/google/perfetto/commit/acc24608c84d2d2d8d684f40a110d0a6f4eddc51
|
||||||
|
|
||||||
|
Signed-off-by: Laura Nao <laura.nao@collabora.com>
|
||||||
|
---
|
||||||
|
src/profiling/common/producer_support.cc | 1 +
|
||||||
|
src/traced/probes/sys_stats/sys_stats_data_source.h | 1 +
|
||||||
|
2 files changed, 2 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/src/profiling/common/producer_support.cc b/src/profiling/common/producer_support.cc
|
||||||
|
index 5303658..e9e193d 100644
|
||||||
|
--- a/src/profiling/common/producer_support.cc
|
||||||
|
+++ b/src/profiling/common/producer_support.cc
|
||||||
|
@@ -16,6 +16,7 @@
|
||||||
|
|
||||||
|
#include "src/profiling/common/producer_support.h"
|
||||||
|
|
||||||
|
+#include <algorithm>
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
|
#include "perfetto/ext/base/android_utils.h"
|
||||||
|
diff --git a/src/traced/probes/sys_stats/sys_stats_data_source.h b/src/traced/probes/sys_stats/sys_stats_data_source.h
|
||||||
|
index e09cd8a..7e4749b 100644
|
||||||
|
--- a/src/traced/probes/sys_stats/sys_stats_data_source.h
|
||||||
|
+++ b/src/traced/probes/sys_stats/sys_stats_data_source.h
|
||||||
|
@@ -21,6 +21,7 @@
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
|
+#include <optional>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "perfetto/ext/base/paged_memory.h"
|
||||||
|
--
|
||||||
|
2.39.5
|
||||||
|
|
||||||
Reference in New Issue
Block a user