Skip to content

Direct users to crate-type=cdylib in crate-type=dylib documentation #65517

Open
@hanna-kruppe

Description

@hanna-kruppe

The dylib crate type is well known to be misleading and rarely useful (to put it politely) among rustc developers, but if a user reads about crate types in rustc --help, the reference, or the rustc book they won't get much indication of this. This probably contributes to the constant stream of users picking it or recommending it to each other when they really need cdylib. Generally this is only prevented if someone with "insider knowledge" is in the same room when the decision is made, and otherwise only corrected when something breaks and the user seeks help or files a bug report.

I still believe it would be best to deprecate the crate type entirely but since that probably involves more process and pushback, for now I propose to add a note to all the aforementioned documents that says something like:

As with lib, the file produced from a dylib crate can only be consumed by the same version of rustc and is not guaranteed to be in any particular format or contain any symbols that other programs could use. If you wish to produce a dynamic library to be loaded dynamically by Rust programs or linked against by other languages, you need to use the cdylib crate type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-FFIArea: Foreign function interface (FFI)A-frontendArea: Compiler frontend (errors, parsing and HIR)C-enhancementCategory: An issue proposing an enhancement or a PR with one.T-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