Fix some CMake build issues - #363
Merged
Merged
Conversation
The CMake PkgConfig module doesn't handle statically linking as nicely as you would expect. When it finds a `.pc` file, that file tells it what flags to use when linking statically vs what flags to use when linking dynamically, but it does not tell it whether the distribution providing that `.pc` file actually provides a library that can be linked dynamically or not. Because of that, we've been using the variables holding the dynamic linking flags unconditionally, leading to broken builds in environments that only provide static libraries. Handle this by detecting whether or not the main library found for each of these dependencies is `libelf.a` or `libdw.a`, and set up a CMake imported target that passes the right flags depending on whether or not the library was detected to be an archive rather than a shared library. Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
Because GCC requires a linker plugin to enable LTO, some environments may have GCC installed but unable to successfully link an LTO build. Detect that condition at CMake configure time and disable LTO. Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #363 +/- ##
=======================================
Coverage 78.19% 78.19%
=======================================
Files 58 58
Lines 6690 6690
Branches 630 630
=======================================
Hits 5231 5231
Misses 1459 1459
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
blin
approved these changes
Sep 22, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fix some issues that have cropped up when doing CMake builds in various environments. Note that these changes should have no effect on wheels built by cibuildwheel, so this PR only affects maintainers' ability to test on and build directly on different environments.