[Lldb-commits] [PATCH] D31367: Expression: add missing linkage to RuntimeDyld component

Joerg Sonnenberger via lldb-commits lldb-commits at lists.llvm.org
Thu Mar 30 15:38:43 PDT 2017


On Thu, Mar 30, 2017 at 10:47:39PM +0200, Michał Górny wrote:
> On czw, 2017-03-30 at 21:37 +0200, Joerg Sonnenberger wrote:
> > On Thu, Mar 30, 2017 at 06:00:15PM +0000, Chris Bieneman via Phabricator wrote:
> > > ExecutionEngine headers directly reference symbols from RuntimeDyld,
> > > so we should enforce a requirement that anyone using ExeuctionEngine
> > > also link RuntimeDyld. This works today as expected for static archive
> > > builds. It is only broken with `BUILD_SHARED_LIBS`.
> > 
> > Welcome to the brave new world of newer ELF linkers. Just because a
> > library pulls in a symbol into the namespace doesn't mean you can just
> > use that symbol. They want you to explicitly specify the dependency...
> > This does happen for static archives though.
> 
> This is expected and desired. Just because some random library you're
> using is using zlib does not mean you should skip linking zlib when your
> program is using it too.

That justification never made that much sense. The linker simply does
not know whether the dependency is considered part of the ABI contract
of the library or not. Hint: the symbol lookup rules for ELF is
recursive. Having different rules for link-time vs run-time is a very
good sign that something is very fishy. But let's not get distracted.
The behavior change of GNU linkers (and anything following them) is
exactly why the original patch was correct here. Symbols from
RuntimeDyld are directly used -- as such the library should be an
explicit declared dependency. If no such reference is created, i.e. due
to not using any of the header functions references such symbols, no
such dependency is necessary. ExecutionEngine can't tell in advance.

Joerg


More information about the lldb-commits mailing list