rust-lang / rust-lang/rfcs

Allow Cargo configuration file to set RUST_TARGET_PATH for compilation

Open
#1,700 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

T-dev-tools
Dominant language
Markdown
Stars
6.6k
Forks
1.7k
Avg merge
16h 14m
Merged PRs (30d)
1

Description

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).

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing .cargo/config configuration described in the issue and how Cargo handles RUST_TARGET_PATH. Resolve whether paths are crate-local or inherited by dependencies, and how relative and absolute paths should behave. Done means the configuration format and propagation rules are specified clearly enough for an RFC decision.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.