Skip to content

ring's build script shouldn't output rerun-if-env-changed for Cargo-related env vars #2454

@sunshowers

Description

@sunshowers

(Originally filed as ctz/ring#10, and ported here.)

Hi there, and thank you so much for maintaining/remaintaining ring!

Currently, ring's build script outputs a number of rerun-if-env-changed instructions (full output):

cargo:rerun-if-env-changed=CARGO_MANIFEST_DIR
cargo:rerun-if-env-changed=CARGO_PKG_NAME
cargo:rerun-if-env-changed=CARGO_PKG_VERSION_MAJOR
cargo:rerun-if-env-changed=CARGO_PKG_VERSION_MINOR
cargo:rerun-if-env-changed=CARGO_PKG_VERSION_PATCH
cargo:rerun-if-env-changed=CARGO_PKG_VERSION_PRE
cargo:rerun-if-env-changed=CARGO_MANIFEST_LINKS
cargo:rerun-if-env-changed=RING_PREGENERATE_ASM
cargo:rerun-if-env-changed=OUT_DIR
cargo:rerun-if-env-changed=CARGO_CFG_TARGET_ARCH
cargo:rerun-if-env-changed=CARGO_CFG_TARGET_OS
cargo:rerun-if-env-changed=CARGO_CFG_TARGET_ENV
cargo:rerun-if-env-changed=CARGO_CFG_TARGET_ENDIAN
cargo:rerun-if-env-changed=CC_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=CC_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_CC
cargo:rerun-if-env-changed=CC
cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
cargo:rerun-if-env-changed=CFLAGS
cargo:rerun-if-env-changed=HOST_CFLAGS
cargo:rerun-if-env-changed=CFLAGS_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=CFLAGS_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=CC_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=CC_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_CC
cargo:rerun-if-env-changed=CC
cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
cargo:rerun-if-env-changed=CFLAGS
cargo:rerun-if-env-changed=HOST_CFLAGS
cargo:rerun-if-env-changed=CFLAGS_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=CFLAGS_x86_64-unknown-linux-gnu

This causes a number of extra recompiles if a ring build is invoked via a Cargo xtask or other wrapper. For more details, see oxidecomputer/omicron#7740.

While many of these are appropriate, the ones prefixed by CARGO_ should probably not be output, I believe. Cargo's documentation says in this section:

Note that the environment variables here are intended for global environment variables like CC and such, it is not possible to use this for environment variables like TARGET that Cargo sets for build scripts. The environment variables in use are those received by cargo invocations, not those received by the executable of the build script.

I think an easy fix here is to ensure that no environment variables prefixed by CARGO_ are produced. That would correctly filter out the current list, and also likely be correct if and when the build script changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions