-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(cmake): improve shared libs and pkg config files #1842
base: master
Are you sure you want to change the base?
fix(cmake): improve shared libs and pkg config files #1842
Conversation
Welcome @Apteryks! It looks like this is your first PR to falcosecurity/libs 🎉 |
192681c
to
816a718
Compare
I've now successfully built sysdig against a shared library falcosecurity-libs distinct package with this series, on GNU Guix. |
Hi! Thanks for this PR! cc @federico-sysdig @geraldcombs EDIT: i will edit the PR title and body to follow our template (as per our commit convention: https://github.com/falcosecurity/.github/blob/main/CONTRIBUTING.md#commit-convention) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's an interesting PR and there's excellent work on the corrections for the generated pkgconfig files.
I do believe that something else is desirable for the management of the dependent libraries other than the proposed generator expressions.
I'm curious; I have tried to implement the ability to integrate falcosecurity/libs
in a client project through find_package
, which is a better, more CMake-oriented, way to use a library. This is not to say that pkgconfig should be left behind, just another option. What are your thoughts on that?
I'll get to these in a bit.
My immediate thought on this is that a |
Of course, I wasn't suggesting to change the scope of this PR. |
The "build-shared-libs-macos-amd64" job is failing because CFlags in libscap.pc no longer includes
|
816a718
to
5b0dea2
Compare
The Cflags of the libscap.pc file shouldn't have changed; I've only added two new entries to them. For example, on my machine, the old copy (master) looks like:
With this change it now reads:
Probably this header was found via libsinsp.pc, which was capturing a lot of build-specific, non-installed directories, which I think shouldn't be baked in the generated .pc file. Previously, it looked like:
Now, it looks like:
|
Any updates on this? Since 0.20 is too close, moving this to |
Sorry for the long wait, I'll take a look at it now. |
No problem :) |
f74a20d
to
c96e0f7
Compare
Lot's have changed (for the better it seems); there's less in this PR following a rebase. I've been conservative in my edits in the hope that even the most exotic platforms shouldn't be impacted in the CI; let's see. |
This is to so that includes work whether using e.g. #include <scap.h> or #include <libscap/scap.h>, and likewise for libsinp. * userspace/libsinsp/libsinsp.pc.in (Cflags): Add include directive for falcosecurity/driver. * userspace/libscap/libscap.pc.in: Likewise. Also add include directive for uthash. Signed-off-by: Maxim Cournoyer <[email protected]>
c96e0f7
to
ddb89c9
Compare
Actually, the pkg-config files |
ddb89c9
to
d07beb8
Compare
The latest revision resolves that. It's a bit hacky in the I'm sharing the content of the freshly built pkg-config files, for a build configured with the flags:
|
d07beb8
to
39137a6
Compare
* userspace/libpman/libpman.pc.in: New file. * userspace/libpman/CMakeLists.txt: Configure and install it along the libpman header. Signed-off-by: Maxim Cournoyer <[email protected]>
39137a6
to
209ebb6
Compare
I think that's ready to be reviewed again. |
Only the sinsp example with pkg-config test appears to fail when building as a shared library on Linux and MacOS. I'll look into it; perhaps the install directory needs to be added to |
These tests pass locally, on my Guix System. I needed to use |
52a064f
to
7f2f802
Compare
Phew. I think my last push hopefully addresses the remaining test failures. I've made the Requires and Requires.private for libscap conditionally computed like for libsinsp, and dropped what seemed like an extraneous protobuf link dependency I had added to the scap unit test. |
7f2f802
to
7a5dde2
Compare
The generated pkg-config files of libscap and libsinsp now makes use of pkg-config Requires and Requires.static fields, which should reduce over-linking when linking to shared libraries. * cmake/modules/BuildPkgConfigDependencies.cmake (add_pkgconfig_library): Add debug messages and fix an issue where IN_LIST had no effect. * cmake/modules/libscap.cmake: Move pkgconfig dependency computation to, pkg-config file configuration to... * userspace/libscap/CMakeLists.txt: ... here, conditionally accumulating Requires and Requires.private values. * userspace/libscap/libscap.pc.in (prefix): Set directly to CMAKE_INSTALL_PREFIX. (Requires, Requires.private): New fields. * userspace/libsinsp/CMakeLists.txt: Separate libraries into pkg-config Requires and Requires.private lists. Add the pkg-config requirements to the ignored link dependencies, since these are now recorded as Requires in the pkg-config file. * userspace/libsinsp/libsinsp.pc.in (Requires): Add @LIBSINSP_REQUIRES@. (Requires.private): New field. (Libs): Remove -lsinsp, automatically computed in SINSP_PKG_CONFIG_LIBS. Signed-off-by: Maxim Cournoyer <[email protected]>
* driver/CMakeLists.txt (DRIVER_SOURCES): Add missing headers. * userspace/libsinsp/test/CMakeLists.txt (unit-test-libsinsp): Link to libgrpc++ to avoid a missing DSO error. * userspace/libscap/CMakeLists.txt: Do not hardcode STATIC type for scap_event_schema and scap_platform libraries, so as to install them (they are referenced in the pkg-config files). Fixes: falcosecurity#1820 Signed-off-by: Maxim Cournoyer <[email protected]>
7a5dde2
to
d7f10d4
Compare
What type of PR is this?
/kind bug
Any specific area of the project related to this PR?
/area build
/area libscap-engine-gvisor
/area libpman
/area libsinsp
What this PR does / why we need it:
It sanitizes the generated pkg-config files of libscap.pc and libsinsp.pc, and add missing includes needed to build as shared libraries.
Which issue(s) this PR fixes:
Fixes #1820
Special notes for your reviewer:
Also see #1825, which is not addressed by this PR but can be easily worked around.
Does this PR introduce a user-facing change?: