Skip to content

Commit 30f0d90

Browse files
committed
rust: procedural macros do not support LTO
Attempting to use LTO on a procedural macro crate fails with error: lto cannot be used for proc-macro crate type without -Zdylib-lto Automatically override -Db_lto in the rust.proc_macro method. Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 054fd1e commit 30f0d90

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

mesonbuild/modules/rust.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,8 @@ def proc_macro(self, state: ModuleState, args: T.Tuple[str, SourcesVarargsType],
497497
kwargs['native'] = MachineChoice.BUILD
498498
kwargs['rust_crate_type'] = 'proc-macro'
499499
kwargs['rust_args'] = kwargs['rust_args'] + ['--extern', 'proc_macro']
500+
kwargs.setdefault('override_options', {})
501+
kwargs['override_options']['b_lto'] = False
500502
target = state._interpreter.build_target(state.current_node, args, kwargs, SharedLibrary)
501503
return target
502504

0 commit comments

Comments
 (0)