Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add documentation on platform 'triple's, example usages #11398

Closed
kevinushey opened this issue Nov 21, 2022 · 10 comments · Fixed by #11603
Closed

docs: add documentation on platform 'triple's, example usages #11398

kevinushey opened this issue Nov 21, 2022 · 10 comments · Fixed by #11603
Assignees
Labels
A-documenting-cargo-itself Area: Cargo's documentation C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` E-easy Experience: Easy

Comments

@kevinushey
Copy link

kevinushey commented Nov 21, 2022

Problem

Primarily related to https://doc.rust-lang.org/cargo/reference/config.html.

I believe it would be helpful if that page included:

  • A brief discussion of what a platform 'triple' is, or a link to a document with such a description;
  • Some instructions on how one can figure out the 'triple' for their host machine, or other potential targets.

Proposed Solution

Perhaps a small section could be added immediately after https://doc.rust-lang.org/cargo/reference/config.html#configuration-format. Here's a short draft:

Platform Triples

Platform-specific compiler and linker flags can be specified as part of [target.<triple>] configuration entries in config.toml. Here, <triple> refers to a Target Triplet. It has the form <machine>-<vendor>-<os>, and you can use:

rustc -vV

to infer your machine's platform triple, which is printed as part of the host: field.

Notes

I'm making this as an issue first just to confirm whether this feels like a worthwhile change; if so, I can make a PR.

@kevinushey kevinushey added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Nov 21, 2022
@weihanglo
Copy link
Member

weihanglo commented Nov 21, 2022

Thanks for the report!

Target triple has its own place in the appendix. Cargo also mentions target triple in the manual of each build command, such as cargo build. And in the chapter "Specifying Dependencies" as well.

We may want to refer to the appendix, but I am not sure where to add and what is the right amount of doc to add. Maybe put a reference under [target] key? I am not sure either.

@weihanglo weihanglo added the A-documenting-cargo-itself Area: Cargo's documentation label Nov 21, 2022
@kevinushey
Copy link
Author

Thank you for pointing that out! I like the idea of adding a link to the target triple section in the appendix.

Maybe the simplest answer here is to add a sentence after the example configuration in https://doc.rust-lang.org/cargo/reference/config.html#configuration-format, with something like:

See Target in the glossary for more details on target triples.

@weihanglo weihanglo added the E-easy Experience: Easy label Jan 12, 2023
@jofas
Copy link
Contributor

jofas commented Jan 18, 2023

@rustbot claim

@jofas
Copy link
Contributor

jofas commented Jan 18, 2023

#### `[target]`
The `[target]` table is used for specifying settings for specific platform
targets. It consists of a sub-table which is either a platform triple or a
[`cfg()` expression]. The given values will be used if the target platform
matches either the `<triple>` value or the `<cfg>` expression.

I'd suggest making <triple> a link to the target section of the glossary. We could do this for every occurrence of <triple> on this page. Do you agree that this would be enough to clarify what target triples are?

@weihanglo
Copy link
Member

I think that is sufficient, despite that you cannot link to Target Triple directly 🥲. We could also update other pages mentioning that if possible.

(Except --target in build command manual I guess. They already got enought information).

@jofas
Copy link
Contributor

jofas commented Jan 19, 2023

### Target
The meaning of the term *target* depends on the context:
- **Cargo Target** — Cargo [*packages*](#package) consist of *targets* which
correspond to [*artifacts*](#artifact) that will be produced. Packages can
have library, binary, example, test, and benchmark targets. The
[list of targets][targets] are configured in the `Cargo.toml`
[*manifest*](#manifest), often inferred automatically by the [directory
layout] of the source files.
- **Target Directory** — Cargo places all built artifacts and intermediate
files in the *target* directory. By default this is a directory named
`target` at the [*workspace*](#workspace) root, or the package root if not
using a workspace. The directory may be changed with the `--target-dir`
command-line option, the `CARGO_TARGET_DIR` [environment variable], or the
`build.target-dir` [config option].
- **Target Architecture** — The OS and machine architecture for the built
artifacts are typically referred to as a *target*.
- **Target Triple** — A triple is a specific format for specifying a target
architecture. Triples may be referred to as a *target triple* which is the

Couldn't we convert the list in the glossary to <h4> subsections with #### in order to link to them? The depth is supported by mdbooks, as seen in the snippet I posted above:

#### `[target]`

@weihanglo
Copy link
Member

Could try that. Just list item feels more natural to me with the surrounding context.

@jofas
Copy link
Contributor

jofas commented Jan 19, 2023

True. Also the Target section in the glossary is not that long to begin with. I'll start working on a PR where I add links to occurrences of triple or host triple inside the src/doc/src/ directory (except to the --target option of the cargo build command).

bors added a commit that referenced this issue Jan 22, 2023
[Doc]: Added links to the `Target` section of the glossary for occurences of `target triple`

Fix for #11398. #11398 raises the concern that it isn't always abundantly clear in the cargo book, what a `target triple` (i.e. `x86_64-unknown-linux-gnu`) is. This is unfortunate, as it is well described in the [glossary](https://doc.rust-lang.org/cargo/appendix/glossary.html#target) of the cargo book (including the command on how to get all targets supported by `rustc`). To mitigate this problem I added links to the glossary entry for target triples to the sections where triples are referenced, but not enough information is given on what they are and how they look like.
@weihanglo
Copy link
Member

I believe #11603 fixes this. Close it now. Thank you everyone for participating in the discussion and fix!

@kevinushey
Copy link
Author

Thanks everyone! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-documenting-cargo-itself Area: Cargo's documentation C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` E-easy Experience: Easy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants