Skip to content

Incorrect Environment Variable/Config Logic #773

@Alexhuszagh

Description

@Alexhuszagh

Checklist

Describe your issue

The code for parsing some environment variable logic (for example, xargo) is as follows:

    pub fn xargo(&self, target: &Target) -> Result<Option<bool>> {
        let (build_xargo, target_xargo) = self.env.xargo(target);
        let (toml_build_xargo, toml_target_xargo) = if let Some(ref toml) = self.toml {
            toml.xargo(target)
        } else {
            (None, None)
        };

        match (build_xargo, toml_build_xargo) {
            (Some(xargo), _) => return Ok(Some(xargo)),
            (None, Some(xargo)) => return Ok(Some(xargo)),
            (None, None) => {}
        };

        match (target_xargo, toml_target_xargo) {
            (Some(xargo), _) => return Ok(Some(xargo)),
            (None, Some(xargo)) => return Ok(Some(xargo)),
            (None, None) => {}
        };
        Ok(None)
    }

This means that if build.env.xargo = true, or CROSS_BUILD_XARGO, these will override the settings present in target.$(...).env.xargo and CROSS_TARGET_$(...)_XARGO. We should prefer more specific to less specific: if someone wants to enable xargo for all but a single target, it should respect that.

For example:

[build.env]
xargo = true

[target.aarch64-unknown-linux-gnu.env]
xargo = false

This means we should use xargo for all targets but aarch64-unknown-linux-gnu, but we currently use it for all targets.

What target(s) are you cross-compiling for?

No response

Which operating system is the host (e.g computer cross is on) running?

  • macOS
  • Windows
  • Linux / BSD
  • other OS (specify in description)

What architecture is the host?

  • x86_64 / AMD64
  • arm32
  • arm64 (including Mac M1)

What container engine is cross using?

  • docker
  • podman
  • other container engine (specify in description)

cross version

cross 0.2.1 (ee2fc1b 2022-06-09)

Example

No response

Additional information / notes

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-configArea: cross-toml configbug

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions