Skip to content

Commit 3851346

Browse files
mszabo-wikiameta-codesync[bot]
authored andcommitted
Add required scaffolding for libbpf (#9697)
Summary: Add a find module for libbpf and link libbpf to HHVM artifacts. Pull Request resolved: #9697 Reviewed By: Wilfred Differential Revision: D89470847 fbshipit-source-id: dc779d8f0ec5b521b0151ccee3971d88db66af37
1 parent 75fd403 commit 3851346

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

CMake/FindBpf.cmake

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
find_path(BPF_INCLUDE_DIR bpf/bpf.h)
2+
find_library(BPF_LIBRARY NAMES bpf)
3+
4+
include(FindPackageHandleStandardArgs)
5+
find_package_handle_standard_args(BPF DEFAULT_MSG BPF_LIBRARY BPF_INCLUDE_DIR)
6+
7+
if(BPF_FOUND)
8+
set(BPF_LIBRARIES ${BPF_LIBRARY})
9+
set(BPF_INCLUDE_DIRS ${BPF_INCLUDE_DIR})
10+
else()
11+
set(BPF_LIBRARIES)
12+
set(BPF_INCLUDE_DIRS)
13+
endif()
14+
15+
mark_as_advanced(BPF_LIBRARIES BPF_INCLUDE_DIRS)

CMake/HPHPFindLibs.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,10 @@ if (APPLE)
271271
find_library(KERBEROS_LIB NAMES gssapi_krb5)
272272
endif()
273273

274+
if (LINUX)
275+
find_package(Bpf REQUIRED)
276+
endif()
277+
274278
# This is required by Homebrew's libc. See
275279
# https://github.com/facebook/hhvm/pull/5728#issuecomment-124290712
276280
# for more info.
@@ -332,6 +336,10 @@ macro(hphp_link target)
332336
target_link_libraries(${target} ${VISIBILITY} ${CURL_LIBRARIES})
333337
target_link_libraries(${target} ${VISIBILITY} glog)
334338

339+
if (LINUX)
340+
target_link_libraries(${target} ${VISIBILITY} ${BPF_LIBRARIES})
341+
endif()
342+
335343
if (LIBINOTIFY_LIBRARY)
336344
target_link_libraries(${target} ${VISIBILITY} ${LIBINOTIFY_LIBRARY})
337345
endif()

0 commit comments

Comments
 (0)