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

Consider providing an universal way to read (proc macro) dylib metadata. #79239

Open
eddyb opened this issue Nov 20, 2020 · 1 comment
Open
Labels
A-codegen Area: Code generation A-metadata Area: Crate metadata A-proc-macros Area: Procedural macros T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@eddyb
Copy link
Member

eddyb commented Nov 20, 2020

In EmbarkStudios/rust-gpu#268, I used rustc_codegen_llvm's implementation of get_dylib_metadata, in order to support proc macros, and also found out that rustc_codegen_cranelift uses the object crate for its get_dylib_metadata.
(Both the LLVM and the object-based implementation extract the .rustc section of an .so, .dll, etc.)

AFAICT, the codegen backend shouldn't really matter, for proc macros specifically, as the proc macro is compiled for the same ("host") platform executing rustc, and for which we have dlopen (or equivalent) support.

So if we trust the object crate to work for at least proc macros, we can attempt to access the dylib metadata using it (i.e. just like rustc_codegen_cranelift does), before we ask the codegen backend for a fallback implementation (which could specifically handle non-proc-macro target dylib crates).

cc @bjorn3 @khyperia @nagisa

@bjorn3
Copy link
Member

bjorn3 commented Nov 20, 2020

I think that for proc macros the universal way to read should be the only way used. For regular dylibs, I think the metadata loader from the codegen backend should still always be used, but the default implementation of get_dylib_metadata should delegate to the universal way. This would allow the codegen backend to store dylib metadata in a way that is incompatible with the universal way without overhead from first trying the universal way.

@jyn514 jyn514 added A-proc-macros Area: Procedural macros T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-metadata Area: Crate metadata A-codegen Area: Code generation labels Nov 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation A-metadata Area: Crate metadata A-proc-macros Area: Procedural macros T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants