Skip to content

Support pkg-config-rs link_files on static/target builds - #137

Merged
gdesmott merged 6 commits into
gdesmott:mainfrom
cole-h:support-link_files
Aug 14, 2026
Merged

gdesmott merged 6 commits into
gdesmott:mainfrom
cole-h:support-link_files

Conversation

@cole-h

@cole-h cole-h commented Feb 10, 2026

Copy link
Copy Markdown

I was recently working on a project that was trying to link to another project statically. The build was failing because it couldn't link to boost; when building statically, the parts of boost that were used were propagated in the Libs: of the library as a .a static archive. However, if I used pkg_config directly to directly probe libraries depending on these static archives from boost, the build started succeeding. That's when I noticed that pkg-config-rs handles this via the link_files part of their Config, but system-deps didn't!

There are a few things here that are maybe not quite Super Awesome (like the test needing to dig so deep into the test setup functions, and having to add the target arg to the gen_flags function), so if you have thoughts or opinions on how to make them better, I'd be happy to fix them!

@codecov

codecov Bot commented Feb 13, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.41935% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.64%. Comparing base (3bb1c9e) to head (ac11ae3).

Files with missing lines Patch % Lines
src/lib.rs 84.61% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #137      +/-   ##
==========================================
+ Coverage   92.40%   92.64%   +0.23%     
==========================================
  Files           8        8              
  Lines        3412     3564     +152     
==========================================
+ Hits         3153     3302     +149     
- Misses        259      262       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gdesmott gdesmott left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks for your patch!

I'm happy to integrate this feature but ideally would prefer to avoid copying all this code from pkg-config-rs if possible.

Comment thread src/lib.rs
Comment thread src/lib.rs
Comment thread src/lib.rs Outdated
}
}

// Copied from pkg-config-rs:

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

It's not great to have so many tricky logic copied from pkg-config-rs.

It would be great if this could be exposed as part of their API somehow. Can you open a ticket there asking if that's something they would consider?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yeah, I agree. I was going back and forth on whether or not to ask them to expose it, and ended up not, but you're right that it would be much better if they said "yes".

rust-lang/pkg-config-rs#184

Comment thread src/test.rs Outdated
Comment thread src/test.rs Outdated
Comment thread src/lib.rs Outdated
@cole-h

cole-h commented Mar 25, 2026

Copy link
Copy Markdown
Author

(Since clippy was failing, I added an expect attr that silences it for this one function, since I'd like to keep the diff from upstream as small as possible)

@cole-h
cole-h force-pushed the support-link_files branch from a91dff7 to f5f4499 Compare May 10, 2026 00:27

@cole-h cole-h left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@gdesmott Thanks again for the review, and sorry for letting this languish for so long... I completely forgot about it. However, I think I've addressed all your comments at this point. Unfortunately, there's been no movement upstream on exposing this function, though...

I submitted a PR just now that would fix the issue I submitted earlier; maybe that will be more successful: rust-lang/pkg-config-rs#192

Comment thread src/lib.rs
Comment thread src/test.rs Outdated
Comment thread src/test.rs Outdated
@cole-h
cole-h requested a review from gdesmott May 10, 2026 00:40
@gdesmott

Copy link
Copy Markdown
Owner

I submitted a PR just now that would fix the issue I submitted earlier; maybe that will be more successful: rust-lang/pkg-config-rs#192

@sdroege : I see you are a maintainer of pkg-config-rs. Any chance you could give this PR a look please? :)

@cole-h
cole-h force-pushed the support-link_files branch from 884e179 to 84872d3 Compare July 18, 2026 17:13
@gdesmott

Copy link
Copy Markdown
Owner

rust-lang/pkg-config-rs#184 has been fixed (thanks @sdroege !) so we can use this once released.

@sdroege

sdroege commented Jul 27, 2026

Copy link
Copy Markdown

I hope to have time to review some more PRs and possibly merge them before making a new release.

@cole-h

cole-h commented Aug 14, 2026

Copy link
Copy Markdown
Author

pkg-config v0.3.34 was released earlier (thanks, @/sdroege!), which publicized Library::extract_lib_from_filename. The PR now reuses that instead of copy-pasting the implementation.

@sdroege

sdroege commented Aug 14, 2026

Copy link
Copy Markdown

@cole-h @thiblahute rust-lang/pkg-config-rs#185 might also be of interest for the things you're doing btw

@gdesmott
gdesmott merged commit b5d008d into gdesmott:main Aug 14, 2026
9 checks passed
@cole-h
cole-h deleted the support-link_files branch August 14, 2026 15:43
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.

3 participants