bytecodealliance / target-lexicon

Target "triple" support
Apache License 2.0
48 stars 42 forks source link

Make a distinction between LLVM and rustc target triples #111

Open madsmtm opened 6 days ago

madsmtm commented 6 days ago

It isn't really clear from the documentation whether this crate parses LLVM or rustc target triples, and that's probably because it tries to parse both.

This is problematic though, in particular the triple aarch64-apple-darwin is from my understanding ambiguous?

Would it make sense to say "FromStr only parses rustc triples", or "FromStr only parses LLVM triples"? Or maybe add Triple::from_llvm(&str) -> Result<Self> and Triple::from_rustc(&str) -> Result<Self>, and remove FromStr?

madsmtm commented 6 days ago

Another solution would be to rename rustc's macOS targets to *-apple-macos, which is desirable anyhow. But that's a complicated process.

madsmtm commented 6 days ago

This is also relevant for figuring out how to parse deployment targets for iOS/tvOS/watchOS/visionOS targets (since what we do here depends on what target-lexicon intends on supporting).

madsmtm commented 4 days ago

I see that this has also been discussed a bit in https://github.com/bytecodealliance/target-lexicon/issues/78.

sunfishcode commented 3 days ago

target-lexicon was written at a time when there was a combination of a lack of alternatives, and a lack of understanding on my part of the relationship between rust target names and LLVM target names.

If one only wants to work with Rust target names now, it may be better to switch to the platforms crate instead.

Perhaps this means that target-lexicon should ideally migrate to focusing only on LLVM target names.