For a given target triple (build-time LLVM_DEFAULT_TARGET_TRIPLE, overridden by --target=), Clang selects a clang::driver::ToolChain under
https://github.com/llvm/llvm-project/tree/main/clang/lib/Driver/ToolChains/.
ToolChain derived classes determine how to construct assembler and linker commands and influence the clang -cc1 command line.
In the past two years, we have received new ToolChain proposals:
- Hurd (present for a long time with x86-32 support; x86-64 support was new)
- Managarm
- SerenityOS
- UEFI
(Some are stalled due to limited review capacity or testing needs. When I notice new ToolChains, I try to require stricter testing requirements.
)
This post aims to establish a clearer bar for accepting new ToolChains.
In the past, some contributed ToolChains saw little use and were eventually removed (as in â D158461 [Driver] Remove unlikely-working Minix.cpp and Contiki.cpp).
A similar question was raised by @dblaikie on Managarm ([llvm] Add triples for managarm by no92 ¡ Pull Request #87845 ¡ llvm/llvm-project ¡ GitHub) about the acceptance bar.
I propose that adding a new ToolChain should come with a Discourse proposal (with a clang tag) outlining how the proposed ToolChain meets the criteria listed on Clang - Get Involved (The Clang project uses the following criteria for this evaluation:).
Note that point 3 (âspecificationâ) is not applicable. Driver behaviors donât have a good specification.
In case of apathy, what shall we do?
(If the author is interested in vendor-impacting decision, consider joining Sign in to GitHub ¡ GitHub .
That said, I suspect that most notifications are likely about diagnostics and unrelated to driver.
)
When the proposal is accepted, the patches should be split to:
- llvm: e.g. llvm/include/llvm/TargetParser/ llvm/unittests/TargetParser/
- clang: e.g. clang/lib/Driver, clang/lib/Basic/Targets, clang/test/Driver
The Hurd x86-64 patch #78065 has really good tests that can be used as an example.
I shall also mention ToolChain behaviors can be emulated without upstream code.
If you specify --target=x86_64-unknown-someunknownos, it is like --target=x86_64 and you use the Generic_ELF toolchain.
You can add -I and -L.
You can specify default arguments by customizing x86_64-unknown-someunknownos.cfg beside clang executable,
This can be used for niche ToolChains that are not accepted.