Skip to content

Allow Cargo configuration file to set RUST_TARGET_PATH for compilation #1700

Open
@zmarcantel

Description

@zmarcantel

Motivation

Some projects cross-compile for multiple targets; all of which need a .json target specification. This can quickly clutter the root directory when there are numerous target specifications that are not, and cannot be, grouped alphabetically.

One solution is to move all the target specs to a separate directory, build_targets for instance. Now, however, the RUST_TARGET_PATH needs to have build_targets appended to it.

This complicates the build process as you now need to tell users to export said variable or use make or some other build system to drive Cargo.

Solution

Cargo configuration (.cargo/config) already supports a large number of options for configuring the build environment. I propose simply adding the RUST_TARGET_PATH variable to that list.

A usage example:

[build]
# append these paths to RUST_TARGET_PATH
target_path = ["build_targets/x86", "build_targets/ARM"]

Possible issues

  1. If crate Foo sets this variable, I am not sure if the variable should be isolated to only Foo, or should carry through to the crates that depend on it.
  2. Being unfamiliar with compiler internals, absolute vs. relative directories could come into play especially when considering (1).

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-dev-toolsRelevant to the development tools team, which will review and decide on the RFC.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions