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

Preserve library order between file paths and libs specified via flags #142

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

piodul
Copy link

@piodul piodul commented Dec 30, 2022

pkg-config files can specify library dependencies in two main ways: via -l or -L flags (e.g. -lstdc++) or via a filesystem paths. Currently, pkg-config-rs does not preserve the order between them when generating cargo commands - it prints commands for the first kind, then for the second. Some linkers are sensitive to the order in which libraries are specified, so this behavior won't work with pkg-config files in which a library specified via a path depends on a library specified via an -l flag.

This PR ensures that the generated cargo commands are correctly ordered with respect to the order in which libraries are specified in the pkg-config output.

pkg-config files can specify library dependencies in two main ways: via
-l or -L flags (e.g. -lstdc++) or via a filesystem paths. Currently,
pkg-config-rs does not preserve the order between them when generating
cargo commands - it prints commands for the first kind, then for the
second. Some linkers are sensitive to the order in which libraries are
specified, so this behavior won't work with pkg-config files in which
a library specified via a path depends on a library specified via an -l
flag.

This commit ensures that the generated cargo commands are correctly
ordered with respect to the order in which libraries are specified
in the pkg-config output.
@piodul
Copy link
Author

piodul commented Dec 30, 2022

Although just fixing the order of cargo commands is sufficient for my case, there is a similar problem with Library::libs vs Library::link_files as they don't preserve the original order of libraries. I'm not sure how the API should be adjusted to include information about the original order of libraries, but if the maintainers have an idea and it's not too much work then I'll be happy to adjust this PR to fix this as well.

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.

None yet

1 participant