Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rust-analyzer's complaint about not finding proc macro library #918

Closed
wants to merge 1 commit into from

Conversation

vtta
Copy link

@vtta vtta commented Oct 18, 2022

The generated rust-project.json contains:

      {
            "cfg": [],
            "deps": [],
            "display_name": "macros",
            "edition": "2021",
            "env": {
                "RUST_MODFILE": "This is only for rust-analyzer"
            },
            "is_proc_macro": true,
            "is_workspace_member": true,
            "proc_macro_dylib_path": "rust/libmacros.so",
            "root_module": "***/rust/macros/lib.rs"
        },

If we use this file in an out-of-tree module to let rust-analyzer index symbols it will complain about not finding proc macro library
image

Make proc_macro_dylib_path absolute fix this issue.

Fix rust-analyzer's complaint about not finding proc macro library
@@ -65,7 +65,7 @@ def append_crate(display_name, root_module, deps, cfg=[], is_workspace_member=Tr
[],
is_proc_macro=True,
)
crates[-1]["proc_macro_dylib_path"] = "rust/libmacros.so"
crates[-1]["proc_macro_dylib_path"] = str((objtree / "rust/libmacros.so").resolve(True))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is .resolve() necessary?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, during my testing, objtree sometimes is empty, the reason is unknown.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In which case is it empty where you need absolute paths?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as shown here
image

Copy link
Author

@vtta vtta Oct 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In which case is it empty where you need absolute paths?

After I copied the generated rust-project.json from build tree to my out-of-tree module directory, the complaint will show up.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You did have to run this script for your out of tree module rather than copying the in-tree rust-project.json file anyway to handle the out of tree module itself, right?

Copy link
Author

@vtta vtta Oct 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory yes, but currently the kernel Makefile does not support calling it in module directory with make -C <path-to-build-root> M=<path-to-module> rust-analyzer

Maybe I will add that support later

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, #914 would add support for this AFAICT. Looks like it also fixes proc macros.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I didn't notice that one. Then I will close this.

@vtta vtta closed this Oct 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants