-
Notifications
You must be signed in to change notification settings - Fork 69
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
Design of system packages #65
Comments
As some background for anyone who has not dealt with conflicting system libraries and custom libraries before I'll add a bit more background... Say that your app depends on This is impossible to ensure if your app uses The other option is to have your app link to libfoo.a using But the problem of conflicting headers still exists. To point a compiler at headers you have only the |
Working on trying to understand the failure at mapbox/mapbox-gl-native#802 by starting to add tests to |
What's wrong with building and statically linking to our own zlib? Then we don't need to worry about system conflicts. |
Statically linking zlib is fine if you can be sure that all code statically links the same zlib (allowing the linker to discard duplicate symbols). Situations where this would not work and would be asking for trouble:
|
Hmm, you cant get the linker to resolve the zlib symbols in our .a/.o files with or zlib, and let other dynamically loaded libs resolve their own zlib? |
In adding tests for zlib-system (#66) I've noticed that
@ljbade not that I'm aware. But I've never been keen to try such a thing enough to learn the intricacies of how you might go about ensuring it works 100% safely. What I see when apps truly need to vendor a library that is also a system/shared library they will rename all the symbols so you can call |
I'm running into this problem. The root cause of this is that Android uses separate package dirs per toolchain, but we don't want that for iOS since it means we'd have to build separate projects for Simulator and actual device. All of our static archives have five architectures (armv7, armv7a, arm64, x86 and x86_64, the latter two are for the simulator), so we're clear here. I think the quickest fix for now is to not output include and lib paths for |
sounds good @kkaefer |
Under GNU
Apple's Normally, the OS/X linker searches all paths for dynamic libraries, then all paths for static libraries. This can be changed to "search each path for dynamic, then static, then continue to the next path" by supplying |
For reference, there are some other (ugly) techniques for handling symbol conflicts discussed here: http://stackoverflow.com/questions/3232822/linking-with-multiple-versions-of-a-library Summary:
I wouldn't want to go down any of these paths unless absolutely necessary. |
A ticket to discuss how to design "system" packages for mason, which are a very unique kind of package. This is a place for @kkaefer and @springmeyer to sync up on goals and others to read to get some background on why system packages are tricky.
My understanding is that a system package:
zlib
without installing a custom version. (**This can be very important because something like zlib is often a dependency of so many apps that mixing a custom version of zlib would be a path to ABI conflicts and much pain).zlib
is located such that a build system can depend on mason to supply platform-specific flags.published
since there is nothing binary to publish. Therefore thescript.sh
does all the work dynamically on each system.But one challenge remains: is it safe to put the -L/path and -I/path of the system package on the compile and link paths? This can result in conflicts with other system libraries that you might be intending to statically link.
I ran into a situation like this with libpq (postgres client library) on OS X, which is the motivation for trying to have
mason cflags
andmason ldflags
return symlinks to the location of a system package rather than the real location (4e14abb). However, due to the nature of the postgres build system I ultimately found I could not avoid-L/usr/lib
ending up on the link flags, even if mason did not put it there. So my changes were not enough. And in addition they were not correct for every platform and therefore caused other unintended breakages downstream in mbgl which I'm sorry about.@kkaefer has made some progress further cleaning up the
zlib-system
package (https://github.com/mapbox/mason/commits/zlib-system). Hopefully we'll be in good shape now and we can keep the symlinking addition. Or we can remove it. Let's discuss.The text was updated successfully, but these errors were encountered: