Skip to content

Commit 1ddbf2e

Browse files
nertpinxdcbaker
authored andcommitted
rust: Fix dependency on proc macro crates
When building a proc-macro crate the build target is actually a shared library target. The resulting library (the .so file directly) is used in the targets that depend on it. But being a shared object there are symbols extracted from it and the symbols file is the actual file recorded as the dependency. When another crate uses a macro from the first crate, being dependent on the symbols file it means that if the macro _implementation_ changes, but symbols stay the same, the symbol extractor does not rewrite the symbols file and nothing else gets rebuilt. That would be fine when it comes to classic shared library, but due to the fact that the shared library is used by the compiler (just like a gcc plugin or another compiler plugin) the result does not change only based on the symbols, but also based on the implementation. Therefore if the target in the dependency is a proc-macro crate, instead of depending on the symbols file, depend on the shared object filename. With this change, when a macro implementation changes in a proc-macro crate, all crates using that macro will be rebuilt. Signed-off-by: Martin Kletzander <[email protected]>
1 parent bc039fa commit 1ddbf2e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

mesonbuild/backend/ninjabackend.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3752,7 +3752,10 @@ def generate_link(self, target: build.BuildTarget, outname, obj_list, linker: T.
37523752

37533753
def get_dependency_filename(self, t):
37543754
if isinstance(t, build.SharedLibrary):
3755-
return self.get_target_shsym_filename(t)
3755+
if t.uses_rust() and t.rust_crate_type == 'proc-macro':
3756+
return self.get_target_filename(t)
3757+
else:
3758+
return self.get_target_shsym_filename(t)
37563759
elif isinstance(t, mesonlib.File):
37573760
if t.is_built:
37583761
return t.relative_name()

0 commit comments

Comments
 (0)