3 ms·
Is it possible for rust to optimize across crate boundaries?
by saosebastiao 11y ago
Is it possible for rust to optimize across crate boundaries?
- vhbit 11y agoYep, it's possible to enable link time optimizations.
- steveklabnik 11y agoWith LTO, yes. I always forget if #[inline] does or not.
- phildawes 11y agoYes, #[inline] works across crates
- chrismorgan 11y ago#[inline] is all about cross-crate work; inside a crate, items not marked #[inline] may still be inlined by the optimiser, but it doesn’t do cross-crate inlining without #[inline] or LTO.
- dbaupp 11y agoNot all about. It gives an inline hint to LLVM, making it inlined more eagerly (even within a single crate) than the default.
- ben0x539 11y agoAre generics not inlined when appropriate even without #[inline] or LTO?
- kibwen 11y agoYou don't need the #[inline] attribute when generics are involved, because Rust already has to cross-crate-export function metadata when generics are involved because otherwise it would be impossible to monomorphize. At that point, LLVM will inline the monomorphized functions as it deems fit.