Skip to content

Commit

Permalink
fix: build dependency issue (#7)
Browse files Browse the repository at this point in the history
* update

* update

* update

* update

* update

* update

* update
  • Loading branch information
Officeyutong authored Aug 26, 2024
1 parent d89cab3 commit 374c2fd
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bpf_conformance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
with:
path: ${{ github.workspace }}/${{ env.INSTALL_LOCATION }}
key: ${{ runner.os }}-dependencies

- uses: actions/checkout@v2
with:
submodules: 'recursive'
Expand Down
13 changes: 12 additions & 1 deletion .github/workflows/test-aot-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,21 @@ jobs:
- uses: actions/checkout@v2
with:
submodules: 'recursive'

- name: Install Ninja (Ubuntu)
if: ${{matrix.container == 'ubuntu-2204'}}
run:
apt install ninja-build

- name: Install Ninja (Fedora)
if: ${{matrix.container == 'fedora-39'}}
run:
dnf install -y ninja-build


- name: Build and install everything
run: |
cmake -B build -DCMAKE_BUILD_TYPE=Debug -DBPFTIME_ENABLE_UNIT_TESTING=1 -DBUILD_LLVM_AOT_CLI=1
cmake -B build -DCMAKE_BUILD_TYPE=Debug -DBPFTIME_ENABLE_UNIT_TESTING=1 -DBUILD_LLVM_AOT_CLI=1 -G Ninja
cmake --build build --target all -j
- name: Do compilation & run
run: |
Expand Down
15 changes: 13 additions & 2 deletions .github/workflows/test-vm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ jobs:
with:
submodules: 'recursive'

- name: Install Ninja (Ubuntu)
if: ${{matrix.container == 'ubuntu-2204'}}
run:
apt install ninja-build

- name: Install Ninja (Fedora)
if: ${{matrix.container == 'fedora-39'}}
run:
dnf install -y ninja-build


- uses: actions/setup-python@v4
if: startsWith(matrix.container,'ubuntu')
with:
Expand All @@ -40,7 +51,7 @@ jobs:
- name: build
run:
|
cmake -B build -DCMAKE_BUILD_TYPE=Debug -DBPFTIME_ENABLE_UNIT_TESTING=1
cmake -B build -DCMAKE_BUILD_TYPE=Debug -DBPFTIME_ENABLE_UNIT_TESTING=1 -G Ninja
cmake --build build --target all -j

- name: run testsuit x86
Expand All @@ -50,4 +61,4 @@ jobs:
source test/bin/activate
pip install -r test/requirements.txt
# make build # or build-arm32 build-arm64
pytest -v -s test/test_framework
pytest -v -s test/test_framework
15 changes: 13 additions & 2 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,21 @@ jobs:
with:
submodules: 'recursive'

- name: Install Ninja (Ubuntu)
if: ${{matrix.container == 'ubuntu-2204'}}
run:
apt install ninja-build

- name: Install Ninja (Fedora)
if: ${{matrix.container == 'fedora-39'}}
run:
dnf install -y ninja-build


- name: build
run:
|
cmake -B build -DCMAKE_BUILD_TYPE=Debug -DBPFTIME_ENABLE_UNIT_TESTING=1
cmake -B build -DCMAKE_BUILD_TYPE=Debug -DBPFTIME_ENABLE_UNIT_TESTING=1 -G Ninja
cmake --build build --target all -j

- name: Run example
Expand All @@ -40,6 +51,6 @@ jobs:
- name: build llvm JIT/AOT release as a standalone library
run: |
cmake -B build -DCMAKE_BUILD_TYPE=Release &&\
cmake -B build -DCMAKE_BUILD_TYPE=Release -G Ninja &&\
cmake --build build --target all -j
41 changes: 22 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.16)

cmake_policy(SET CMP0079 NEW)
project(
"llvm-bpf-jit"
LANGUAGES C CXX
Expand Down Expand Up @@ -39,7 +39,7 @@ set_target_properties(llvmbpf_vm PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CU

find_package(LLVM REQUIRED CONFIG)

if (${LLVM_PACKAGE_VERSION} VERSION_LESS 15)
if(${LLVM_PACKAGE_VERSION} VERSION_LESS 15)
message(FATAL_ERROR "LLVM version must be >=15")
endif()

Expand All @@ -62,13 +62,15 @@ include(FetchContent)

if(NOT DEFINED SPDLOG_INCLUDE)
message(INFO " Adding spdlog seperately..")

# spdlog
# Fetch spdlog
FetchContent_Declare(
spdlog
GIT_REPOSITORY https://github.com/gabime/spdlog.git
GIT_TAG v1.14.1 # Specify the version you want to use
spdlog
GIT_REPOSITORY https://github.com/gabime/spdlog.git
GIT_TAG v1.14.1 # Specify the version you want to use
)

# Make the spdlog target available
FetchContent_MakeAvailable(spdlog)
endif()
Expand All @@ -82,30 +84,31 @@ else()
if(${BUILD_LLVM_AOT_CLI})
add_subdirectory(cli)
endif()
if(${BPFTIME_ENABLE_UNIT_TESTING})
message(INFO " Adding Catch2 seperately..")
FetchContent_Declare(
catch
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.4.0 # Specify the version you want to use
)

# Make the Catch2 target available
FetchContent_MakeAvailable(catch)

if(${BPFTIME_ENABLE_UNIT_TESTING} AND NOT DEFINED Catch2_INCLUDE)
message(STATUS "Adding Catch2 seperately..")
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.4.0 # Specify the version you want to use
)

# Make the Catch2 target available
FetchContent_MakeAvailable(Catch2)
endif()
endif()

message(STATUS "LLVM_LIBS=${LLVM_LIBS}")

target_link_libraries(llvmbpf_vm PUBLIC ${LLVM_LIBS} PRIVATE spdlog::spdlog)
target_include_directories(llvmbpf_vm
PUBLIC ${LLVM_INCLUDE_DIRS} ${SPDLOG_INCLUDE} ${Boost_INCLUDE} ../include include #LLVM jit also used these headers
target_include_directories(llvmbpf_vm
PUBLIC ${LLVM_INCLUDE_DIRS} ${SPDLOG_INCLUDE} ${Boost_INCLUDE} ../include include # LLVM jit also used these headers
)
add_dependencies(llvmbpf_vm spdlog::spdlog)

if(BPFTIME_ENABLE_UNIT_TESTING)
message(STATUS "Build unit tests for the project. Tests should always be found in the test folder\n")
add_subdirectory(test)
message(STATUS "Build unit tests for the project. Tests should always be found in the test folder\n")
add_subdirectory(test)
endif()

add_subdirectory(example)
15 changes: 7 additions & 8 deletions cli/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,28 @@ target_include_directories(bpftime-vm-cli
${LIBBPF_INCLUDE_DIRS}
)

set(LIBBPF_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libbpf_project)

include(ExternalProject)
ExternalProject_Add(
libbpf_project
PREFIX ${CMAKE_BINARY_DIR}/libbpf
GIT_REPOSITORY https://github.com/libbpf/libbpf.git
GIT_TAG v1.2.0 # Replace with the version you need
CONFIGURE_COMMAND ""
BUILD_COMMAND make -C src -j
BUILD_IN_SOURCE TRUE
INSTALL_COMMAND ""
BUILD_BYPRODUCTS ${CMAKE_BINARY_DIR}/libbpf/src/libbpf.a
BUILD_BYPRODUCTS ${LIBBPF_SOURCE_DIR}/src/libbpf.a
SOURCE_DIR ${LIBBPF_SOURCE_DIR}
)

ExternalProject_Get_Property(libbpf_project source_dir)
set(LIBBPF_INCLUDE_DIRS ${source_dir}/src)
set(LIBBPF_LIBRARIES ${source_dir}/src/libbpf.a)

set(LIBBPF_INCLUDE_DIRS ${LIBBPF_SOURCE_DIR}/src)
set(LIBBPF_LIBRARIES ${LIBBPF_SOURCE_DIR}/src/libbpf.a)
# Ensure libbpf is built before your target
add_dependencies(bpftime-vm-cli libbpf_project)

include_directories(${LIBBPF_INCLUDE_DIRS})

add_dependencies(bpftime-vm-cli spdlog::spdlog llvmbpf_vm)
add_dependencies(bpftime-vm-cli spdlog::spdlog llvmbpf_vm libbpf_project)
target_link_libraries(bpftime-vm-cli
PRIVATE spdlog::spdlog llvmbpf_vm
${LIBBPF_LIBRARIES}
Expand Down
5 changes: 2 additions & 3 deletions test/unit-test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@

if(${ENABLE_EBPF_VERIFIER})
# Have to fetch Catch2
if(${BPFTIME_ENABLE_UNIT_TESTING} AND NOT DEFINED Catch2_INCLUDE)
Include(FetchContent)
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.4.0
)
FetchContent_MakeAvailable(Catch2)
# if not enable verifier, we will use the catch2 from submodule
endif()

set(TEST_SOURCES
Expand Down

0 comments on commit 374c2fd

Please sign in to comment.