Skip to content

Enable Building Both libjbpf.a and libjbpf.so with cmake option -DJBPF_STATIC=Both - #124

Open
Dr Lai (doctorlai-msrc) wants to merge 9 commits into
devfrom
zhihua/cmake
Open

Enable Building Both libjbpf.a and libjbpf.so with cmake option -DJBPF_STATIC=Both#124
Dr Lai (doctorlai-msrc) wants to merge 9 commits into
devfrom
zhihua/cmake

Conversation

@doctorlai-msrc

Copy link
Copy Markdown
Collaborator

This PR changes the cmake option JBPF_STATIC to 3 states: On, Off and Both.
When set to Both, both the libjbpf.a and libjbpf.so will be built

Originally, this PR was in #22 it got merged by mistakes and reverted in #120 .
Thus, re-creating the PR.

Dr Lai (doctorlai-msrc) and others added 3 commits July 2, 2025 13:56
…ake option -DJBPF_STATIC=Both""

This reverts commit 955049a.
* Adding a emulator

* Add Python/ctypesgen dependencies for emulator

* Add jbpf_agent_hooks.h and generate py

* Add time helper functions

* Test emulator

* Add missing file

* Add missing fields

* Fix time event initialization

* Refactor

* Remove protobuf, update jbpf_stats_report.o

* Add xran helper functions, and create random stream_id

* Clang-format

* Fix cppcheck issue

* Refactor default values

* Default num_codelet_descriptors to len(codelet_descriptors)

* Enable ASAN in tests, ignore ODR, cleanup

* Clangformat

* Support custom helper functions and refactor

* Fix clang-format

* Move definitions above users include file

* Remove XRAN

* Add Custom init code

* Add yaml_to_json, refactor

* Fix path

* Add debug option to emulator_utils.jbpf_handle_out_bufs

* Match codelet_descriptor in yaml

* Add missing define agent hooks

* Revert

* jbpf_handle_out_bufs should return how many messages that have been processed

* Add some debug output when calling periodic_call and report_stats hook

* Add a test to make sure the report_stats is actually called

* Add comment

* Clang-format -i

* Add debug printf

* Continued work

* Add matching ck_epoch_end

* Clang

* Continued testing

* Add more debugging

* Clang

* Debug

* Debug print

* Add more debugging message

* More debugging

* Add tests for report_stats and periodic_call, add debugging

* Clang-format

* Pipeline integration

* simple_output2.o

* Add missing files

* Refactor & debug

* COntinued work

* Continued work

* Revert and Cleanup

* Revert

* Fix

* Ignore dynamic builds

* Fix

* Fix syntax

* Fix syntax

* Keep static mode only

* Revert

* Emulate time and add a test

* Add test

* Fix clang-format

* Add missing file

* Fix compilation under ubuntu20

* Init draft of adding both options

* Fix

* Pipeline

* Move autogen wrappers

* Fix cppcheck issue

* Build both by default

* Fix JBPF_SHARED_LIB

* Fix build under ubuntu24.04

* Fix segfault at Static

* Add emulator tests to github action, fix RELEASE

* Typo

* First round of addressing comments

* Improve test description comments

* Add some more doc

* Add to ARM pipeline

* Sync dev with main (#105)

* Add helper function for fixed points (#71)

* Add helper function for fixed points

* Addressing the comments

* Revert

* Continued work

* Fix the algorithms and tests

* Minor tweaks

* Cleanup

* Avoid clang optimise the code

* Fix implementations

* Test fixed_to_float and fixed_to_double

* Fix type

* Add 2 more tests

* Cleanup

* Clang format inconsistent fix

* Add more tests in the codelet

* Increase MAX_NUM_HOOKS from 64 to 128 (#90)

* Increase MAX_NUM_HOOKS from 64 to 96

* Increase MAX_NUM_HOOKS to 128

---------

Co-authored-by: Zhihua Lai <92519564+doctorlai-msrc@users.noreply.github.com>
Co-authored-by: matthewbalkwill <93522480+matthewbalkwill@users.noreply.github.com>

* Refactor docker files

* Add to github actions

* Add System Information

* Merge and fix

* Fix comments

* Readme

* More doc

* Update docs

* Move emulator tests to the end

* Add debug messages

* Add more debug

* Update codelet to provide more information

* Comment

* Fix print error

* Revert "Update codelet to provide more information"

This reverts commit 95dc9e4.

* Fix segfault

* Use smart ptr

* Revert "Adding a emulator"

* Revert "Enable Building Both libjbpf.a and libjbpf.so with cmake option -DJBPF_STATIC=Both"

---------

Co-authored-by: Xenofon Foukas <137962+xfoukas@users.noreply.github.com>
Co-authored-by: matthewbalkwill <93522480+matthewbalkwill@users.noreply.github.com>
@doctorlai-msrc
Dr Lai (doctorlai-msrc) marked this pull request as ready for review July 11, 2025 09:09

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the build system to treat JBPF_STATIC as a tri-state CMake setting (ON, OFF, BOTH) so the project can build either a static lib, a shared lib, or both in one build.

Changes:

  • Convert JBPF_STATIC from a boolean option to a 3-value cache string (ON|OFF|BOTH) and thread the normalized value (JBPF_STATIC_OPTION_UPPER) through subdirectories.
  • Refactor core library CMake logic to support producing both libjbpf.a and a shared library in the same configuration.
  • Update Docker build scripts, tests, docs, and CI workflows to exercise/configure the new JBPF_STATIC=2 (“both”) behavior.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
CMakeLists.txt Defines tri-state JBPF_STATIC cache string and updates global JBPF_SHARED_LIB definition behavior.
src/core/CMakeLists.txt Refactors core library creation and adds BOTH mode to build static + shared artifacts.
jbpf_tests/CMakeLists.txt Propagates JBPF_STATIC_OPTION_UPPER to subdirectories for tests.
jbpf_tests/unit_tests/CMakeLists.txt Propagates JBPF_STATIC_OPTION_UPPER within unit test subdir tree.
jbpf_tests/unit_tests/bitmap/CMakeLists.txt Adjusts unit test linking based on ON/OFF/BOTH semantics.
helper_build_files/build_utils.sh Adds JBPF_STATIC=2 / unset handling to emit -DJBPF_STATIC=both.
helper_build_files/test_build_utils.sh Extends flag expectation tests for JBPF_STATIC=2 and new default behavior.
docs/integrate_lib.md Updates integration documentation to describe updated build option semantics.
.github/workflows/docker_build_and_test.yaml Adds new CI cases to run Docker build/test with JBPF_STATIC=2.
.github/workflows/docker-build-and-test-arm.yaml Adds new ARM CI cases to run Docker build/test with JBPF_STATIC=2.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/core/CMakeLists.txt Outdated
Comment thread src/core/CMakeLists.txt
Comment thread src/core/CMakeLists.txt Outdated
Comment thread docs/integrate_lib.md Outdated
Comment thread helper_build_files/build_utils.sh Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants