Hacking vs Feature Request to Compiler
Hacking vs Feature Request to Compiler
Posted Oct 11, 2024 19:03 UTC (Fri) by rywang014 (subscriber, #167182)Parent article: FFI type mismatches in Rust for Linux
Something I can think of: mark the helpers.o symbols as "inline only". When linking: any objects referencing those symbols are force-LTO'ed; and after all linkings, delete those text and symbols.
Posted Oct 12, 2024 2:20 UTC (Sat)
by garyguo (subscriber, #173367)
[Link] (1 responses)
From LLVM IR level, inlinehint + linkonce_odr is essentially what you have described. It gets inlined during LTO, and unused functions get deleted without codegen functions get discarded without codegen. If LLVM heurstics decides not to inline something, the function gets emitted with weak linkage (if one doesn't want the heurstics, then replace inlinehint with alwaysinline).
It's just you cannot tweak clang to generate this combination. It was attempted previously: https://reviews.llvm.org/D18095, but it was rejected and the advice is keep post-processing IR.
Posted Oct 13, 2024 4:10 UTC (Sun)
by rywang014 (subscriber, #167182)
[Link]
Hacking vs Feature Request to Compiler
Hacking vs Feature Request to Compiler
