Skip to content

Commit 1883fbb

Browse files
committed
rust: Rust-ABI dynamic libraries do not support LTO
Attempting to use LTO on e.g. a procedural macro crate fails with error: lto cannot be used for proc-macro crate type without -Zdylib-lto Do not return -Clto for such crate types. Signed-off-by: Paolo Bonzini <[email protected]>
1 parent c094151 commit 1883fbb

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

mesonbuild/compilers/rust.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,9 @@ def get_embed_bitcode_args(self, bitcode: bool, lto: bool) -> T.List[str]:
367367

368368
def get_lto_compile_args(self, *, target: T.Optional[BuildTarget] = None, threads: int = 0,
369369
mode: str = 'default') -> T.List[str]:
370+
if target.rust_crate_type in {'dylib', 'proc-macro'}:
371+
return []
372+
370373
# TODO: what about -Clinker-plugin-lto?
371374
rustc_lto = 'lto=thin' if mode == 'thin' else 'lto'
372375
return ['-C', rustc_lto]

0 commit comments

Comments
 (0)