Target-lexicon

Decode and represent LLVM target triples in Rust with a typed, queryable Triple struct.

Library
Cargo
v0.13.5
59stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
44/100Fair
Development Activity44
Maintenance8
Community52
Maturity60
Momentum12

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
79/100Good
Architecture80
Code Quality82
Innovation74
Learning Curve78

Target-lexicon is a small, foundational Rust library for managing compilation targets. Its core feature is decoding LLVM “triples” — the strings like x86_64-unknown-linux-gnu that identify a target configuration — into a strongly typed Triple struct with enums for architecture, vendor, operating system, environment, and binary format.

Maintained by the Bytecode Alliance and depended on by Cranelift, Wasmtime, and much of the Rust compiler-tooling ecosystem, it lets tools parse, construct, and inspect targets without hand-rolling string matching. Triple implements FromStr and Display for round-tripping, exposes host constructors, and answers queries about endianness, pointer width, and binary format.

What You Get

  • A typed Triple struct with enums for architecture, vendor, OS, environment, and binary format
  • FromStr and Display implementations for parsing and printing conventional triple strings
  • host() constructors that produce a Triple describing the current build host
  • Query helpers for endianness, pointer bit width, and binary format
  • Partial compatibility with the triples used by rustc and rustup

Common Use Cases

  • Parsing a target triple string into structured fields inside a compiler backend
  • Constructing a host Triple to configure code generation for the current machine
  • Querying endianness or pointer width to make target-dependent codegen decisions
  • Round-tripping between the string and typed representation of a target in build tooling

Under The Hood

Architecture - The crate is deliberately small: triple.rs defines the central Triple struct and its parsing/display logic, targets.rs holds the large enums (Architecture, Vendor, OperatingSystem, Environment, BinaryFormat) and their string mappings, data_model.rs derives properties like pointer width and endianness, host.rs provides host-detection constructors, and parse_error.rs defines the error types surfaced by FromStr.

Tech Stack - Pure Rust with a minimal dependency footprint, built as a standard Cargo crate. It uses serde optionally for (de)serialization and relies on generated/hand-maintained tables for the target enums; there is no build-script code generation beyond ordinary crate compilation.

Code Quality - The code is compact and stable, with unit tests across four files exercising parsing round-trips and host detection. Because the API surface is narrow and the enums are exhaustive, the crate is easy to audit despite low recent commit activity — its maturity, not neglect, explains the slow cadence.

API Design - The public API is ergonomic and discoverable: parse with "...".parse::<Triple>(), print with Display, build the host with Triple::host(), and query properties via straightforward methods. Naming closely mirrors LLVM’s own triple vocabulary, so users familiar with target triples need almost no ramp-up.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search