bytecodealliance / target-lexicon

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

How should avr-unknown-gnu-atmega328 be parsed? #63

Open sunfishcode opened 3 years ago

sunfishcode commented 3 years ago

avr-unknown-gnu-atmega328 is a new target in rustc. "atmega328" isn't recognized by LLVM's Triple or GNU autotools so it's unclear how to categorize it. I posted here asking for clarification.

sunfishcode commented 3 years ago

The initial description said "This target system is gnu, as it uses the AVR-GCC frontend along with avr-binutils. The target triple ABI is 'atmega328'."

Calling gnu a "system" and putting it in the operating-system position might suggest that gnu is the operating system, however in the language of triples, gnu is already the name of an environment, and the triple format doesn't work well with names that have different meanings in different positions—some triple parsers don't support it at all. Consequently, I think it makes sense to say that gnu is the environment here, with the operating system being unknown.

That leaves the atmega328 field. The guidance is that atmega328 is not a binary format. But we don't currently have anything else in the syntax that can go after an environment.

So my current thinking is that we need to interpret atmega328 as a new syntactic concept in triples, maybe called "environment modifiers", making the full format for "triple" look like this: arch-vendor-os-env-envmodifier-binfmt. In terms of the target-lexicon API, gnu-atmega328 would be represented as a new Environment field, GnuAtmega328.