-
Notifications
You must be signed in to change notification settings - Fork 79
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
Bug: is_system
erroneously reports that a library is a system library in some cases.
#36
Comments
Does configuring this crate work? |
It doesn't work, since the |
Sounds like a bug to fix then! |
I'll look into it in the near future! |
#37 Sent a PR. I left the check with empty directory list as is, because it seems reasonable to think a library is a system lib if no search path is specified. But I fixed two other problems. |
There's still one problem: The I don't know if there even exists a simple, non-distro specific heuristic that is able to prevent obviously wrong choices while allowing the correct ones. (One of reasonable candidates is checking whether the path contains word "musl"; that works at least on Debian and Arch, but that would be not only distro-specific, but also target-specific. Not sure if we even have other static targets than musl, though.) |
The
is_system
function uses a heuristic "path starts with/usr
" to check whether a library is a system library. For reasons unknown to me, being a system library blocks static linking.The function iterates all the dirs and checks if any of them is a non-system library. If even one library search path is found for the library that is "non-system", the function returns false. If all the search paths are system libraries, the function returns true.
However, the function has a bug: if the list of search dirs passed to it is empty, the function returns true. I'm not sure how should it behave if the list is empty, but certainly returning "this is a system lib" when the library is actually not, is wrong behaviour.
There's some other concerns too: the dirs are added to the list in the order they are got from
pkg-config
. This is the reason the dir list may be empty in the first place; pkg-config might return something like:-I/musl/include -lssl -lcrypto -L/musl/lib -ldl
.There's another concern too. That has more to do with the spirit of this issue I posted just a moment ago in the Rust repo: rust-lang/rust#39998 If the pkg-config knows that I want to link statically (after all, I specified the env vars!), why does it silently pass dynamic flags to cargo instead of erroring: "You said you want to link statically but what you've got here is a system lib, I can't link that statically!"
The text was updated successfully, but these errors were encountered: