Skip to content

Commit

Permalink
Make it clear in docs that we parse LLVM triples (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm authored Dec 3, 2024
1 parent 61922cd commit 2b95ffe
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "target-lexicon"
version = "0.12.16"
authors = ["Dan Gohman <[email protected]>"]
description = "Targeting utilities for compilers and related tools"
description = "LLVM target triple types"
documentation = "https://docs.rs/target-lexicon/"
readme = "README.md"
keywords = ["target", "host", "triple", "compiler", "jit"]
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
This is a library for managing targets for compilers and related tools.

Currently, the main feature is support for decoding "triples", which
Currently, the main feature is support for decoding [LLVM "triples"], which
are strings that identify a particular target configuration. They're named
"triples" because historically they contained three fields, though over time
they've added additional fields. This library provides a `Triple` struct
Expand All @@ -14,7 +14,11 @@ pointer bit width, and binary format.
And, `Triple` and the enum types have `host()` constructors, for targeting
the host.

It supports all triples currently used by rustc and rustup.
It somewhat supports reading triples currently used by `rustc` and rustup,
though beware that the mapping between `rustc` and LLVM triples is not
one-to-one.

It does not support reading JSON target files itself. To use it with a JSON
target file, construct a `Triple` using the value of the "llvm-target" field.

[LLVM "triples"]: https://clang.llvm.org/docs/CrossCompilation.html#target-triple
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Target triple support.
//! LLVM target triple types.
#![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)]
#![warn(unused_import_braces)]
Expand Down
8 changes: 6 additions & 2 deletions src/triple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ pub enum CallingConvention {
AppleAarch64,
}

/// A target "triple". Historically such things had three fields, though they've
/// added additional fields over time.
/// An LLVM target "triple". Historically such things had three fields, though
/// they've added additional fields over time.
///
/// Note that `Triple` doesn't implement `Default` itself. If you want a type
/// which defaults to the host triple, or defaults to unknown-unknown-unknown,
Expand Down Expand Up @@ -291,6 +291,10 @@ fn show_binary_format_with_no_os(triple: &Triple) -> bool {
impl FromStr for Triple {
type Err = ParseError;

/// Parse a triple from an LLVM target triple.
///
/// This may also be able to parse `rustc` target triples, though support
/// for that is secondary.
fn from_str(s: &str) -> Result<Self, Self::Err> {
if let Some(triple) = Triple::special_case_from_str(s) {
return Ok(triple);
Expand Down

0 comments on commit 2b95ffe

Please sign in to comment.