Skip to content

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
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