This is an archive of the discontinued LLVM Phabricator instance.

tools/llvm-config: improve shared library support
ClosedPublic

Authored by axw on Nov 26 2015, 10:34 PM.

Details

Summary

r252532 added support for reporting the monolithic library
when LLVM_BUILD_LLVM_DYLIB is used. This would only be done
if the individual components were not found, and the dynamic
library is found.

This diff extends this as follows:

  • If LLVM_LINK_LLVM_DYLIB is set, then prefer the shared library, even if all component libraries exist.
  • Two flags, --link-shared and --link-static are introduced to provide explicit guidance. If --link-shared is passed and the shared library does not exist, an error results.

Additionally, changed the expected shared library names from
(e.g.) LLVM-3.8.0 to LLVM-3.8. The former exists only in an
installation (and then only in CMake builds I think?), and not
in the build tree; this breaks usage of llvm-config during
builds, e.g. by llvm-go.

Diff Detail

Event Timeline

axw updated this revision to Diff 41281.Nov 26 2015, 10:34 PM
axw retitled this revision from to tools/llvm-config: improve shared library support.
axw updated this object.
axw added reviewers: beanz, DiamondLovesYou.
axw added a subscriber: llvm-commits.

It looks like if LLVM is built with LLVM_LINK_LLVM_DYLIB=ON and --link-static is provided and the static archives are removed, llvm-config doesn't error and still prints the shared lib with --libs.

beanz accepted this revision.Nov 30 2015, 9:26 AM
beanz edited edge metadata.

LGTM.

This revision is now accepted and ready to land.Nov 30 2015, 9:26 AM
beanz requested changes to this revision.Nov 30 2015, 9:28 AM
beanz edited edge metadata.

Sorry, didn't notice Richard's comments. Those need to be addressed first.

This revision now requires changes to proceed.Nov 30 2015, 9:28 AM
axw added a comment.Dec 4 2015, 1:04 AM

It looks like if LLVM is built with LLVM_LINK_LLVM_DYLIB=ON and --link-static is provided and the static archives are removed, llvm-config doesn't error and still prints the shared lib with --libs.

I've updated it to cater for this. It's a bit more complicated in order to keep current behaviour.

I'd prefer if we didn't do this "if static exists use, otherwise use shared", and rather just use whatever the installation is supposed to as according to LLVM_LINK_LLVM_DYLIB. Richard, if you have no objections, I'll change it to do that.

axw updated this revision to Diff 41845.Dec 4 2015, 1:05 AM
axw edited edge metadata.

Fail on non-existing static libraries when --link-static supplied

In D15033#302259, @axw wrote:

It looks like if LLVM is built with LLVM_LINK_LLVM_DYLIB=ON and --link-static is provided and the static archives are removed, llvm-config doesn't error and still prints the shared lib with --libs.

I've updated it to cater for this. It's a bit more complicated in order to keep current behaviour.

I'd prefer if we didn't do this "if static exists use, otherwise use shared", and rather just use whatever the installation is supposed to as according to LLVM_LINK_LLVM_DYLIB. Richard, if you have no objections, I'll change it to do that.

I disagree. Such complexity is easier to maintain upstream, and avoids multiple downstream solutions for this problem. The problem can still happen if LLVM_LINK_LLVM_DYLIB=OFF, and it would be Nice to automatically delegate to the dylib (if it exists) for external tools so things will Just Work (absent of --link-static).

axw added a comment.Dec 14 2015, 5:23 PM
In D15033#302259, @axw wrote:

It looks like if LLVM is built with LLVM_LINK_LLVM_DYLIB=ON and --link-static is provided and the static archives are removed, llvm-config doesn't error and still prints the shared lib with --libs.

I've updated it to cater for this. It's a bit more complicated in order to keep current behaviour.

I'd prefer if we didn't do this "if static exists use, otherwise use shared", and rather just use whatever the installation is supposed to as according to LLVM_LINK_LLVM_DYLIB. Richard, if you have no objections, I'll change it to do that.

I disagree. Such complexity is easier to maintain upstream, and avoids multiple downstream solutions for this problem.

My contention is that the complexity is unnecessary in the first place; I don't see why anything should work around broken installations, regardless of whether that be in llvm-config or its users. The solution should be to fix the installation, not make everything more complicated. Anyway, I don't want to block the primary change with side debate, so forget this for now please.

The problem can still happen if LLVM_LINK_LLVM_DYLIB=OFF, and it would be Nice to automatically delegate to the dylib (if it exists) for external tools so things will Just Work (absent of --link-static).

Oops, I need to make a change to how ComputeLibsForComponents is called. Will do that later, fix up formatting and ping again. Thanks.

Anyway, I don't want to block the primary change with side debate, so forget this for now please.

Sure.

axw updated this revision to Diff 44078.Jan 5 2016, 7:07 PM
axw edited edge metadata.

Don't check IncludeNonInstalled when updating MissingLibs

axw updated this revision to Diff 44079.Jan 5 2016, 7:10 PM

Format

DiamondLovesYou accepted this revision.Jan 5 2016, 10:13 PM
DiamondLovesYou edited edge metadata.

LGTM

axw added a comment.Jan 6 2016, 2:43 PM

Thanks @DiamondLovesYou. @beanz, are you okay with this landing now? I'd like to get it in before the branch if possible.

beanz accepted this revision.Jan 6 2016, 2:47 PM
beanz edited edge metadata.

Yes. LGTM!

Thanks,
-Chris

This revision is now accepted and ready to land.Jan 6 2016, 2:47 PM
axw closed this revision.Jan 6 2016, 4:22 PM
axw added a comment.Jan 11 2016, 11:27 PM

I have reverted this, because it breaks if you have BUILD_SHARED_LIBS=on and we're about to branch for 3.8. I'll reapply when D15986 (or another fix) is ready to land.