Live data from Hacker News

What the hell is a target triple?

mcyoung.xyz

1–10 of 139 posts

Re: What the hell is a target triple?

#4
I think GCC's more-or-less equivalent to Clang's --target is called -B: https://gcc.gnu.org/onlinedocs/gcc/Directory-Options.html#in...

I assume it works with an all-targets binutils build. I haven't seen anyone building their cross-compilers in this way (at least not in recent memory).

Re: What the hell is a target triple?

#5
I did start to try to take clang's TargetInfo code (https://github.com/llvm/llvm-project/blob/main/clang/lib/Bas...) and porting it over to TableGen, primarily so somebody could actually extract useful auto-generated documentation out of it, like "What are all the targets available?"

I actually do have working code for the triple-to-TargetInfo instantiation portion (which is fun because there's one or two cases that juuuust aren't quite like all of the others, and I'm not sure if that's a bad copy-paste job or actually intentional). But I never got around to working out how to actually integrate the actual bodies of TargetInfo implementations--which provide things like the properties of C/C++ fundamental types or default macros--into the TableGen easily, so that patch is still merely languishing somewhere on my computer.

Re: What the hell is a target triple?

#7
post #4

I think GCC's more-or-less equivalent to Clang's --target is called -B: https://gcc.gnu.org/onlinedocs/gcc/Directory-Options.html#in... I assume it works with an all-targets binutils build. I haven't seen anyone building their cross-compilers in this way (at least not in recent memory).

I haven't either, probably because it would require building once per target and installing all the individual binaries.

This is one of the biggest differences between clang and GCC: clang has one binary that supports multiple targets, while a GCC build is always target-specific.

Re: What the hell is a target triple?

#8
Funny thing I found when I gave up trying to find documentation and read the LLVM source code (seems to be what happened to the author too!): there are actually five components of the triple, not four.

I can't remember what the fifth one is, but yeah... insane system.

Thanks for writing this up! I wonder if anyone will ever come up with something more sensible.

Re: What the hell is a target triple?

#10

The author's blog is a FANTASTIC source of information. I recommend checking out some of their other posts: - https://mcyoung.xyz/2021/06/01/linker-script/ - https://mcyoung.xyz/2023/08/09/yarns/ - https://mcyoung.xyz/2023/08/01/llvm-ir/

[deleted]
Post reply on HN