Mach v0.1: Cross-platform Zig graphics
devlog.hexops.com
Mach v0.1: Cross-platform Zig graphics
1–10 of 48 posts
Re: Mach v0.1: Cross-platform Zig graphics
#2Why is zig often mentionned in that context ? it seems that cross-compilation and C can be achieved using llvm/clang without a lot of problem ? What is zig accomplishing in that matter that makes it so special ?
Re: Mach v0.1: Cross-platform Zig graphics
#3i'm following zig's project from HN and i often see cross-compilation and c/c++ mentionned. Why is zig often mentionned in that context ? it seems that cross-compilation and C can be achieved using llvm/clang without a lot of problem ? What is zig accomplishing in that matter that makes it so special ?
[1] https://ziglang.org/learn/overview/#zig-is-also-a-c-compiler
Re: Mach v0.1: Cross-platform Zig graphics
#4> slugging through the depths of hell where only a footnote from Raymond Chen himself will save you
The behavior is well documented: https://docs.microsoft.com/en-us/cpp/build/x64-calling-conve...
the caller must allocate memory for the return value and pass a pointer to it as the first argument. The remaining arguments are then shifted one argument to the right. The same pointer must be returned by the callee in RAX
Re: Mach v0.1: Cross-platform Zig graphics
#5Re: Mach v0.1: Cross-platform Zig graphics
#6i'm following zig's project from HN and i often see cross-compilation and c/c++ mentionned. Why is zig often mentionned in that context ? it seems that cross-compilation and C can be achieved using llvm/clang without a lot of problem ? What is zig accomplishing in that matter that makes it so special ?
Re: Mach v0.1: Cross-platform Zig graphics
#7i'm following zig's project from HN and i often see cross-compilation and c/c++ mentionned. Why is zig often mentionned in that context ? it seems that cross-compilation and C can be achieved using llvm/clang without a lot of problem ? What is zig accomplishing in that matter that makes it so special ?
Best place to read more is probably on the Zig project website, specifically this section[1] on how/why Zig's compiler is also a C compiler and the benefits that provides. [1] https://ziglang.org/learn/overview/#zig-is-also-a-c-compiler
---
I will resist making the obvious reference despite having said both "launch" and "zig" in the same sentence.
Re: Mach v0.1: Cross-platform Zig graphics
#8Good article, 1 comment, still. > slugging through the depths of hell where only a footnote from Raymond Chen himself will save you The behavior is well documented: https://docs.microsoft.com/en-us/cpp/build/x64-calling-conve... the caller must allocate memory for the return value and pass a pointer to it as the first argument. The remaining arguments are then shifted one argument to the right. The same pointer must…
So either there's some extra COM consideration I'm not aware of, or there's a serious confusion in how calling conventions work. If someone returns an aggregate, what option do you have other than a pointer? If it's a callee-allocated pointer, what are the lifetime rules and how do you free it? Passing caller-allocated storage is the obvious answer and is far from unusual, or undocumented.
The difference I can tell between the MSVC and Itanium C++ ABIs is just that MSVC uses "this, ret" order for methods, and Itanium uses "ret, this". There's probably some subtle differences in what constitutes "non-trivial" between the two ABIs as well.
Re: Mach v0.1: Cross-platform Zig graphics
#9i'm following zig's project from HN and i often see cross-compilation and c/c++ mentionned. Why is zig often mentionned in that context ? it seems that cross-compilation and C can be achieved using llvm/clang without a lot of problem ? What is zig accomplishing in that matter that makes it so special ?
zig cc uses clang under the hood, and Zig the language is also mostly based on LLVM, but zig cc ships a lot of versions of libc to ensure that it can properly compile to all platforms without weird linker errors.
Re: Mach v0.1: Cross-platform Zig graphics
#10i'm following zig's project from HN and i often see cross-compilation and c/c++ mentionned. Why is zig often mentionned in that context ? it seems that cross-compilation and C can be achieved using llvm/clang without a lot of problem ? What is zig accomplishing in that matter that makes it so special ?
TL;DR the hardest part of cross compilation is usually getting the tool gains set up to do so. Zig ships a bunch of libc's in a lightweight compressed format which makes cross compilation completely trivial, it handles most of the work behind the scenes.