Skip to content

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

Open
@eddyb

Description

@eddyb

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generationA-metadataArea: Crate metadataA-proc-macrosArea: Procedural macrosT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions