Skip to content

Environment variable to identify the library name #11966

@azam

Description

@azam

Problem

Cargo allows for building libraries having different name than the crate name (name field on [package]) via the name field on [lib], such as given the following manifest, crate name will be goodname but built library will be named libothername.so or so.

[packege]
name = "goodname"
version = "0.1.0"
edition = "2021"

[lib]
name = "othername"
crate-type = ["cdylib"]

For binaries, we have CARGO_BIN_NAME being populated with similar target name for binary on tests etc, but we do not have the equivalent of it for libraries, thus my request is to have CARGO_LIB_NAME, or any suitable variable name that will be populated with the target library name, having same behavior as CARGO_BIN_NAME.

Proposed Solution

Add an env var CARGO_LIB_NAME to be populated with the value set on name field on [lib], if set or default to package name.

Notes

Ref:

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-environment-variablesArea: environment variablesC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-needs-team-inputStatus: Needs input from team on whether/how to proceed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions