mirror of
https://github.com/openembedded/meta-openembedded.git
synced 2026-07-16 16:27:27 +00:00
bpftrace,bcc: Migrate recipe from meta-clang to meta-oe
These recipes depend on clang, and clang being on core it is better place for these tools to be in a common layer for now that is meta-oe Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
+54
@@ -0,0 +1,54 @@
|
||||
From 24421ba92c69f1abaadaff01270621917616a2b8 Mon Sep 17 00:00:00 2001
|
||||
From: Changqing Li <changqing.li@windriver.com>
|
||||
Date: Thu, 17 Apr 2025 10:38:50 +0800
|
||||
Subject: [PATCH] Fix build failures due to missing location.hh
|
||||
|
||||
ast/location.h does `#include "location.hh"` and location.hh is
|
||||
generated by the parser so any CMake target whose source includes
|
||||
ast/location.h needs to have a dependency on the `parser` target,
|
||||
otherwise the compilation may fail due to incorrect ordering of build
|
||||
targets. This also applies to targets which include ast/location.h
|
||||
transitively via other headers.
|
||||
|
||||
To avoid such errors, do 2 things:
|
||||
- drop includes of ast/location.h where unused
|
||||
- for CMake targets including ast/location.h, add an explicit dependency
|
||||
on the `parser` target
|
||||
|
||||
Signed-off-by: Viktor Malik <viktor.malik@gmail.com>
|
||||
|
||||
Upstream-Status: Backport [https://github.com/bpftrace/bpftrace/commit/743cb9c88c25fb9737d714f4d4ac853f05bb6481]
|
||||
|
||||
Signed-off-by: Changqing Li <changqing.li@windriver.com>
|
||||
---
|
||||
src/CMakeLists.txt | 1 +
|
||||
src/ast/CMakeLists.txt | 1 +
|
||||
2 files changed, 2 insertions(+)
|
||||
|
||||
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
|
||||
index e04ee429..13a51040 100644
|
||||
--- a/src/CMakeLists.txt
|
||||
+++ b/src/CMakeLists.txt
|
||||
@@ -21,6 +21,7 @@ add_library(compiler_core STATIC
|
||||
struct.cpp
|
||||
types.cpp
|
||||
)
|
||||
+add_dependencies(compiler_core parser)
|
||||
|
||||
add_library(runtime STATIC
|
||||
attached_probe.cpp
|
||||
diff --git a/src/ast/CMakeLists.txt b/src/ast/CMakeLists.txt
|
||||
index 92231f85..7230cf71 100644
|
||||
--- a/src/ast/CMakeLists.txt
|
||||
+++ b/src/ast/CMakeLists.txt
|
||||
@@ -22,6 +22,7 @@ add_library(ast STATIC
|
||||
passes/return_path_analyser.cpp
|
||||
)
|
||||
|
||||
+add_dependencies(ast parser)
|
||||
target_compile_definitions(ast PRIVATE ${BPFTRACE_FLAGS})
|
||||
target_link_libraries(ast PUBLIC ast_defs arch compiler_core parser)
|
||||
|
||||
--
|
||||
2.34.1
|
||||
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
From ce5d908bb1256ede680fbfd521f087060a567dca Mon Sep 17 00:00:00 2001
|
||||
From: Martin Jansa <martin.jansa@gmail.com>
|
||||
Date: Tue, 3 Sep 2024 14:17:51 +0200
|
||||
Subject: [PATCH] CMakeLists.txt: allow to set BISON_FLAGS like -l
|
||||
|
||||
Signed-off-by: Martin Jansa <martin.jansa@gmail.com>
|
||||
|
||||
Upstream-Status: Pending
|
||||
---
|
||||
CMakeLists.txt | 10 +++++++---
|
||||
1 file changed, 7 insertions(+), 3 deletions(-)
|
||||
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -100,16 +100,20 @@ include_directories(SYSTEM ${LIBCEREAL_I
|
||||
|
||||
find_package(BISON REQUIRED)
|
||||
find_package(FLEX REQUIRED)
|
||||
+
|
||||
+# avoid buildpaths in generated #line statements and allow to pass --file-prefix-map=OLD=NEW
|
||||
+set(BISON_FLAGS "${BISON_FLAGS} -l")
|
||||
+set(FLEX_FLAGS "${FLEX_FLAGS} -L")
|
||||
# `parser_class_name` is deprecated and generates warnings in bison >= 3.3.
|
||||
# But `api.parser.class` is not supported in bison < 3.3. So we must inject
|
||||
# the %define based on the bison version here.
|
||||
if(${BISON_VERSION} VERSION_GREATER_EQUAL 3.3)
|
||||
- set(BISON_FLAGS "-Dapi.parser.class={Parser}")
|
||||
+ set(BISON_FLAGS "${BISON_FLAGS} -Dapi.parser.class={Parser}")
|
||||
else()
|
||||
- set(BISON_FLAGS "-Dparser_class_name={Parser}")
|
||||
+ set(BISON_FLAGS "${BISON_FLAGS} -Dparser_class_name={Parser}")
|
||||
endif()
|
||||
bison_target(bison_parser src/parser.yy ${CMAKE_BINARY_DIR}/parser.tab.cc COMPILE_FLAGS ${BISON_FLAGS} VERBOSE)
|
||||
-flex_target(flex_lexer src/lexer.l ${CMAKE_BINARY_DIR}/lex.yy.cc)
|
||||
+flex_target(flex_lexer src/lexer.l ${CMAKE_BINARY_DIR}/lex.yy.cc COMPILE_FLAGS ${FLEX_FLAGS})
|
||||
add_flex_bison_dependency(flex_lexer bison_parser)
|
||||
add_library(parser STATIC ${BISON_bison_parser_OUTPUTS} ${FLEX_flex_lexer_OUTPUTS})
|
||||
target_compile_options(parser PRIVATE "-w")
|
||||
@@ -0,0 +1,51 @@
|
||||
#!/bin/sh
|
||||
|
||||
# The whole test suite may take up to 40 minutes to run, so setting -t 2400
|
||||
# parameter in ptest-runner is necessary to not kill it before completion
|
||||
|
||||
cd tests || exit 1
|
||||
export BPFTRACE_RUNTIME_TEST_EXECUTABLE=/usr/bin/bpftrace
|
||||
export BPFTRACE_AOT_RUNTIME_TEST_EXECUTABLE=/usr/bin/bpftrace-aotrt
|
||||
|
||||
PASS_CNT=0
|
||||
FAIL_CNT=0
|
||||
SKIP_CNT=0
|
||||
FAILED=""
|
||||
|
||||
print_test_result() {
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "PASS: $1"
|
||||
PASS_CNT=$((PASS_CNT + 1))
|
||||
else
|
||||
echo "FAIL: $1"
|
||||
FAIL_CNT=$((FAIL_CNT + 1))
|
||||
FAILED="${FAILED:+$FAILED }$1;"
|
||||
fi
|
||||
}
|
||||
|
||||
IFS=$(printf '\n\t')
|
||||
# Start unit tests
|
||||
for test_name in $(./bpftrace_test --gtest_list_tests | grep -v "^ "); do
|
||||
./bpftrace_test --gtest_filter="${test_name}*" > /dev/null 2>&1
|
||||
print_test_result "unit:$test_name"
|
||||
done
|
||||
|
||||
# Start runtime tests
|
||||
for test_name in $(ls runtime); do
|
||||
# Ignore test cases that hang the suite forever (bpftrace v0.16.0)
|
||||
if [ "$test_name" = "signals" ] || [ "$test_name" = "watchpoint" ]; then
|
||||
echo "SKIP: runtime:$test_name"
|
||||
SKIP_CNT=$((SKIP_CNT + 1))
|
||||
continue
|
||||
fi
|
||||
python3 runtime/engine/main.py --filter="${test_name}.*" > /dev/null 2>&1
|
||||
print_test_result "runtime:$test_name"
|
||||
done
|
||||
unset IFS
|
||||
|
||||
echo "#### bpftrace tests summary ####"
|
||||
echo "# TOTAL: $((PASS_CNT + FAIL_CNT + SKIP_CNT))"
|
||||
echo "# PASS: $PASS_CNT"
|
||||
echo "# FAIL: $FAIL_CNT ($FAILED)"
|
||||
echo "# SKIP: $SKIP_CNT"
|
||||
echo "################################"
|
||||
@@ -0,0 +1,62 @@
|
||||
SUMMARY = "bpftrace"
|
||||
HOMEPAGE = "https://github.com/iovisor/bpftrace"
|
||||
LICENSE = "Apache-2.0"
|
||||
LIC_FILES_CHKSUM = "file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57"
|
||||
|
||||
DEPENDS += "bison-native \
|
||||
flex-native \
|
||||
gzip-native \
|
||||
elfutils \
|
||||
bcc \
|
||||
systemtap \
|
||||
libcereal \
|
||||
libbpf \
|
||||
"
|
||||
DEPENDS += "${@bb.utils.contains('PTEST_ENABLED', '1', 'pahole-native llvm-native', '', d)}"
|
||||
|
||||
RDEPENDS:${PN} += "bash python3 xz"
|
||||
|
||||
PV .= "+git"
|
||||
|
||||
SRC_URI = "git://github.com/iovisor/bpftrace;branch=release/0.23.x;protocol=https \
|
||||
file://run-ptest \
|
||||
file://0002-CMakeLists.txt-allow-to-set-BISON_FLAGS-like-l.patch \
|
||||
file://0001-Fix-build-failures-due-to-missing-location.hh.patch \
|
||||
"
|
||||
SRCREV = "01e806d24c61f996f1809e1e991646311499db4f"
|
||||
|
||||
inherit bash-completion cmake ptest pkgconfig
|
||||
|
||||
PACKAGECONFIG ?= " \
|
||||
${@bb.utils.contains('PTEST_ENABLED', '1', 'tests', '', d)} \
|
||||
${@bb.utils.contains("DISTRO_FEATURES", "systemd", "systemd", "", d)} \
|
||||
"
|
||||
|
||||
PACKAGECONFIG[tests] = "-DBUILD_TESTING=ON,-DBUILD_TESTING=OFF,gtest xxd-native"
|
||||
PACKAGECONFIG[systemd] = "-DENABLE_SYSTEMD=ON,-DENABLE_SYSTEMD=OFF,systemd"
|
||||
|
||||
do_install_ptest() {
|
||||
if [ -e ${B}/tests/bpftrace_test ]; then
|
||||
install -Dm 755 ${B}/tests/bpftrace_test ${D}${PTEST_PATH}/tests/bpftrace_test
|
||||
cp -rf ${B}/tests/runtime ${D}${PTEST_PATH}/tests
|
||||
cp -rf ${B}/tests/test* ${D}${PTEST_PATH}/tests
|
||||
fi
|
||||
}
|
||||
|
||||
EXTRA_OECMAKE = " \
|
||||
-DCMAKE_ENABLE_EXPORTS=1 \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DUSE_SYSTEM_BPF_BCC=ON \
|
||||
-DENABLE_MAN=OFF \
|
||||
-DBISON_FLAGS='--file-prefix-map=${WORKDIR}=' \
|
||||
"
|
||||
|
||||
COMPATIBLE_HOST = "(x86_64.*|aarch64.*|powerpc64.*|riscv64.*)-linux"
|
||||
COMPATIBLE_HOST:libc-musl = "null"
|
||||
|
||||
INHIBIT_PACKAGE_STRIP_FILES += "\
|
||||
${PKGD}${PTEST_PATH}/tests/testprogs/uprobe_test \
|
||||
"
|
||||
|
||||
WARN_QA:append = "${@bb.utils.contains('PTEST_ENABLED', '1', ' buildpaths', '', d)}"
|
||||
ERROR_QA:remove = "${@bb.utils.contains('PTEST_ENABLED', '1', 'buildpaths', '', d)}"
|
||||
Reference in New Issue
Block a user