27 ms·
> Take a moment to appreciate what just happened here - I downloaded a Windows build of Zig, ran it in Wine, using it to cross compile for Linux, and then ran t
by krate 7y ago
> Take a moment to appreciate what just happened here - I downloaded a Windows build of Zig, ran it in Wine, using it to cross compile for Linux, and then ran the binary natively. Computers are fun!
Even though it probably doesn't qualify this is pretty close a Canadian Cross, which for some reason is one of my favorite pieces of CS trivia. It's when you cross compile a cross compiler.
https://en.wikipedia.org/wiki/Cross_compiler#Canadian_Cross https://en.wikipedia.org/wiki/Cross_compiler#Canadian_Cross
> The term Canadian Cross came about because at the time that these issues were under discussion, Canada had three national political parties.
- catblast 7y agoIn what way is this even close? What are the three targets in this case? It simply isn’t relevant at all.
- halotrope 7y agoIt is tangentially relevant CS-Trivia. I found it to be interesting and fun. The only think completely useless is unfortunately your comment.
- cxr 7y agoYou wrote: > this is pretty close a Canadian Cross And on that point, your correspondent is right. The two bear no real resemblance to each other. The cross compilation approach described in the article is not something to be held in high regard. It's the result of poor design. It's a lot of work involving esoteric implementation details to solve a problem that the person using the compiler should never have encountered in the first place. It's exactly the problem that the Zig project leader is highlighting in the sticker when he contrasts Zig with Clang, etc. The way compilers like Go and Zig work is the only reasonable way to approach cross compilation: every compiler should already be able to cross compiler.
- bregma 7y agoGo doesn't cross compile: it only supports the Go operating system on a very limited number of processors variants. If zig were to truly cross compile for every combination of CPU variant and supported version of every operating system, it would require terabytes of storage and already be out of date.
- matthewbauer 7y agoIt doesn't require nearly as much storage as you think. For zig, there's only 3 standard libraries (glibc, musl, mingw) and 7 unique architectures (ARM, x86, MIPS, PowerPC, SPARC, RISC-V, WASM). LLVM can support all of these with a pretty small footprint and since the standard libraries can be recompiled by Zig, it really only needs to ship source code - no binaries necessary.
- bregma 7y agoIf it's only supporting two OS runtimes and a small subset of hardware it's mostly just a curiosity.
- trasz 7y agoThe problem with cross compilation isn’t the compiler, it’s the build system. See eg the autoconf, which builds test binaries and then executes them, to test for availability of strcmp(3).
- yellowapple 7y agoI feel like there should be a more sane way to test for the availability of strcmp than to build and run a whole executable and see if it works. The sheer number of things autoconf does even for trivial programs has always been baffling to me.
- rbonvall 7y agoThanks for putting it this way. I always wondered why cross compilation was a big deal. For me it sounds like saying "look, I can write a text in English without having to be in an English-speaking country!".
- tzjmetron 7y agoTerribly random naming.