Default triple on GNU/Hurd is wrong
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Hello,
When building llvm on GNU/Hurd the `config.guess` script bundled with llvm detects the triple as `x86_64-unknown-gnu/i686-unknown-gnu` matching the triple used in gcc.
However `llvm::Triple::normalize` normalizes this to `xxxx-unknown-unknown-gnu` instead:
```
llvm-config --host-target
x86_64-unknown-unknown-gnu0.9
```
The "correct" triple would be `xxx-unknown-hurd-gnu` instead.
This seems to work for clang because there is an explicit check to correct the normalization.
```cpp
// clang/lib/Driver/Driver.cpp
// llvm::Triple computeTargetTriple():
llvm::Triple Target(llvm::Triple::normalize(TargetTriple));
// GNU/Hurd's triples should have been -hurd-gnu*, but were historically made
// -gnu* only, and we can not change this, so we have to detect that case as
// being the Hurd OS.
if (TargetTriple.contains("-unknown-gnu") || TargetTriple.contains("-pc-gnu"))
Target.setOSName("hurd");
```
When trying to build ldc for https://github.com/ldc-developers/ldc/pull/5115 this causes ldc to assume a freestanding OS instaed leading to build failures.
I am unsure how this should be fixed. In the `config.guess` or in `llvm::Triple::normalize` or somewhere else?
Thanks.
Contributor guide
Research direction
Start by comparing the bundled config.guess result with llvm::Triple::normalize and the GNU/Hurd handling in clang/lib/Driver/Driver.cpp, especially computeTargetTriple(). Reproduce the reported llvm-config --host-target output, then determine which component should recognize the GNU/Hurd triple; done means the host target is normalized consistently without breaking existing GNU triples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, shell
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 45/100