Summary
We propose forming a new working group within the LLVM project dedicated to solving the challenges of linking massive binaries in LLD. The group would provide a platform for discussing cross-cutting concerns around relocation overflows, and modifications to the x86-64 ABI via code-models such as range-extension thunks.
Rationale
At Meta, our code-base continues to grow and we predominantly chose to statically link code. We are increasingly running into relocation overflows as a result as we’ve defaulted to the small code-model for performance. While the current x86-64 large code model prevents these overflows, it introduces performance penalties that make it a non-starter for our critical workloads.
We seek a solution that produces efficient instruction sequences when possible and employ other well known techniques (i.e. thunks) for when code breaches beyond certain limits – “pay as you go”.
Engineers from Meta and Google have already put forward to similar RFC to the x86-ABI community (please see matching threads for current discussion)
-
Google’s RFC: Redefining the Large Code Model
-
Meta’s RFC: Solving Relocation Overflow with Medium Code Model and Layout Optimization
Aside:
If I were to be frank, the RFCs are similar enough but where they diverge, it looks like Google’s (Arthur) RFC has more current support. The difference doesn’t matter to me as much as they both attempt to solve the problem in a similar enough fashion so I’m in support of it as well.
Outcome
The outcome of the working group will be to build binaries of any size with performance penalty only for code that breaches 2GiB boundary. We believe that with post-link optimization (BOLT & Propeller), that we can keep the hottest code within this boundary.
In Scope
- Changes to glibc to support multiple RELRO
- Changes to coreutils to support multiple GOT
- Changes to lld where necessary
- Changes to llvm where necessary
- Changes to the x86-64 ABI
Who is Involved So Far
So far, the conversation includes engineers from Meta and Google.
Organizational Details
-
Regular Meetings: We propose scheduling at a minimum, a monthly meeting for 1 hour to discuss designs, share prototype results, and track upstreaming progress.
-
Communications: We will keep public meeting notes and can use Discourse for major updates.
Call to action
Let me know if you would be interested in joining. I could not find much public discourse on binaries that breach 2GiB.
Looking forward to the discussion!
(I have modeled this post after RFC: Forming a Static Analysis Working Group in the Clang Ecosystem )
