-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Dependency Handling Whiteboard #3111
Comments
The best solution would be to update pkg-config to provide a richer set of data. That will be probably be tricky. Is it even actively maintained? |
Kinda, but not really. However, we can recommend pkgconf as a future replacement. It already has a Python API too that we can if it's available for greater speed. I think it's fine if we support older pkg-config with fallback code that calls it multiple times to get all the info we need. |
This is related too: #2816 |
In addition to static vs shared, do we need to allow selection between other variants? I am thinking of boost here, which gives debug and non-debug variants different names on windows. |
I'll mention that include paths can also lead to trouble - here's an example where I got it wrong: xkbcommon/libxkbcommon@776cb52. Getting rid of shared include paths is probably harder than library paths. But maybe you have some ideas. Alternatively, we can all switch to NixOS. |
just edited in: static linking specific cflagsSome platforms (i.e. windows) require different cflags when compiling code that will be statically linked against a library (i.e. no declspec dll import). |
|
Might come in handy to know that |
Here's a case where absolute paths failed where -L would be better: https://groups.google.com/forum/#!topic/mesonbuild/USAviy4NZSw Basically, meson converted pkg-config's library spec to an absolute path, but the "library" is a linker script which points to an actual library file. But the path to the library file is not in the system ldconfig path. So since meson did not use -L, the actual library file is not found - thus linker error. |
[Feel free to mercilessly edit this when parts are resolved or for any other reason]
[Partially based on irc conversations in the meson irc channel]
Reasons absolute paths in pkg-config files might break things.
There is interest in investigation if generating pc files that point to the actual files rather than doing -L/-l magic is viable.
libs: -L${libdir}
-lsomething
to 'Libs: ${libdir}/libsomething.so'Alternatives:
Static vs dynamic linking selection (user intend)
static linking specific cflags
Some platforms (i.e. windows) require different cflags when compiling code that will be statically linked against a library (i.e. no declspec dll import).
(pkgconf has
Cflags.private
for that, for pkg-config see https://bugs.freedesktop.org/show_bug.cgi?id=47996)Resolving library pathes as early as possible
Meson wants to resolve libraries to file pathes as early as possible to avoid relying on the shared state in the linker commandline where search pathes from many different dependencies can mix in hard to predict ways.
pkg-config --libs-only-l
is also recursivepkg-config --print-requires
, then runpkg-config --libs-only-l
on each, and subtract from the original listSecondary Dependencies
Dependencies themselves often have their own dependencies
Static linking
For static linking these dependencies need to be added as direct dependencies while linking.
Dynamic linking
At least gnu binutils' ld insists that dependencies of shared libraries (DT_NEEDED) need to be available and findable at link time. Practically this means all locations (containing directory) of secondary dependencies need to be either specified either as
-rpath
or-rpath-link
Pkg-config file generation
dependency('name')
.Link argument deduplication
Real builds can get very slow by massive duplications of libraries in dependency chains. Some discussion here #2156
Recent changes should at least reduce this problem: #3392 #3394 #3395
Open issues: #2150 #3071
Dependencies for relinking on change.
Build rpath
Meson should ensure for all dependencies that targets are runnable from the build directory.
--disable-new-dtags
is needed.--enable-new-dtags
/DT_RUNPATH
is not really recursive (or maybe not if any library hasDT_RUNPATH
entries on it's own)Windows std library variants
(from irc): """just realised that everything about "debug" is broken. There are at least two different things that it means on Windows. The first is debug information (pdb files) and the second is whether deps are built against the debug STL or not. We currently don't deal with the latter in any way. Qt ships release and debug deps and we need to know which one to use. I would imagine the only way to get that done is to somehow look at the value of b_vscrt and make it part of the dependency lookup. But the question then becomes what to do if the mode is /MTd or /MT?"""
The text was updated successfully, but these errors were encountered: