下载源码:
git clone https://kernel.googlesource.com/pub/scm/devel/pahole/pahole
下载libbpf源码:
git clone https://github.com/libbpf/libbpf
屏蔽pahole下CMakeLists.txt相关代码
+++ b/CMakeLists.txt @@ -35,26 +35,6 @@ find_package(DWARF REQUIRED) find_package(ZLIB REQUIRED) # make sure git submodule(s) are checked out -find_package(Git QUIET) -if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") - # Update submodules as needed - option(GIT_SUBMODULE "Check submodules during build" ON) - if(GIT_SUBMODULE) - message(STATUS "Submodule update") - execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - RESULT_VARIABLE GIT_SUBMOD_RESULT) - if(NOT GIT_SUBMOD_RESULT EQUAL "0") - message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMOD_RESULT}, please checkout submodules") - else() - message(STATUS "Submodule update - done") - endif() - endif() -endif() -if(NOT EXISTS "${PROJECT_SOURCE_DIR}/lib/bpf/src/btf.h") - message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.") -endif() -
创建mkdir lib/bpf目录,将libbpf源码拷贝到该目录下
编译:
mkdir build cd build cmake -D__LIB=lib .. make make install