[LLVMdev] LLD improvement plan
Shankar Easwaran
shankare at codeaurora.org
Wed May 6 19:28:54 PDT 2015
Hi,
There are a lot of advantages to keep on improving the atom model and
working on that model.
The atom model allowed lld to have a single intermediate representation
for all the formats ELF/COFF/Mach-O. The native model allowed the
intermediate representation to be serialized to disk too. If the
intermediate representations data structures are made available to
scripting languages most of all linker script script layout can be
implemented by the end user. A new language also can be developed as
most of the users need it and it can work on this intermediate
representation.
The atom model also simplified a lot of usecases like garbage collection
and having the resolve to deal just with atoms. The section model would
sound simple from the outside but it it has its own challenges like
separating the symbol information from section information.
The atom model also simplifies testing as there is one unique/nice way
to test the core linker independent of the format.
In addition to testing, there are tools that are designed to convert ELF
to COFF or viceversa, which makes lld to support these usecases by design.
Most of all embedded users want to reduce the final image size by
compiling code using -ffunction-sections and -fdata-sections, which
makes the atom model directly model it. Thanks to Espindola for adding
support for -fno-unique-section-names which makes lld and the atom model
more useful.
lld has already proven that it can link most of our llvm tools and self
host with reasonable performance, I dont see why we dont want to
continue with the Atom model.
Atom model also eases up dealing with LTO in general.
In summary, I would like to continue the ELF ports using the Atom model.
_If a section model is being chosen to model flavors lets not mixing it
up with Atom model as I can see there would be very less code sharing._
Shankar Easwaran
On 5/4/2015 2:52 PM, Chris Lattner wrote:
> On May 1, 2015, at 12:31 PM, Rui Ueyama <ruiu at google.com> wrote:
>> Proposal
>> Re-architect the linker based on the section model where it’s appropriate.
>> Stop simulating different linker semantics using the Unix model. Instead, directly implement the native behavior.
> Preface: I have never personally contributed code to LLD, so don’t take anything I’m about to say too seriously. This is not a mandate or anything, just an observation/idea.
>
>
> I think that there is an alternative solution to these exact same problems. What you’ve identified here is that there are two camps of people working on LLD, and they have conflicting goals:
>
> - Camp A: LLD is infrastructure for the next generation of awesome linking and toolchain features, it should take advantage of how compilers work to offer new features, performance, etc without deep concern for compatibility.
>
> - Camp B: LLD is a drop in replacement system linker (notably for COFF and ELF systems), which is best of breed and with no compromises w.r.t. that goal.
>
>
> I think the problem here is that these lead to natural and inescapable tensions, and Alex summarized how Camp B has been steering LLD away from what Camp A people want. This isn’t bad in and of itself, because what Camp B wants is clearly and unarguably good for LLVM. However, it is also not sufficient, and while innovation in the linker space (e.g. a new “native” object file format generated directly from compiler structures) may or may not actually “work” or be “worth it”, we won’t know unless we try, and that won’t fulfill its promise if there are compromises to Camp B.
>
> So here’s my counterproposal: two different linkers.
>
> Lets stop thinking about lld as one linker, and instead think of it is two different ones. We’ll build a Camp B linker which is the best of breed section based linker. It will support linker scripts and do everything better than any existing section based linker. The first step of this is to do what Rui proposes and rip atoms out of the model.
>
> We will also build a no-holds-barred awesome atom based linker that takes advantage of everything it can from LLVM’s architecture to enable innovative new tools without worrying too much about backwards compatibility.
>
> These two linkers should share whatever code makes sense, but also shouldn’t try to share code that doesn’t make sense. The split between the semantic model of sections vs atoms seems like a very natural one to me.
>
> One question is: does it make sense for these to live in the same lld subproject, or be split into two different subprojects? I think the answer to that question is driven from whether there is shared code common between the two linkers that doesn’t make sense to sink down to the llvm subproject itself.
>
> What do you think?
>
> -Chris
>
>
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150506/519a74a2/attachment.html>
More information about the llvm-dev
mailing list