Skip to content

build scripts: DEBUG environment variable is always "true" or "false" #16363

@jrose-signal

Description

@jrose-signal

Problem

The docs for build scripts say that OPT_LEVEL and DEBUG are set to the "values of the corresponding variables for the profile currently being built". However, this is only true for OPT_LEVEL; DEBUG is always "true" or "false":

.env("DEBUG", debug.to_string())
.env("OPT_LEVEL", &unit.profile.opt_level)

This prevents tools like cc-rs from making more fine-grained decisions about what debug info to include, which I implemented in rust-lang/cc-rs#1624 before realizing Cargo didn't actually support it.

Steps

No response

Possible Solution(s)

I would love to just change this, but of course there may be build scripts depending on the existing behavior. :-( If it is not to be changed, the docs should be adjusted to match the actual behavior.

Notes

The docs probably were correct way back in Rust/Cargo's history, when this was just a boolean option.

Version

(discovered in Cargo 1.89, but verified with code investigation in main)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-build-scriptsArea: build.rs scriptsA-documenting-cargo-itselfArea: Cargo's documentationC-bugCategory: bugS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or review

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions