Thanks to visit codestin.com
Credit goes to github.com

Skip to content

pkg-config: Sort the different sections #3268

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

Merged
merged 1 commit into from
Jun 29, 2015
Merged

pkg-config: Sort the different sections #3268

merged 1 commit into from
Jun 29, 2015

Conversation

vmg
Copy link
Member

@vmg vmg commented Jun 29, 2015

Because of the fact that pkg-config is pants-on-head retarded and that
the Linux linker requires a static library to come before all its
dynamic dependencies in the link path, calling pkg-config --libs --static was generating the wrong flags for linking.

Before this patch:

-Wl,-Bsymbolic-functions -Wl,-z,relro -L/usr/local/lib -lcurl -lssh2
-lrt -lgit2 -lssl -lcrypto -ldl -lz

After this patch:

-Wl,-Bsymbolic-functions -Wl,-z,relro -L/usr/local/lib -lgit2 -lcurl
-lssh2 -lrt -lssl -lcrypto -ldl -lz

By setting the "Libs" line before all other rules, we make sure that
-lgit2 is the first library in the link path and that it gets its
symbols resolved with the libraries coming after it.

This fix (ab)uses an implementation detail in pkg-config (namely, that
flags are output as they are found on the file), but this detail seems
to be stable between releases and always gives a stable output.

Because of the fact that pkg-config is pants-on-head retarded and that
the Linux linker *requires* a static library to come before all its
dynamic dependencies in the link path, calling `pkg-config --libs
--static` was generating the wrong flags for linking.

Before this patch:

	-Wl,-Bsymbolic-functions -Wl,-z,relro -L/usr/local/lib -lcurl -lssh2
	-lrt -lgit2 -lssl -lcrypto -ldl -lz

After this patch:

	-Wl,-Bsymbolic-functions -Wl,-z,relro -L/usr/local/lib -lgit2 -lcurl
	-lssh2 -lrt -lssl -lcrypto -ldl -lz

By setting the "Libs" line before all other rules, we make sure that
`-lgit2` is the first library in the link path and that it gets its
symbols resolved with the libraries coming after it.

This fix (ab)uses an implementation detail in `pkg-config` (namely, that
flags are output as they are found on the file), but this detail seems
to be stable between releases and always gives a stable output.
vmg pushed a commit that referenced this pull request Jun 29, 2015
pkg-config: Sort the different sections
@vmg vmg merged commit b977d01 into master Jun 29, 2015
@ethomson ethomson deleted the vmg/pkg-config-sort branch January 9, 2019 10:20
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.

1 participant