Skip to content

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

Merged
Zhihua Lai (doctorlai-msrc) merged 25 commits into
devfrom
zhihua/cmake
Jul 2, 2025
Merged

Zhihua Lai (doctorlai-msrc) merged 25 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

@doctorlai-msrc
Zhihua Lai (doctorlai-msrc) marked this pull request as ready for review December 9, 2024 14:23
@xfoukas

Copy link
Copy Markdown
Collaborator

Zhihua Lai (@doctorlai-msrc) Can you please explain why we cannot build both the static and the dynamic library by default? Why

@doctorlai-msrc

Copy link
Copy Markdown
Collaborator Author

Zhihua Lai (@doctorlai-msrc) Can you please explain why we cannot build both the static and the dynamic library by default? Why

We can, however, building both would double the time.

@xfoukas

Copy link
Copy Markdown
Collaborator

Why would it double the time? Have you profiled this? Could you share some numbers?

@doctorlai-msrc

Copy link
Copy Markdown
Collaborator Author

Why would it double the time? Have you profiled this? Could you share some numbers?

Because building both will have two add_library. I did a few quick tests, however between tests, the time statistics do vary.

rm -rf * && rm -rf ../out/ && cmake ../ -DJBPF_STATIC=On
time bash -c " make -j"
real 1m16.577s
user 6m53.224s
sys 0m58.393s

rm -rf * && rm -rf ../out/ && cmake ../ -DJBPF_STATIC=Off
time bash -c " make -j"
real 1m46.668s
user 9m29.203s
sys 1m28.137s

rm -rf * && rm -rf ../out/ && cmake ../ -DJBPF_STATIC=Both
time bash -c " make -j"
real 1m58.854s
user 10m11.512s
sys 1m45.767s

@xfoukas

Copy link
Copy Markdown
Collaborator

The default (JBPF_STATIC=off) and the case when building both take similar time according to this profiling, so in my view we should build both by default, as it simplifies the build process.

Comment thread CMakeLists.txt Resolved
@doctorlai-msrc
Zhihua Lai (doctorlai-msrc) changed the base branch from main to dev April 16, 2025 09:08
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