-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
129 additions
and
56 deletions.
There are no files selected for viewing
113 changes: 85 additions & 28 deletions
113
bpftrace/0001-Do-not-require-libbpf-for-static-build.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,108 @@ | ||
From a2cffdecd0ae3952f36917710307ed60bd1acbad Mon Sep 17 00:00:00 2001 | ||
From bbef8fe662571abed5d538e6ba819d345de10978 Mon Sep 17 00:00:00 2001 | ||
From: bas smit <[email protected]> | ||
Date: Thu, 25 Jun 2020 17:22:54 +0200 | ||
Date: Sat, 1 May 2021 13:04:44 +0200 | ||
Subject: [PATCH] Do not require libbpf for static build | ||
|
||
--- | ||
CMakeLists.txt | 2 +- | ||
src/CMakeLists.txt | 1 - | ||
tests/CMakeLists.txt | 1 - | ||
3 files changed, 1 insertion(+), 3 deletions(-) | ||
CMakeLists.txt | 2 +- | ||
cmake/FindLibBcc.cmake | 56 +++++++++++++++++++++--------------------- | ||
src/CMakeLists.txt | 1 - | ||
3 files changed, 29 insertions(+), 30 deletions(-) | ||
|
||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index 4c739585..af7493ff 100644 | ||
index a2f7c6b..64704e6 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -103,7 +103,7 @@ if(POLICY CMP0075) | ||
@@ -111,7 +111,7 @@ if(POLICY CMP0075) | ||
cmake_policy(SET CMP0075 NEW) | ||
endif() | ||
if(STATIC_LINKING) | ||
- set(CMAKE_REQUIRED_LIBRARIES bcc bcc_bpf bpf elf z) | ||
+ set(CMAKE_REQUIRED_LIBRARIES bcc bcc_bpf elf z) | ||
else() | ||
set(CMAKE_REQUIRED_LIBRARIES bcc) | ||
endif(STATIC_LINKING) | ||
set(CMAKE_REQUIRED_LIBRARIES ${LIBBCC_LIBRARIES}) | ||
if (LIBBPF_FOUND) | ||
diff --git a/cmake/FindLibBcc.cmake b/cmake/FindLibBcc.cmake | ||
index 61d1f5e..79326c5 100644 | ||
--- a/cmake/FindLibBcc.cmake | ||
+++ b/cmake/FindLibBcc.cmake | ||
@@ -78,36 +78,36 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibBcc "Please install the bcc library package | ||
|
||
# Check bpf_attach_kprobe signature | ||
if(${LIBBCC_FOUND}) | ||
-if(STATIC_LINKING) | ||
- # libbcc.a is not statically linked with libbpf.a, libelf.a, and libz.a. | ||
- # If we do a static bpftrace build, we must link them in. | ||
- find_package(LibBpf) | ||
- find_package(LibElf) | ||
- find_package(LibZ) | ||
- SET(CMAKE_REQUIRED_LIBRARIES ${LIBBCC_BPF_LIBRARY_STATIC} ${LIBBPF_LIBRARIES} ${LIBELF_LIBRARIES} ${LIBZ_LIBRARIES}) | ||
-else() | ||
- SET(CMAKE_REQUIRED_LIBRARIES ${LIBBCC_LIBRARIES} ${LIBBPF_LIBRARIES}) | ||
-endif() | ||
+ if(STATIC_LINKING) | ||
+ # libbcc.a is not statically linked with libbpf.a, libelf.a, and libz.a. | ||
+ # If we do a static bpftrace build, we must link them in. | ||
+ find_package(LibBpf) | ||
+ find_package(LibElf) | ||
+ find_package(LibZ) | ||
+ SET(CMAKE_REQUIRED_LIBRARIES ${LIBBCC_BPF_LIBRARY_STATIC} ${LIBELF_LIBRARIES} ${LIBZ_LIBRARIES}) | ||
+ else() | ||
+ SET(CMAKE_REQUIRED_LIBRARIES ${LIBBCC_LIBRARIES} ) | ||
+ endif() | ||
|
||
-INCLUDE(CheckCXXSourceCompiles) | ||
-SET(CMAKE_REQUIRED_INCLUDES ${LIBBCC_INCLUDE_DIRS}) | ||
-CHECK_CXX_SOURCE_COMPILES(" | ||
-#include <bcc/libbpf.h> | ||
+ INCLUDE(CheckCXXSourceCompiles) | ||
+ SET(CMAKE_REQUIRED_INCLUDES ${LIBBCC_INCLUDE_DIRS}) | ||
+ CHECK_CXX_SOURCE_COMPILES(" | ||
+ #include <bcc/libbpf.h> | ||
|
||
-int main(void) { | ||
- bpf_attach_kprobe(0, BPF_PROBE_ENTRY, \"\", \"\", 0, 0); | ||
- return 0; | ||
-} | ||
-" LIBBCC_ATTACH_KPROBE_SIX_ARGS_SIGNATURE) | ||
+ int main(void) { | ||
+ bpf_attach_kprobe(0, BPF_PROBE_ENTRY, \"\", \"\", 0, 0); | ||
+ return 0; | ||
+ } | ||
+ " LIBBCC_ATTACH_KPROBE_SIX_ARGS_SIGNATURE) | ||
|
||
-CHECK_CXX_SOURCE_COMPILES(" | ||
-#include <bcc/libbpf.h> | ||
+ CHECK_CXX_SOURCE_COMPILES(" | ||
+ #include <bcc/libbpf.h> | ||
|
||
-int main(void) { | ||
- bpf_attach_uprobe(0, BPF_PROBE_ENTRY, \"\", \"\", 0, 0, 0); | ||
- return 0; | ||
-} | ||
-" LIBBCC_ATTACH_UPROBE_SEVEN_ARGS_SIGNATURE) | ||
-SET(CMAKE_REQUIRED_LIBRARIES) | ||
-SET(CMAKE_REQUIRED_INCLUDES) | ||
+ int main(void) { | ||
+ bpf_attach_uprobe(0, BPF_PROBE_ENTRY, \"\", \"\", 0, 0, 0); | ||
+ return 0; | ||
+ } | ||
+ " LIBBCC_ATTACH_UPROBE_SEVEN_ARGS_SIGNATURE) | ||
+ SET(CMAKE_REQUIRED_LIBRARIES) | ||
+ SET(CMAKE_REQUIRED_INCLUDES) | ||
endif() | ||
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt | ||
index 487fa9bc..d82054ae 100644 | ||
index f491a54..38dcdb8 100644 | ||
--- a/src/CMakeLists.txt | ||
+++ b/src/CMakeLists.txt | ||
@@ -90,7 +90,6 @@ target_link_libraries(bpftrace ${LIBBCC_LIBRARIES}) | ||
@@ -150,7 +150,6 @@ target_link_libraries(libbpftrace ${LIBBCC_LIBRARIES}) | ||
if(STATIC_LINKING) | ||
# These are not part of the static libbcc so have to be added separate | ||
target_link_libraries(bpftrace ${LIBBCC_BPF_LIBRARY_STATIC}) | ||
- target_link_libraries(bpftrace ${LIBBPF_LIBRARIES}) | ||
target_link_libraries(bpftrace ${LIBBCC_LOADER_LIBRARY_STATIC}) | ||
|
||
add_library(LIBELF STATIC IMPORTED) | ||
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt | ||
index d660fe73..4f73c1d7 100644 | ||
--- a/tests/CMakeLists.txt | ||
+++ b/tests/CMakeLists.txt | ||
@@ -111,7 +111,6 @@ if (STATIC_LINKING) | ||
|
||
# These are not part of the static libbcc so have to be added separate | ||
target_link_libraries(bpftrace_test ${LIBBCC_BPF_LIBRARY_STATIC}) | ||
- target_link_libraries(bpftrace_test ${LIBBPF_LIBRARIES}) | ||
target_link_libraries(bpftrace_test ${LIBBCC_LOADER_LIBRARY_STATIC}) | ||
target_link_libraries(libbpftrace ${LIBBCC_BPF_LIBRARY_STATIC}) | ||
- target_link_libraries(libbpftrace ${LIBBPF_LIBRARIES}) | ||
target_link_libraries(libbpftrace ${LIBBCC_LOADER_LIBRARY_STATIC}) | ||
|
||
add_library(LIBELF STATIC IMPORTED) | ||
-- | ||
2.25.0 | ||
2.24.3 (Apple Git-128) | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
From 533790bcba6fc235ad55bfda0ff049b9a66f08fd Mon Sep 17 00:00:00 2001 | ||
From: bas smit <[email protected]> | ||
Date: Sat, 1 May 2021 13:33:00 +0200 | ||
Subject: [PATCH] Relink against libz | ||
|
||
The ordering is messed, can't find libz for libcc. This fixes it in a | ||
hacky way. | ||
--- | ||
src/CMakeLists.txt | 3 +++ | ||
tests/CMakeLists.txt | 1 + | ||
2 files changed, 4 insertions(+) | ||
|
||
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt | ||
index 38dcdb8..cb3e755 100644 | ||
--- a/src/CMakeLists.txt | ||
+++ b/src/CMakeLists.txt | ||
@@ -169,6 +169,9 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR ${CMAKE_CXX_COMPILER_VERSION} | ||
target_link_libraries(libbpftrace "stdc++fs") | ||
endif() | ||
|
||
+ | ||
+target_link_libraries(libbpftrace ${LIBZ_LIBRARIES}) | ||
+ | ||
if (BUILD_ASAN) | ||
if(${CMAKE_VERSION} VERSION_LESS "3.13.0") | ||
# target_link_options is supported in CMake 3.13 and newer | ||
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt | ||
index 8d546f9..dc14cf3 100644 | ||
--- a/tests/CMakeLists.txt | ||
+++ b/tests/CMakeLists.txt | ||
@@ -198,3 +198,4 @@ if(ENABLE_TEST_VALIDATE_CODEGEN) | ||
else() | ||
message(STATUS "codegen-validator test disabled") | ||
endif() | ||
+target_link_libraries(bpftrace_test ${LIBZ_LIBRARIES}) | ||
-- | ||
2.24.3 (Apple Git-128) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters