Libraries are no longer de-duped? #83
Labels
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: ariadne/pkgconf#83
Loading…
Reference in New Issue
There is no content yet.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may exist for a short time before cleaning up, in most cases it CANNOT be undone. Continue?
Hi,
I'm having the opposite problem to #78 while trying to build qt. Some part of it's build system de-dupes libs and will drop dependencies at the end. A suitable test for this is already written but the current result is:
the ideal result would be either of (probably the first):
So that the final
-lfoo
isn't stripped. I'm not sure whatpkg-config
does in this case but the de-duping behaviour is preferable.I think
-lprivate -lfoo -baz -lzee -lbar -lfoo
is correct. Can you explain why it wouldn't be?Keep in mind static linking, which may require the dependency to be declared twice.
This is for static linking (cross-compiling actually), I'm updating
pkgconf
in mxe.cc from a pre 0.9.3 (https://github.com/pkgconf/pkgconf/commit/da179fd) to 0.9.12. The old version produces nice output like:where the new version does this:
which looks like something
pkg-config
would produce. There's a lot of redundancy there and it's very hard to read - it's not incorrect, but also not in the spirit ofpkgconf
.Isn't it only the last appearance of a lib that matters to the linker? That's been my experience but I'll browse though the issues - do you have an example that comes to mind?
So a younger version of myself didn't understand the correct behaviour! Your comment:
Is the right behaviour.
Now I think the merge-back should be enabled for static but I'll do some more reading. We've actually been using a merge-back enabled version of
pkgconf
in MXE for years without ordering issues.With shared linking, it does not matter and merge-back is safe always.
With static linking, some optimizations are unsafe. For example, if
-lws2_32
depends on-lcrypt32
, then-lcrypt32
must come first. Obviously we try to handle that in all cases.It may be a bug. I'm still not convinced though. Static linking is always going to be ugly, and I think the fact that it happened to just work for you before was likely a bug...
Please attach all involved .pc files so we can check their correctness. The deduplication features need a full view of the dependency graph in order to safely optimize. Most likely Qt (or a dependency) is not properly declaring the dependency graph.
Also, if you really want the unsafe optimizations we can probably add an option for them to enable them even in
--static
mode, but there we should be conservative by default.I'm confused, did you mean last? Neither the old nor new behaviour puts
-lcrypt32
first.I think a large part of the ugliness comes from people adding libs until something works. The only really ugly workaround we've had with the stricter merge-back is a single case of truly circular dependencies (harfbuzz and freetype from freedesktop.org - maybe they think such things are clever).
Yesterday, I stumbled across the grouping options in
ld
:This sounds like a very nice solution to such problems, though I haven't tried it yet and aren't sure how it will be parsed if I put it in
Libs.private
.Qt is a bit of a red-herring, it's doing it's own (naive) de-duplication with qmake's "append unique" operator
LIBS *= ...
. I can simply replace that*
with a+
and the build will succeed.That would be ideal! Some sort of strict/pedantic mode with the ability to parse (or simply pass-thru) cycle annotations would likely make the optimisations both safe and readable. (I'll brush up on my graph theory to state that more clearly)
The unsafe optimisations not only reduce maintenance and support requests, but make it much easier to debug problems. Since we started bundling
pkgconf
there's almost no linking questions that don't amount to "did you use the wrapper script?".What I'm actually trying to do is improve the out-of-the-box MXE experience for
cmake
users with static Qt builds (or static builds in general). These issues go back to at least 2006 and there's no current solution from either upstream project. The only workable solution is to getcmake
to usepkgconf
, it already has built in support forpkg-config
and it works well apart from some-L
merge-backs that seem to have been fixed recently.I guess what I'm really trying to do is integrate command-line
pkgconf
withld
,cmake
, andqmake
. I knowlibpkgconf
is around the corner, but I doubt I'll be able to integrate it at a library level. As with lib interfaces, the more strict/pedantic/deterministicpkgconf
can be, the better.Would a flag, say,
--pure
which has the old behaviour be interesting for you?Yes! That would be great.
@tonytheodore with this you can use
pkgconf --static --pure
to build a static dep graph and then treat it as if it were a normal dep graph. should give you what you want.