The current LLVM-C/Ocaml linker API is very slow when linking many files
together. This patch exposes and additional API that does not destroy
the Linker object between each linking call.
Details
- Reviewers
deadalnix CodaFi whitequark hiraditya
Diff Detail
- Repository
- rL LLVM
- Build Status
Buildable 35720 Build 35719: arc lint + arc unit
Event Timeline
lib/Linker/LinkModules.cpp | ||
---|---|---|
617 | Exposing them is not trivial, because I would have to introduce new types for Flag and a trampoline for the callback. I removed them to be implicit and in line with LLVMLinkModules2. If you really want me to add them, I would prefer to do it as a separate diff. |
lib/Linker/LinkModules.cpp | ||
---|---|---|
617 | I realize it’s non-trivial, but our commitment to ABI compatibility makes revising these public interfaces much more difficult after the fact than getting it right up front. FWIW, the result of the internalize bindings patch you have apply here as well, and you need only provide a thunk to translate the C binding flags to the few linker flags LLVM currently supports. If you’d like, I can generate that binding and tag you in a review, then you can rebase the OCaml bindings on top. |
include/llvm-c/Linker.h | ||
---|---|---|
35 | These names should be qualified as above. typedef enum { LLVMLinkerFlagsNone = 0, LLVMLinkerFlagsOverrideFromSrc = 1, LLVMLinkerFlagsLinkOnlyNeeded = 2 } LLVMLinkerFlags; |
bindings/ocaml/linker/linker_ocaml.c | ||
---|---|---|
40 | I think the proliferation of non-reentrant/non-threadsafe functions in the API is an issue. (Right now OCaml has a global lock, but a multicore runtime is in works.) The approach in D65138 is better, but still seems error-prone to me; I'll need to take a closer look at the OCaml runtime feature to see if perhaps a better one is possible. |
bindings/ocaml/linker/linker_ocaml.c | ||
---|---|---|
40 | I would personally consider any C API function that does not take a context a (usability) bug, since the LLVM C API is primarily useful for writing bindings from other languages, most of which have some kind of closure mechanism. I think in this case it is clearly justifiable to add an LLVMLinkInModule2 that fixes this. |
bindings/ocaml/linker/linker_ocaml.c | ||
---|---|---|
40 | Ah good point, I'Il do that. Thanks |
@kren1 Do you have any objections to my suggestion of adding LLVMLinkInModule2? I think that's the only remaining issue to address.
@whitequark I think I decided to fold the functionality of LLVMLinkInModule2 into the LLVMLinkInModule. Since I'm adding the function in the first place, I thought there is no need to have the C function without those additional parameters.
Or did I misunderstand what you meant by adding the LLVMLinkInModule2?
I think the proliferation of non-reentrant/non-threadsafe functions in the API is an issue. (Right now OCaml has a global lock, but a multicore runtime is in works.) The approach in D65138 is better, but still seems error-prone to me; I'll need to take a closer look at the OCaml runtime feature to see if perhaps a better one is possible.