From 64956ba3ffd76873241b03bc352dd916be198da0 Mon Sep 17 00:00:00 2001 From: Gordon Tisher Date: Sun, 24 Sep 2023 10:00:10 -0700 Subject: [PATCH] Generate and link dtrace probes for libponyrt Dtrace functionality was missed when converting the build system to cmake. This PR generates and links dtrace probes into `libponyrt` if the `use=dtrace` option. Fixes #4449 --- .github/workflows/pr.yml | 40 ++++++++++++++++++++++++++++++++++++ src/libponyrt/CMakeLists.txt | 8 ++++++++ 2 files changed, 48 insertions(+) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index c2bb4eb883..8374e9cc86 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -400,3 +400,43 @@ jobs: .\make.ps1 -Command build -Config Release - name: Test with Release Runtime run: .\make.ps1 -Command test -Config Release -Uselldb yes + + use_dtrace_directive: + needs: x86_64-linux + runs-on: ubuntu-latest + + name: dtrace + container: + image: ${{ matrix.image }} + options: --user pony --cap-add=SYS_PTRACE --security-opt seccomp=unconfined + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Restore Libs Cache + id: restore-libs + uses: actions/cache/restore@v3 + with: + path: build/libs + key: libs-ghcr.io/ponylang/ponyc-ci-x86-64-unknown-linux-ubuntu22.04-builder:20230830-${{ hashFiles('Makefile', 'CMakeLists.txt', 'libs/CMakeLists.txt') }} + - name: Build Libs + if: steps.restore-libs.outputs.cache-hit != 'true' + run: make libs build_flags=-j8 + - name: Save Libs Cache + if: steps.restore-libs.outputs.cache-hit != 'true' + uses: actions/cache/save@v3 + with: + path: build/libs + key: libs-ghcr.io/ponylang/ponyc-ci-x86-64-unknown-linux-ubuntu22.04-builder:20230830-${{ hashFiles('Makefile', 'CMakeLists.txt', 'libs/CMakeLists.txt') }} + - name: Build Debug Runtime + run: | + make configure arch=x86-64 config=debug use=dtrace + make build config=debug + - name: Test with Debug Runtime + run: make test-ci config=debug usedebugger='lldb' + - name: Build Release Runtime + run: | + make configure arch=x86-64 config=release use=dtrace + + make build config=release + - name: Test with Release Runtime + run: make test-ci config=release usedebugger='lldb' diff --git a/src/libponyrt/CMakeLists.txt b/src/libponyrt/CMakeLists.txt index 4416f93d5a..d9b6fb9b81 100644 --- a/src/libponyrt/CMakeLists.txt +++ b/src/libponyrt/CMakeLists.txt @@ -64,6 +64,14 @@ add_library(libponyrt STATIC ${_ll_except_obj} ) +if(PONY_USE_DTRACE) + add_custom_command(OUTPUT dtrace_probes.o + COMMAND dtrace -h -s "${CMAKE_CURRENT_SOURCE_DIR}/../common/dtrace_probes.d" -o "${CMAKE_CURRENT_SOURCE_DIR}/../common/dtrace_probes.h" + COMMAND dtrace -G -s "${CMAKE_CURRENT_SOURCE_DIR}/../common/dtrace_probes.d" -o dtrace_probes.o + ) + target_sources(libponyrt PRIVATE dtrace_probes.o) +endif() + if (NOT MSVC) if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86-64") target_compile_options(libponyrt PUBLIC -mcx16)