-
Notifications
You must be signed in to change notification settings - Fork 165
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 pkgconfig files (mostly for static linking) #2005
Merged
+170
−150
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
05d356d
fix(build): get pkgconfig libraries recursively
gnosek af7b76b
fix(build): install libpman
gnosek 5f0571a
fix(build): fix gvisor .so build
gnosek 65934b1
fix(build): do not expose build directory includes in pkg-config
gnosek a9399a2
fix(build): install cri_* helper libraries and generated headers
gnosek 00c76a8
fix(build): link cri_* with grpc
gnosek 2bf1a1b
fix(build): make sinsp->cri_* linkage public
gnosek f6f1119
cleanup(build): remove now-unused link
gnosek f08b1ef
fix(build): make engines' links public
gnosek 0535c22
fix(build): do not install entire libelf as "headers"
gnosek 53ee284
cleanup(build): do not install libbpf headers
gnosek 53cf2d7
cleanup(build): gvisor no longer has a circular dependency on scap
gnosek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
# Get all dependencies for ${lib} and add them to ${LIBDIRS_VAR} and ${LIBS_VAR}. Ignore any | ||
# dependencies in the list ${ignored} to: - avoid infinite recursion - avoid libscap dependencies in | ||
# libsinsp.pc (which requires libscap.pc and pulls them in that way) | ||
function(add_pkgconfig_library LIBDIRS_VAR LIBS_VAR lib ignored) | ||
|
||
# if it's not a target, it doesn't have dependencies we know or care about | ||
if(NOT TARGET ${lib}) | ||
return() | ||
endif() | ||
|
||
# get the libraries that ${lib} links to | ||
get_target_property(PKGCONFIG_LIBRARIES ${lib} LINK_LIBRARIES) | ||
if("${PKGCONFIG_LIBRARIES}" STREQUAL "PKGCONFIG_LIBRARIES-NOTFOUND") | ||
return() | ||
endif() | ||
|
||
get_property( | ||
target_type | ||
TARGET ${lib} | ||
PROPERTY TYPE | ||
) | ||
foreach(dep ${PKGCONFIG_LIBRARIES}) | ||
# ignore dependencies in the list ${ignored} | ||
if(${dep} IN_LIST "${ignored}") | ||
continue() | ||
endif() | ||
|
||
if(${target_type} STREQUAL "SHARED_LIBRARY") | ||
# for shared libraries, do not add static libraries as dependencies | ||
if(TARGET ${dep}) | ||
# skip static libraries which are CMake targets | ||
get_property( | ||
dep_target_type | ||
TARGET ${dep} | ||
PROPERTY TYPE | ||
) | ||
if(${dep_target_type} STREQUAL "STATIC_LIBRARY") | ||
continue() | ||
endif() | ||
else() | ||
# skip static libraries which are just file paths | ||
get_filename_component(ext ${dep} LAST_EXT) | ||
if("${ext}" STREQUAL "${CMAKE_STATIC_LIBRARY_SUFFIX}") | ||
continue() | ||
endif() | ||
endif() | ||
elseif(${target_type} STREQUAL "STATIC_LIBRARY") | ||
# for static libraries which are not CMake targets, redirect them to | ||
# ${libdir}/${LIBS_PACKAGE_NAME} note that ${libdir} is not a CMake variable, but a | ||
# pkgconfig variable, so we quote it and end up with a literal ${libdir} in the | ||
# pkgconfig file | ||
if(NOT TARGET ${dep}) | ||
get_filename_component(filename ${dep} NAME) | ||
set(dep "\${libdir}/${LIBS_PACKAGE_NAME}/${filename}") | ||
endif() | ||
endif() | ||
|
||
add_pkgconfig_dependency(${LIBDIRS_VAR} ${LIBS_VAR} ${dep} "${ignored}") | ||
endforeach() | ||
|
||
# Remove duplicate search paths. We cannot remove duplicates from ${LIBS_VAR} because the order | ||
# of libraries is important. | ||
list(REMOVE_DUPLICATES ${LIBDIRS_VAR}) | ||
|
||
set(${LIBS_VAR} | ||
${${LIBS_VAR}} | ||
PARENT_SCOPE | ||
) | ||
set(${LIBDIRS_VAR} | ||
${${LIBDIRS_VAR}} | ||
PARENT_SCOPE | ||
) | ||
endfunction() | ||
|
||
function(add_pkgconfig_dependency LIBDIRS_VAR LIBS_VAR lib ignored) | ||
if(${lib} IN_LIST ignored) | ||
# already processed, avoid infinite recursion | ||
elseif(${lib} MATCHES "^-") | ||
# We have a flag. Pass it through unchanged. | ||
list(APPEND ${LIBS_VAR} ${lib}) | ||
elseif(${lib} MATCHES "/") | ||
# We have a path. Convert it to -L<dir> + -l<lib>. | ||
get_filename_component(lib_dir ${lib} DIRECTORY) | ||
list(APPEND ${LIBDIRS_VAR} -L${lib_dir}) | ||
get_filename_component(lib_base ${lib} NAME_WE) | ||
string(REGEX REPLACE "^lib" "" lib_base ${lib_base}) | ||
list(APPEND ${LIBS_VAR} -l${lib_base}) | ||
else() | ||
# Assume we have a plain library name. Prefix it with "-l". Then recurse into its | ||
# dependencies but ignore the library itself, so we don't end up in an infinite loop with | ||
# cyclic dependencies | ||
list(APPEND ${LIBS_VAR} -l${lib}) | ||
list(APPEND ignored ${lib}) | ||
add_pkgconfig_library(${LIBDIRS_VAR} ${LIBS_VAR} ${lib} "${ignored}") | ||
endif() | ||
set(${LIBS_VAR} | ||
${${LIBS_VAR}} | ||
PARENT_SCOPE | ||
) | ||
set(${LIBDIRS_VAR} | ||
${${LIBDIRS_VAR}} | ||
PARENT_SCOPE | ||
) | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
prefix=${pcfiledir}/../.. | ||
libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ | ||
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ | ||
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@/@LIBS_PACKAGE_NAME@ | ||
|
||
Name: libscap | ||
Description: lib for System CAPture | ||
Version: @FALCOSECURITY_LIBS_VERSION@ | ||
|
||
Libs: -L${libdir} @LIBSCAP_LINK_LIBDIRS_FLAGS@ @LIBSCAP_LINK_LIBRARIES_FLAGS@ | ||
Cflags: -I${includedir}/@LIBS_PACKAGE_NAME@/libscap | ||
Cflags: -I${includedir} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Just a question after a very first look: will
BUILD_SHARED_LIBS
behave like before? 🤔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.
WDYM? libscap_engine_gvisor.so becomes a separate shared library, so that's a change, but other than that, there should be no observable changes (at least, Works For Me ™️)
TBH I'm not entirely sure when the circular dependency disappeared, probably when extracting some scap_platform_util or other
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.
I meant regarding
BUILD_SHARED_LIBS
in general, but I noticed right now that it's only related to gvisor (and I believe it's acceptable).cc @LucaGuerra
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.
FWIW, I consider splitting out scap_engine_gvisor as a separate .so a fix
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.
sounds fine!