Skip to content
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

Also emit DEP_Z_INCLUDE when using pkg-config #188

Merged
merged 1 commit into from
Mar 21, 2024

Conversation

sfackler
Copy link
Member

Downstream build scripts use DEP_Z_INCLUDE to configure the builds of other native libraries (for example in libgit2-sys). Previously, if libz was found via pkg-config and didn't have a system-default include directory those builds would fail.

Copy link
Member

@Byron Byron left a comment

Choose a reason for hiding this comment

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

Thanks a lot for the fix!

It looks good to me, but I wouldn't know how to test it, nor do I think it would be easy to write a test for this.

Can I assume that you validated this works as expected so I can merge?

Also, if you'd like to see a new release with this fix so it can trickle downstream, you could open another PR with the manifest version update, as I think this repository doesn't allow self-approvals.

Thanks again.

@Byron Byron added the question There is a question to be answered label Mar 21, 2024
@sfackler
Copy link
Member Author

Yep, I validated it with [patch.crates-io] on an internal thing that was previously failing to build libgit2.

Will follow up with a version bump PR.

@Byron Byron merged commit fef3990 into rust-lang:main Mar 21, 2024
43 checks passed
@sfackler sfackler deleted the pkg-config-include branch March 21, 2024 19:58
@weihanglo
Copy link
Member

Would it be better using std::env::join_paths instead of commas to maximize the compatibility?

@Byron
Copy link
Member

Byron commented Apr 25, 2024

This could be a great catch!

cargo:include is seemingly unlisted in the docs, maybe I am not looking in the right place though.
With the docs it should be clear what separators can be used - it's surprising that , is support if : or ; would be supported as well. But then again, everything is possible if it's documented somewhere.

@sfackler
Copy link
Member Author

It is the old syntax for

cargo::metadata=KEY=VALUE — Metadata, used by links scripts.

@weihanglo
Copy link
Member

cargo:include is arbitrary user-defined cargo:KEY=VALUE, which is superseded by cargo::metadata=KEY=VALUE to have a better extensibility. I am looking at other -sys crate and some of them have the same (not ideal?) pattern.

@Fabian-Gruenbichler
Copy link

this change broke cross compiling for Debian builds of rustc. Debian builds never use bundled system libraries (they are stripped from upstream sources). before this commit, pkgconf found the system libz and the build script exited. after this commit, even if pkgconf finds the system libz, the build script continues and the fallback to build the bundled version when cross compiling obviously can't work for us if the bundled sources are missing.

it's easy enough to patch around this on our end, I just wanted to make you aware that this not only changed the build script to emit an additional line, but changed its behaviour in a pretty fundamental way that might not have been intended.

@Byron
Copy link
Member

Byron commented Oct 8, 2024

Thanks for letting us know!

It's unsurprising that any change by now has great potential to break downstream. The reason for why the build script is what it is is hard to deduce, and even if it was perfectly documented it would probably be all too easy to make unintended changes.

After all, for the most part, the build script is untested as well, and testing this isn't trivial at all. In theory, each downstream user would have to contribute a CI setup that allows testing their particular requirements.

In lieu of that, maybe it would be possible for those who wish to prevent future breakage to get time to sign-off on planned changes. In theory, subscribing to all PRs should be enough to signal interest and make sure nothing breaks.

But that's all I got, and hope we can find something actionable here as otherwise I think it will just keep breaking.

CC @jongiddy

@Fabian-Gruenbichler
Copy link

on the Debian side we are used to patching build scripts (since we strip all bundled library copies and force the builds to use the system copy via pkgconf), and as far as that is concerned, libz-sys is actually quite good ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question There is a question to be answered
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants