this post was submitted on 29 Jul 2023
13 points (81.0% liked)
Programming
17326 readers
220 users here now
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Rules
- Follow the programming.dev instance rules
- Keep content related to programming in some way
- If you're posting long videos try to add in some form of tldr for those who don't want to watch videos
Wormhole
Follow the wormhole through a path of communities [email protected]
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
“Clang and GCC cannot do this” this is such a dishonest claim. A certain clang distribution he tried “couldn’t do it”, but that does not mean that clang in general can’t cross-compile. In fact, the reason zig can is LLVM itself. You can build a custom distribution with all your favorite targets from clang (just like you can build a whole compiler for a new language).
The magical thing here are C header files. While it is certainly possible to crosscompile using traditional tooling, what zig does here is an all-in-one package that lets you cross-compile not only to a different architecture, but a different libc or operating system. Most impressive is it's support for selecting target glibc version.
Actually there was some effort (I think currently on halt) to make those headers usable outside of zig. So yeah, it's not a thing that is (or rather must be) zig specific, but right now zig is the only language that does that AFAIK