From 8805a72f1bb55fe427c8286f5426002ec43e3aac Mon Sep 17 00:00:00 2001 From: Chris Green Date: Thu, 19 Feb 2026 21:32:46 +0000 Subject: [PATCH 1/4] Add Perfetto profiling support to CI workflow This commit adds Perfetto profiling as a matrix item in the cmake-build GitHub workflow, enabling performance profiling of the C++ codebase. Changes: - Add FindPerfetto.cmake module that searches standard locations (/opt/perfetto, /usr/local/include, /usr/include) and creates a Perfetto::Perfetto imported target following CMake best practices - Add ENABLE_PERFETTO CMake option and integrate Perfetto SDK linking to the phlex executable when profiling is enabled - Install Perfetto SDK (perfetto.h and perfetto.cc) in CI Docker image at /opt/perfetto for use during CI builds - Add gcc/perfetto and clang/perfetto to available build matrix combinations in generate_matrix.py - Add dedicated workflow step for Perfetto profiling runs that executes tests with profiling enabled, following the pattern established by the Valgrind step - Add weekly scheduled trigger (Saturdays at 18:00 UTC) that runs gcc/perfetto by default for regular performance profiling The implementation follows existing workflow conventions for modularity, naming, and reusable actions. Users can trigger Perfetto builds via workflow_dispatch, issue comments (@phlexbot build gcc/perfetto), or wait for the weekly scheduled run. --- .../generate-build-matrix/generate_matrix.py | 14 +++++++-- .github/workflows/cmake-build.yaml | 30 +++++++++++++++++-- .gitignore | 1 + CMakeLists.txt | 13 ++++++++ Modules/FindPerfetto.cmake | 29 ++++++++++++++++++ ci/Dockerfile | 20 +++++++++++++ 6 files changed, 101 insertions(+), 6 deletions(-) create mode 100644 Modules/FindPerfetto.cmake diff --git a/.github/actions/generate-build-matrix/generate_matrix.py b/.github/actions/generate-build-matrix/generate_matrix.py index eb44d4cce..4b8db62af 100644 --- a/.github/actions/generate-build-matrix/generate_matrix.py +++ b/.github/actions/generate-build-matrix/generate_matrix.py @@ -7,10 +7,16 @@ def get_default_combinations(event_name, all_combinations): """Gets the default build combinations based on the GitHub event type.""" - if event_name in ("push", "pull_request", "pull_request_target", "workflow_dispatch"): + if event_name in ( + "push", + "pull_request", + "pull_request_target", + "issue_comment", + "workflow_dispatch", + ): return ["gcc/none"] - elif event_name == "issue_comment": - return ["gcc/none", "clang/none"] + elif event_name == "schedule": + return ["gcc/perfetto"] else: # Default to a minimal safe configuration for unknown events return ["gcc/none"] @@ -23,10 +29,12 @@ def main(): "gcc/asan", "gcc/tsan", "gcc/valgrind", + "gcc/perfetto", "clang/none", "clang/asan", "clang/tsan", "clang/valgrind", + "clang/perfetto", ] user_input = os.getenv("USER_INPUT", "") comment_body = os.getenv("COMMENT_BODY", "") diff --git a/.github/workflows/cmake-build.yaml b/.github/workflows/cmake-build.yaml index d68ea35ee..370820330 100644 --- a/.github/workflows/cmake-build.yaml +++ b/.github/workflows/cmake-build.yaml @@ -7,6 +7,8 @@ run-name: "${{ github.actor }} building and testing ${{ github.repository }}" types: [created] push: branches: [main, develop] + schedule: + - cron: '7 18 * * 6' workflow_dispatch: inputs: ref: @@ -71,8 +73,12 @@ env: jobs: setup: if: > - github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request' || github.event_name == 'push' || - github.event_name == 'workflow_call' || ( + github.event_name == 'workflow_dispatch' || + github.event_name == 'pull_request' || + github.event_name == 'push' || + github.event_name == 'schedule' || + github.event_name == 'workflow_call' || + ( github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(fromJSON('["OWNER", "COLLABORATOR", "MEMBER"]'), github.event.comment.author_association) && @@ -175,6 +181,7 @@ jobs: extra-options: | ${{ matrix.sanitizer == 'asan' && format('-D{0}_ENABLE_ASAN=ON', steps.repo_name.outputs.name) || '' }} ${{ matrix.sanitizer == 'tsan' && format('-D{0}_ENABLE_TSAN=ON', steps.repo_name.outputs.name) || '' }} + ${{ matrix.sanitizer == 'perfetto' && format('-D{0}_ENABLE_PERFETTO=ON', steps.repo_name.outputs.name) || '' }} - name: Build id: build @@ -183,7 +190,7 @@ jobs: build-path: ${{ needs.setup.outputs.build_path }} - name: Run tests - if: matrix.sanitizer != 'valgrind' + if: matrix.sanitizer != 'valgrind' && matrix.sanitizer != 'perfetto' working-directory: ${{ needs.setup.outputs.build_path }} run: | . /entrypoint.sh @@ -215,6 +222,23 @@ jobs: echo "⚠️ Valgrind tests failed, but the workflow will continue." fi + - name: Run Perfetto profiling + if: matrix.sanitizer == 'perfetto' + run: | + . /entrypoint.sh + cd "$GITHUB_WORKSPACE/${{ env.local_build_path }}" + + echo "➡️ Running tests with Perfetto profiling..." + echo "::group::Running ctest with Perfetto" + if ctest --progress --output-on-failure -j "$(nproc)"; then + echo "::endgroup::" + echo "✅ Perfetto profiling completed." + else + echo "::endgroup::" + echo "::error:: Perfetto profiling failed." + exit 1 + fi + cmake-build-skipped: needs: [setup] if: > diff --git a/.gitignore b/.gitignore index 931fc4922..23bce7796 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ /_deps/ /build-*/ /build/ +/out/ /phlex-build/ /phlex-src/ CMakeFiles/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f0a53b9a..ffcb8f2f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,6 +94,7 @@ include(Modules/private/CreateCoverageTargets.cmake) option(ENABLE_TSAN "Enable Thread Sanitizer" OFF) option(ENABLE_ASAN "Enable Address Sanitizer" OFF) +option(ENABLE_PERFETTO "Enable Perfetto profiling" OFF) option(PHLEX_USE_FORM "Enable experimental integration with FORM" OFF) option(ENABLE_COVERAGE "Enable code coverage instrumentation" OFF) option(ENABLE_BUILD_PROFILING "Enable monitoring of compile and link operations" OFF) @@ -196,6 +197,12 @@ if(ENABLE_ASAN) endif() endif() +# Configure Perfetto profiling if enabled +if(ENABLE_PERFETTO) + message(STATUS "Enabling Perfetto profiling") + find_package(Perfetto REQUIRED) +endif() + # Configure code coverage if enabled if(ENABLE_COVERAGE) # Check if the compiler supports code coverage @@ -222,6 +229,12 @@ endif() add_subdirectory(phlex) add_subdirectory(plugins) +# Link Perfetto to phlex executable if enabled +if(ENABLE_PERFETTO AND TARGET phlex) + target_link_libraries(phlex PRIVATE Perfetto::Perfetto) + target_compile_definitions(phlex PRIVATE PERFETTO_ENABLE_TRACING=1) +endif() + if(PHLEX_USE_FORM) set(BUILD_SHARED_LIBS OFF) # Temporary add_subdirectory(form) diff --git a/Modules/FindPerfetto.cmake b/Modules/FindPerfetto.cmake new file mode 100644 index 000000000..ca472a603 --- /dev/null +++ b/Modules/FindPerfetto.cmake @@ -0,0 +1,29 @@ +# FindPerfetto.cmake +# Finds the Perfetto SDK (single-header implementation) + +include(FindPackageHandleStandardArgs) + +find_path( + Perfetto_INCLUDE_DIR + NAMES perfetto.h + PATHS /opt/perfetto /usr/local/include /usr/include + DOC "Perfetto SDK header location" +) + +find_file( + Perfetto_SOURCE + NAMES perfetto.cc + PATHS /opt/perfetto /usr/local/include /usr/include + DOC "Perfetto SDK implementation file" +) + +find_package_handle_standard_args(Perfetto REQUIRED_VARS Perfetto_INCLUDE_DIR Perfetto_SOURCE) + +if(Perfetto_FOUND AND NOT TARGET Perfetto::Perfetto) + add_library(perfetto_impl STATIC "${Perfetto_SOURCE}") + target_include_directories(perfetto_impl PUBLIC "${Perfetto_INCLUDE_DIR}") + target_compile_definitions(perfetto_impl PUBLIC PERFETTO_ENABLE_TRACING=1) + add_library(Perfetto::Perfetto ALIAS perfetto_impl) +endif() + +mark_as_advanced(Perfetto_INCLUDE_DIR Perfetto_SOURCE) diff --git a/ci/Dockerfile b/ci/Dockerfile index 3b6087e7c..16c9421b1 100644 --- a/ci/Dockerfile +++ b/ci/Dockerfile @@ -280,6 +280,26 @@ set -euo pipefail rm -f /tmp/spack.yaml CLEAN_TEMP_FILES +######################################################################## +# Install Perfetto SDK for profiling + +RUN <<'INSTALL_PERFETTO' +set -euo pipefail + +# Install Perfetto SDK +apt-get update +apt-get install -y --no-install-recommends \ + wget +apt-get clean +rm -rf /var/lib/apt/lists/* + +mkdir -p /opt/perfetto +cd /opt/perfetto +wget -O perfetto.h https://raw.githubusercontent.com/google/perfetto/main/sdk/perfetto.h +wget -O perfetto.cc https://raw.githubusercontent.com/google/perfetto/main/sdk/perfetto.cc +chmod 644 perfetto.h perfetto.cc +INSTALL_PERFETTO + ######################################################################## # Finalize CI image stage From 19c42ace54141178b54e10c71699609b4cb8be41 Mon Sep 17 00:00:00 2001 From: Chris Green Date: Thu, 19 Feb 2026 16:47:33 -0600 Subject: [PATCH 2/4] Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Upload Perfetto trace files as workflow artifacts Add artifact upload step to the Perfetto profiling workflow to capture trace files generated during test execution, enabling offline analysis via the Perfetto UI. Changes: - Add upload-artifact step after Perfetto profiling runs that collects all .pftrace files from the build directory - Name artifacts by compiler (perfetto-traces-gcc, perfetto-traces-clang) to distinguish between different compiler runs - Set 30-day retention period for trace files to allow sufficient time for analysis while managing storage costs - Configure if-no-files-found: warn to alert if profiling did not generate expected trace output Users can download the trace artifacts from the workflow run and analyze them at https://ui.perfetto.dev/ for detailed performance profiling and visualization of the test execution. Add tracebox and advanced profiling support to Perfetto workflow Enable heap profiling, CPU profiling, and system-wide tracing via Perfetto's tracebox tool for comprehensive performance analysis. Changes: - Install tracebox binary in CI Docker image from get.perfetto.dev for system-wide profiling capabilities - Add workflow_dispatch inputs for perfetto-heap-profile and perfetto-cpu-profile to control profiling modes (CPU profiling enabled by default, heap profiling opt-in) - Add SYS_PTRACE capability and disable seccomp in container options to enable perf_event access required for CPU profiling - Configure perf_event_paranoid=-1 at runtime when CPU profiling is enabled to allow non-root access to performance counters - Update Perfetto profiling step to conditionally wrap ctest execution with tracebox when heap or CPU profiling is enabled, passing appropriate flags (--heapprofd for heap, --cpu-freq/--cpu-idle/ --cpu-sched for CPU) - Fall back to SDK-only tracing when no system profiling is requested Users can now enable heap profiling and CPU counter profiling via workflow_dispatch inputs to capture detailed memory allocation patterns and CPU performance metrics alongside application traces. Minor tweaks, and improvements per Copilot review - Restrict artifact upload path to build directory only to avoid collecting unintended files from source tree - Use absolute path for tracebox output file to ensure trace is written to expected location within build directory - Move Perfetto linking to phlex/app/CMakeLists.txt immediately after cet_make_exec() to localize it to the executable creation - Use specific Perfetto SDK version (v51.0) instead of main branch for reproducible container builds Apply YAML formatter fixes --- .github/workflows/cmake-build.yaml | 94 ++++++++++++++++++++++-------- CMakeLists.txt | 6 -- Modules/FindPerfetto.cmake | 2 + ci/Dockerfile | 12 +++- phlex/app/CMakeLists.txt | 4 ++ 5 files changed, 84 insertions(+), 34 deletions(-) diff --git a/.github/workflows/cmake-build.yaml b/.github/workflows/cmake-build.yaml index 370820330..d1772d85c 100644 --- a/.github/workflows/cmake-build.yaml +++ b/.github/workflows/cmake-build.yaml @@ -8,7 +8,7 @@ run-name: "${{ github.actor }} building and testing ${{ github.repository }}" push: branches: [main, develop] schedule: - - cron: '7 18 * * 6' + - cron: "7 18 * * 6" workflow_dispatch: inputs: ref: @@ -26,6 +26,16 @@ run-name: "${{ github.actor }} building and testing ${{ github.repository }}" Default (if empty): Run `gcc/none` required: false default: "" + perfetto-heap-profile: + description: "Enable heap profiling for Perfetto runs" + required: false + type: boolean + default: false + perfetto-cpu-profile: + description: "Enable CPU profiling for Perfetto runs" + required: false + type: boolean + default: true workflow_call: inputs: checkout-path: @@ -73,12 +83,8 @@ env: jobs: setup: if: > - github.event_name == 'workflow_dispatch' || - github.event_name == 'pull_request' || - github.event_name == 'push' || - github.event_name == 'schedule' || - github.event_name == 'workflow_call' || - ( + github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request' || github.event_name == 'push' || + github.event_name == 'schedule' || github.event_name == 'workflow_call' || ( github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(fromJSON('["OWNER", "COLLABORATOR", "MEMBER"]'), github.event.comment.author_association) && @@ -146,6 +152,7 @@ jobs: container: image: ghcr.io/framework-r-d/phlex-ci:latest + options: --cap-add=SYS_PTRACE --security-opt seccomp=unconfined steps: - name: Check out code @@ -181,7 +188,7 @@ jobs: extra-options: | ${{ matrix.sanitizer == 'asan' && format('-D{0}_ENABLE_ASAN=ON', steps.repo_name.outputs.name) || '' }} ${{ matrix.sanitizer == 'tsan' && format('-D{0}_ENABLE_TSAN=ON', steps.repo_name.outputs.name) || '' }} - ${{ matrix.sanitizer == 'perfetto' && format('-D{0}_ENABLE_PERFETTO=ON', steps.repo_name.outputs.name) || '' }} + ${{ matrix.sanitizer == 'perfetto' && format('-D{0}_ENABLE_PERFETTO=ON', steps.repo_name.outputs.name) || '' }} - name: Build id: build @@ -222,29 +229,66 @@ jobs: echo "⚠️ Valgrind tests failed, but the workflow will continue." fi - - name: Run Perfetto profiling - if: matrix.sanitizer == 'perfetto' - run: | - . /entrypoint.sh - cd "$GITHUB_WORKSPACE/${{ env.local_build_path }}" + - name: Run Perfetto profiling + if: matrix.sanitizer == 'perfetto' + working-directory: ${{ needs.setup.outputs.build_path }} + env: + PERFETTO_HEAP_PROFILE: ${{ github.event.inputs.perfetto-heap-profile || 'false' }} + PERFETTO_CPU_PROFILE: ${{ github.event.inputs.perfetto-cpu-profile || 'true' }} + run: | + . /entrypoint.sh + + echo "➡️ Running tests with Perfetto profiling..." + + # Set perf_event_paranoid for CPU profiling + if [ "$PERFETTO_CPU_PROFILE" = "true" ]; then + echo "Configuring perf_event_paranoid for CPU profiling" + echo -1 | tee /proc/sys/kernel/perf_event_paranoid 2>/dev/null || echo "Warning: Could not set perf_event_paranoid" + fi + + # Configure profiling based on environment + TRACEBOX_ARGS="" + if [ "$PERFETTO_HEAP_PROFILE" = "true" ]; then + echo "Enabling heap profiling" + TRACEBOX_ARGS="$TRACEBOX_ARGS --app '*' --heapprofd" + fi + if [ "$PERFETTO_CPU_PROFILE" = "true" ]; then + echo "Enabling CPU profiling" + TRACEBOX_ARGS="$TRACEBOX_ARGS --cpu-freq --cpu-idle --cpu-sched" + fi + + # Run tests with or without tracebox wrapper + if [ -n "$TRACEBOX_ARGS" ]; then + echo "::group::Running ctest with tracebox" + tracebox $TRACEBOX_ARGS -o "perfetto-trace.pftrace" -- ctest --progress --output-on-failure -j "$(nproc)" || TEST_RESULT=$? + else + echo "::group::Running ctest with Perfetto SDK tracing" + ctest --progress --output-on-failure -j "$(nproc)" || TEST_RESULT=$? + fi - echo "➡️ Running tests with Perfetto profiling..." - echo "::group::Running ctest with Perfetto" - if ctest --progress --output-on-failure -j "$(nproc)"; then - echo "::endgroup::" - echo "✅ Perfetto profiling completed." - else echo "::endgroup::" - echo "::error:: Perfetto profiling failed." - exit 1 - fi + if [ "${TEST_RESULT:-0}" -eq 0 ]; then + echo "✅ Perfetto profiling completed." + else + echo "::error:: Perfetto profiling failed." + exit 1 + fi + + - name: Upload Perfetto traces + if: matrix.sanitizer == 'perfetto' + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 + with: + name: perfetto-traces-${{ matrix.compiler }} + path: | + ${{ needs.setup.outputs.build_path }}/**/*.pftrace + retention-days: 30 + if-no-files-found: warn cmake-build-skipped: needs: [setup] if: > - needs.setup.result == 'success' && github.event_name != 'workflow_dispatch' && - !inputs.skip-relevance-check && needs.setup.outputs.is_act != 'true' && - needs.setup.outputs.has_changes != 'true' + needs.setup.result == 'success' && github.event_name != 'workflow_dispatch' && !inputs.skip-relevance-check && + needs.setup.outputs.is_act != 'true' && needs.setup.outputs.has_changes != 'true' runs-on: ubuntu-latest permissions: contents: read diff --git a/CMakeLists.txt b/CMakeLists.txt index ffcb8f2f0..5822f08ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -229,12 +229,6 @@ endif() add_subdirectory(phlex) add_subdirectory(plugins) -# Link Perfetto to phlex executable if enabled -if(ENABLE_PERFETTO AND TARGET phlex) - target_link_libraries(phlex PRIVATE Perfetto::Perfetto) - target_compile_definitions(phlex PRIVATE PERFETTO_ENABLE_TRACING=1) -endif() - if(PHLEX_USE_FORM) set(BUILD_SHARED_LIBS OFF) # Temporary add_subdirectory(form) diff --git a/Modules/FindPerfetto.cmake b/Modules/FindPerfetto.cmake index ca472a603..093f7a2b1 100644 --- a/Modules/FindPerfetto.cmake +++ b/Modules/FindPerfetto.cmake @@ -20,9 +20,11 @@ find_file( find_package_handle_standard_args(Perfetto REQUIRED_VARS Perfetto_INCLUDE_DIR Perfetto_SOURCE) if(Perfetto_FOUND AND NOT TARGET Perfetto::Perfetto) + find_package(Threads REQUIRED) add_library(perfetto_impl STATIC "${Perfetto_SOURCE}") target_include_directories(perfetto_impl PUBLIC "${Perfetto_INCLUDE_DIR}") target_compile_definitions(perfetto_impl PUBLIC PERFETTO_ENABLE_TRACING=1) + target_link_libraries(perfetto_impl PUBLIC Threads::Threads) add_library(Perfetto::Perfetto ALIAS perfetto_impl) endif() diff --git a/ci/Dockerfile b/ci/Dockerfile index 16c9421b1..ba201b5d9 100644 --- a/ci/Dockerfile +++ b/ci/Dockerfile @@ -286,7 +286,7 @@ CLEAN_TEMP_FILES RUN <<'INSTALL_PERFETTO' set -euo pipefail -# Install Perfetto SDK +# Install Perfetto SDK and tools apt-get update apt-get install -y --no-install-recommends \ wget @@ -295,9 +295,15 @@ rm -rf /var/lib/apt/lists/* mkdir -p /opt/perfetto cd /opt/perfetto -wget -O perfetto.h https://raw.githubusercontent.com/google/perfetto/main/sdk/perfetto.h -wget -O perfetto.cc https://raw.githubusercontent.com/google/perfetto/main/sdk/perfetto.cc +PERFETTO_VERSION=v51.0 +wget -O perfetto.h https://raw.githubusercontent.com/google/perfetto/${PERFETTO_VERSION}/sdk/perfetto.h +wget -O perfetto.cc https://raw.githubusercontent.com/google/perfetto/${PERFETTO_VERSION}/sdk/perfetto.cc chmod 644 perfetto.h perfetto.cc + +# Install tracebox for system-wide profiling +wget -O tracebox https://get.perfetto.dev/tracebox +chmod +x tracebox +mv tracebox /usr/local/bin/ INSTALL_PERFETTO ######################################################################## diff --git a/phlex/app/CMakeLists.txt b/phlex/app/CMakeLists.txt index 3c0a57af0..3f1fd76c1 100644 --- a/phlex/app/CMakeLists.txt +++ b/phlex/app/CMakeLists.txt @@ -33,4 +33,8 @@ cet_make_exec( jsonnet::lib ) +if(ENABLE_PERFETTO) + target_link_libraries(phlex PRIVATE Perfetto::Perfetto) +endif() + set_target_properties(phlex PROPERTIES INSTALL_RPATH "$ORIGIN/../lib") From f3018adbbb7717f1863f11f7cca097d46149bcf2 Mon Sep 17 00:00:00 2001 From: Chris Green Date: Fri, 20 Mar 2026 21:16:41 -0500 Subject: [PATCH 3/4] Address Copilot review comments from #341 - Remove --security-opt seccomp=unconfined from container options; SYS_PTRACE alone is sufficient and seccomp=unconfined is a broader security relaxation than required - Fix PERFETTO_CPU_PROFILE fallback default from the string 'true' to the boolean true, consistent with the workflow_dispatch input default - Initialize TEST_RESULT=0 before the conditional tracebox block for clarity, making the intent explicit rather than relying on :- default - Rename FindPerfetto.cmake internal target perfetto_impl to Perfetto_impl to follow the namespaced capitalization convention and reduce risk of collision with user-defined targets - Make ENABLE_PERFETTO a Linux-only option via cmake_dependent_option, since the Perfetto SDK only supports Linux Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/cmake-build.yaml | 5 +++-- CMakeLists.txt | 9 ++++++++- Modules/FindPerfetto.cmake | 10 +++++----- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.github/workflows/cmake-build.yaml b/.github/workflows/cmake-build.yaml index d1772d85c..4acfeb734 100644 --- a/.github/workflows/cmake-build.yaml +++ b/.github/workflows/cmake-build.yaml @@ -152,7 +152,7 @@ jobs: container: image: ghcr.io/framework-r-d/phlex-ci:latest - options: --cap-add=SYS_PTRACE --security-opt seccomp=unconfined + options: --cap-add=SYS_PTRACE steps: - name: Check out code @@ -234,7 +234,7 @@ jobs: working-directory: ${{ needs.setup.outputs.build_path }} env: PERFETTO_HEAP_PROFILE: ${{ github.event.inputs.perfetto-heap-profile || 'false' }} - PERFETTO_CPU_PROFILE: ${{ github.event.inputs.perfetto-cpu-profile || 'true' }} + PERFETTO_CPU_PROFILE: ${{ github.event.inputs.perfetto-cpu-profile || true }} run: | . /entrypoint.sh @@ -258,6 +258,7 @@ jobs: fi # Run tests with or without tracebox wrapper + TEST_RESULT=0 if [ -n "$TRACEBOX_ARGS" ]; then echo "::group::Running ctest with tracebox" tracebox $TRACEBOX_ARGS -o "perfetto-trace.pftrace" -- ctest --progress --output-on-failure -j "$(nproc)" || TEST_RESULT=$? diff --git a/CMakeLists.txt b/CMakeLists.txt index 5822f08ce..998d9a802 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,7 +94,14 @@ include(Modules/private/CreateCoverageTargets.cmake) option(ENABLE_TSAN "Enable Thread Sanitizer" OFF) option(ENABLE_ASAN "Enable Address Sanitizer" OFF) -option(ENABLE_PERFETTO "Enable Perfetto profiling" OFF) +include(CMakeDependentOption) +cmake_dependent_option( + ENABLE_PERFETTO + "Enable Perfetto profiling" + OFF + "CMAKE_SYSTEM_NAME STREQUAL Linux" + OFF +) option(PHLEX_USE_FORM "Enable experimental integration with FORM" OFF) option(ENABLE_COVERAGE "Enable code coverage instrumentation" OFF) option(ENABLE_BUILD_PROFILING "Enable monitoring of compile and link operations" OFF) diff --git a/Modules/FindPerfetto.cmake b/Modules/FindPerfetto.cmake index 093f7a2b1..0b2d4daec 100644 --- a/Modules/FindPerfetto.cmake +++ b/Modules/FindPerfetto.cmake @@ -21,11 +21,11 @@ find_package_handle_standard_args(Perfetto REQUIRED_VARS Perfetto_INCLUDE_DIR Pe if(Perfetto_FOUND AND NOT TARGET Perfetto::Perfetto) find_package(Threads REQUIRED) - add_library(perfetto_impl STATIC "${Perfetto_SOURCE}") - target_include_directories(perfetto_impl PUBLIC "${Perfetto_INCLUDE_DIR}") - target_compile_definitions(perfetto_impl PUBLIC PERFETTO_ENABLE_TRACING=1) - target_link_libraries(perfetto_impl PUBLIC Threads::Threads) - add_library(Perfetto::Perfetto ALIAS perfetto_impl) + add_library(Perfetto_impl STATIC "${Perfetto_SOURCE}") + target_include_directories(Perfetto_impl PUBLIC "${Perfetto_INCLUDE_DIR}") + target_compile_definitions(Perfetto_impl PUBLIC PERFETTO_ENABLE_TRACING=1) + target_link_libraries(Perfetto_impl PUBLIC Threads::Threads) + add_library(Perfetto::Perfetto ALIAS Perfetto_impl) endif() mark_as_advanced(Perfetto_INCLUDE_DIR Perfetto_SOURCE) From 62f6c6c549744a91ccd3ad3d38223d0aa0be0efb Mon Sep 17 00:00:00 2001 From: Chris Green Date: Fri, 20 Mar 2026 21:17:46 -0500 Subject: [PATCH 4/4] Document tracebox supply-chain limitation in Dockerfile The Perfetto project currently offers no versioned or checksum-verifiable standalone tracebox binary download. Add a comment noting this known limitation so it is visible for future remediation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- ci/Dockerfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ci/Dockerfile b/ci/Dockerfile index ba201b5d9..e94e6725f 100644 --- a/ci/Dockerfile +++ b/ci/Dockerfile @@ -300,7 +300,11 @@ wget -O perfetto.h https://raw.githubusercontent.com/google/perfetto/${PERFETTO_ wget -O perfetto.cc https://raw.githubusercontent.com/google/perfetto/${PERFETTO_VERSION}/sdk/perfetto.cc chmod 644 perfetto.h perfetto.cc -# Install tracebox for system-wide profiling +# Install tracebox for system-wide profiling. +# Note: get.perfetto.dev/tracebox serves the latest binary with no versioned +# or checksum-verifiable download currently offered by the Perfetto project. +# Revisit when the project provides versioned tracebox releases with integrity +# metadata. wget -O tracebox https://get.perfetto.dev/tracebox chmod +x tracebox mv tracebox /usr/local/bin/