Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upIncluding system library paths makes it difficult to overide library versions #11
Comments
This comment has been minimized.
This comment has been minimized.
|
Currently system library paths are required to allow the compiler to find static versions of libraries, but I can see where this would cause problems with multiple libs on the system... |
This comment has been minimized.
This comment has been minimized.
|
Could the compiler not add the system default paths, independently of pkg-config, at the end of the arguments list (so they have the lowest priority)? |
This comment has been minimized.
This comment has been minimized.
|
Perhaps, but the compiler has no knowledge of the default paths for a system (like the linker does) |
This comment has been minimized.
This comment has been minimized.
|
What would the process be, to move towards a solution for this? |
This comment has been minimized.
This comment has been minimized.
|
I can't really think of a great solution for this, so it would probably involve coming up with one first :) |
This comment has been minimized.
This comment has been minimized.
|
I'm not familiar with all the tooling rust uses to compile. Is there some place I can read up on the linkers used on different platforms? Could the compiler query the linker for the default paths? |
This comment has been minimized.
This comment has been minimized.
|
We generally just shell out to |
This comment has been minimized.
This comment has been minimized.
julienw
commented
Apr 26, 2016
|
So in our project we ended up on exactly the same issue, and no easy solution. Of course the root cause is the awful setup of libssl on MacOS X but we need to find a way around this... I still don't properly get why we need the system paths for the static libs to be found. Isn't it something that |
julienw
referenced this issue
Apr 26, 2016
Open
[Mac] Linking intermittently fails to find openssl symbols #414
This comment has been minimized.
This comment has been minimized.
julienw
commented
Apr 26, 2016
•
|
If we really need it, here is a dumb idea: call
Diff the 2 outputs. Then we'd know which libs are the system libs. |
This comment has been minimized.
This comment has been minimized.
The compiler needs to load the actual
Perhaps! |
This comment has been minimized.
This comment has been minimized.
julienw
commented
Apr 27, 2016
|
I just re-read the manual page for pkg-config. Actually the list of paths that pkg-config considers as "system" seems to be hard-coded:
So maybe it's good enough to just special-case these paths ? |
This comment has been minimized.
This comment has been minimized.
|
I'd be game! |
This comment has been minimized.
This comment has been minimized.
julienw
commented
Apr 27, 2016
|
So now, how do we special case them ? Do you think rustc could actually automatically always add them (and then we can remove them from pkg-config output)? Or would it be too fragile and we should instead add them as a new special build.rs output that cargo would understand ? |
This comment has been minimized.
This comment has been minimized.
|
It's pretty rare to pick up a staticlib from there, so if we're linking a dylib we just shouldn't print out those two |
This comment has been minimized.
This comment has been minimized.
julienw
commented
Apr 29, 2016
|
In that case the patch would be as simple as not adding the env variable |
This comment has been minimized.
This comment has been minimized.
lilith
commented
Sep 4, 2016
|
See sfackler/rust-openssl#447 (comment) I think there's a way to make this specific to certain libraries (or, at least, I did for openssl):
|
This comment has been minimized.
This comment has been minimized.
|
@nathanaeljones I don't think that syntax is recognized by the compiler. It will attempt to interpret |
This comment has been minimized.
This comment has been minimized.
lilith
commented
Sep 15, 2016
•
|
What about #11 (comment) ? This is a pretty painful bug. Since |
This comment has been minimized.
This comment has been minimized.
lilith
commented
Sep 16, 2016
|
For reference, this is how I'm using [replace]. Cargo pretends it doesn't exist.
|
This comment has been minimized.
This comment has been minimized.
lilith
commented
Sep 22, 2016
|
|
This comment has been minimized.
This comment has been minimized.
|
@nathanaeljones hm the |
This comment has been minimized.
This comment has been minimized.
lilith
commented
Jan 3, 2017
|
No, they both were not. But due to the non-deterministic order of link paths in cargo, it is very hard to construct tests. Failures can range from 5% of builds to 95% of builds, so isolating variables is near-impossible. (I'm not blaming pkg-config - there are larger questions) FrictionThis is by far the worst whack-a-mole situation I've experienced in the Rust ecosystem. Since September, I've averaged 16 hours per month in fighting recurrences on Travis and AppVeyor (along with various dev environments). I forked pkg-config, but any new crates I use could pull in a standard version, causing the issue to ... eventually, even weeks later ... reoccur. It's not easy to diagnose, even the (n)th time, because sometimes it is just OpenSSL breaking its ABI again, or an actual build environment issue, and it's just infrequent enough to be extremely painful. I should be shipping a production beta of Imageflow this month, but for now I've had to disable TLS support across all crates and purge usage of HTTPS. For the server component, I'm planning an nginx proxy to substitute, but I don't yet have an answer for making HTTPS requests, and that's kind a key feature for an image proxy. Right now I'm holding my breath and hoping that this PR goes somewhere fast. If it doesn't, I'll need to fork Hyper and most of the Iron ecosystem rather quickly. Unfortunately, this isn't limited to OpenSSL - I've run into it with libpng, libjpeg, and various other packages. Larger questionMy understanding is that there are several issues at play:
Hear me out. You've got a great solution to the OpenSSL nightmare in the works, but the problem with C dependencies (in general) persists. Cross-plat is much harder when wrangling compatibility with a range of versions for each dependency. With diamond dependencies (like openssl) this is sometimes impossible without forking the world. What if we made it easier for developers to use specific versions of C/C++ dependencies? I realize this feature (discovered as I write this) tries to make that easier, and I suspect I could .gitignore .cargo/config and generate it from Conan. However, if I miss a target, or a library, I risk silently linking against the wrong binaries and risking future heap or stack corruption. What if - rather than preventing various build.rs scripts from executing - I was able to specify a 'filter' - an executable receiving the concatenated build script output via STDIN (along with all env vars like the target triple), and producing modified results to STDOUT? This method would permit:
Anticipated challenges:
|
This comment has been minimized.
This comment has been minimized.
julienw
commented
Jan 4, 2017
•
|
@nathanaeljones if you already forked to remove https://github.com/alexcrichton/pkg-config-rs/blob/e9297b2e16e40026ec546324b657b780d2c305b3/src/lib.rs#L363 in your fork, maybe you can propose a PR ? |
This comment has been minimized.
This comment has been minimized.
|
@nathanaeljones sorry you've been having so much trouble lately! It sounds like there's definitely some improvement we could make somewhere. That being said though this perhaps isn't the place to discuss these issues? I'm more than willing to help out with any particular issue, but general changes to Cargo should probably be discussed on internals.rust-lang.org, rather than the pkg-config-rs issue tracker. |
This comment has been minimized.
This comment has been minimized.
lilith
commented
Jan 5, 2017
|
@julienw #35 Would have done so earlier, but I didn't get confirmation that the change was acceptable. @alexcrichton I wasn't sure, but figured you could suggest the best forum. Thanks! I'll post there. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
lilith
commented
Jan 24, 2017
•
|
In light of the refactoring of SSL in Hyper, I upgraded all crates and gave this another try. It would appear that this is still broken by default - at least, compiling openssl-sys on Ubuntu 14.04 brings in the world ( |
This comment has been minimized.
This comment has been minimized.
lilith
commented
Jan 24, 2017
|
What if we could somehow pass paths to the compiler only? Is there anything we can do to make this correct? |
hugoduncan commentedMar 11, 2015
At present,
Config::findreturns system library paths. This can make it difficult to override library versions.The motiviating example is using rust-openssl with ssh2-rs on OS X. On Mac, openssl requires a non-system version of openssl for TLS support, which can successfuly be provided by homebrew, for example. ssh2-rs depends on libz-rs, which pkg-config finds as
-L /usr/lib. This library path gets added before the openssl library path, resulting in the system (older) openssl libraries being used, and the linker failing.