Skip to content

Are the CARGO_CFG_* environment variables safe to use in build scripts?Β #4302

@bluetech

Description

@bluetech

Cargo exposes some CARGO_CFG_* environment variables to build scripts. Here are the ones from my machine:

CARGO_CFG_TARGET_FEATURE=sse,sse2
CARGO_CFG_TARGET_ENV=gnu
CARGO_CFG_TARGET_VENDOR=unknown
CARGO_CFG_TARGET_HAS_ATOMIC=16,32,64,8,ptr
CARGO_CFG_TARGET_THREAD_LOCAL=
CARGO_CFG_TARGET_ENDIAN=little
CARGO_CFG_TARGET_ARCH=x86_64
CARGO_CFG_UNIX=
CARGO_CFG_TARGET_POINTER_WIDTH=64
CARGO_CFG_DEBUG_ASSERTIONS=
CARGO_CFG_TARGET_OS=linux
CARGO_CFG_TARGET_FAMILY=unix

In my case, I want to use them instead of manually parsing $TARGET. It'd be better since I could use the same type of cfg conditions in the build script as in the code.

But these variables are not documented in http://doc.crates.io/environment-variables.html. Should they be? Or are they meant for internal use only and should not be relied upon?

Thanks.

(This was briefly mentioned in rust-lang/rfcs#2048 (comment)).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions