I'm a bit worried this is intro'ing the classic problem we have in Bazel land, where everyone is having to show up with their own sort of packaging scripts etc instead of using upstream tooling one way or another. I had the impression `zig` already has stuff like `zig cc`. Would... would `zig make` be an impossible proposition? Maybe that makes no sense.
This is something that bothers me about languages that proclaim C/C++ compat because it's almost exclusively just talking about the ABI. I will say that Zig's build system is definitely one of the better ones, just look at the sqlite3 repo: it just points to the amalgamation zip and compiles it statically, meaning you can compile it with whichever flags you want, knowing it's guaranteed to work exactly how you want.…
C/C++ projects packaged for Zig
21–30 of 44 posts
Re: C/C++ projects packaged for Zig
#22Earlier quoted context omitted.
there's a wonderful blog post about this that I wish I could find and can't. I feel like it was a github gist. The gist of it is something like: - Bazel community hits a problem with something like how npm behaves around paths - Bazel's solution is to create a patching system around paths to resolve them - rinse and repeat for every piece of tooling us "normies" are using The end result is that instead of Bazel's eff…
Ah interesting, thanks. My intuition is that npm, cargo, zig build etc are all “wrong”. And that Bazel/Buck are architecturally correct. Build systems should be polyglot by default! All these build systems and package managers that are per language are wrong. But unfortunately Bazel and Buck have a decade plus of tech debt and baggage from their corporate overlords. Internal buck is actually mostly nice. I don’t know…
Bazel uses npm/cargo/pip in most people's usage of these tools! People still use these packages managers, with random patches and tweaks (because the overall ecosystem assumes you're using them). But Bazel often includes random fixups in their own tools.
For example [0] is some patches Bazel does to node to get it to play nicely witH Bazel. In an (IMO) better world Bazel people figure out what they need, and figure out what they can get upstreamed into node to get things working.
Instead we have patches that (if you jump through the history) have been around for 6+ years
[0]: https://github.com/aspect-build/rules_js/tree/main/js/privat...
Re: C/C++ projects packaged for Zig
#23Earlier quoted context omitted.
you _can_ just tell zig build to call make (std.Build.addSystemCommand, https://ziglang.org/documentation/0.16.0/std/#std.Build.addS... ). the only benefits of an inbuilt make would be not having to install it and that it could maybe intercept calls to external compilers and replace them with `zig cc` or something similar but i get the impression that supporting nontrivial make scripts would be very hard
so then my glib question: what is the purpose of this project? It does look like for some projects it's almost entirely "just declare the dep tree" ( https://github.com/allyourcodebase/boringssl ), + the tiniest patch. But what's going on in grpc for example? Like this build file https://github.com/allyourcodebase/grpc/blob/master/build.zi... ... why is this build file in this repo? Is the grpc makefile no bueno? Eff…
the one thing i will blame zig for here is the refusal to make some system to just include all of the files in a directory (hence allyourcodebase's python scripts). it makes sense with zig's import & module system but i think it would probably be a big blocker for some projects that they'd have to manually list out every single C file in their source.
you can currently use the filesystem apis to manually walk through files in your build script, though this is discouraged and will go away with upcoming change of isolating the build script
Re: C/C++ projects packaged for Zig
#24These look more like configure snapshots for Zig's bundled Clang than full ports of build system. The HAVE_/WITH_ defines are supposed to be dynamically probed to adapt to different toolchain environments, setting them manually like that[1][2][3] could only work well for specific targets and for specific versions. [1] https://github.com/allyourcodebase/libxml2/blob/38fb69d375bc... [2] https://github.com/allyourcodeba…
that's a bygone practice from before compilers were widely capable.
Re: C/C++ projects packaged for Zig
#25Earlier quoted context omitted.
Ah interesting, thanks. My intuition is that npm, cargo, zig build etc are all “wrong”. And that Bazel/Buck are architecturally correct. Build systems should be polyglot by default! All these build systems and package managers that are per language are wrong. But unfortunately Bazel and Buck have a decade plus of tech debt and baggage from their corporate overlords. Internal buck is actually mostly nice. I don’t know…
It's not about the package managers not being polyglot. It's about, for example, witnessing that `pip install` installs binaries with absolute paths and then writing a patch _for pip_ that Bazel uses, instead of figuring out how to change upstream pip to make that a configuration bit that Bazel uses. Bazel uses npm/cargo/pip in most people's usage of these tools! People still use these packages managers, with random…
Oh interesting. Buck totally replaces cargo / pip. I think the JS story is a little messier. Not sure as I try my best to not touch JS.
Re: C/C++ projects packaged for Zig
#26Earlier quoted context omitted.
This is something that bothers me about languages that proclaim C/C++ compat because it's almost exclusively just talking about the ABI. I will say that Zig's build system is definitely one of the better ones, just look at the sqlite3 repo: it just points to the amalgamation zip and compiles it statically, meaning you can compile it with whichever flags you want, knowing it's guaranteed to work exactly how you want.…
Yeah, I tend to bail out and just use @cImport and linkSystemLibrary, for exactly this reason.
Re: C/C++ projects packaged for Zig
#27Now a C++ developer can face a problem, when he needs some thirdparty dependency and it requires Zig to be built.
Re: C/C++ projects packaged for Zig
#28These look more like configure snapshots for Zig's bundled Clang than full ports of build system. The HAVE_/WITH_ defines are supposed to be dynamically probed to adapt to different toolchain environments, setting them manually like that[1][2][3] could only work well for specific targets and for specific versions. [1] https://github.com/allyourcodebase/libxml2/blob/38fb69d375bc... [2] https://github.com/allyourcodeba…
> supposed to be dynamically probed to adapt to different toolchain environments that's a bygone practice from before compilers were widely capable.
musl libc specifically recommends using external feature detection a la autoconf, and is so opinionated about this that it refuses to add any identifying macros, like __GLIBC__.
Re: C/C++ projects packaged for Zig
#29> Clang: Zig is a full compiler toolchain and happens to also bundle all of clang.
Re: C/C++ projects packaged for Zig
#30Yet another attempt to fix the problem with 14 competing standards by introducing one more standard. Now a C++ developer can face a problem, when he needs some thirdparty dependency and it requires Zig to be built.
It is more the other way around, Zig devs need to interface with the existing C++ ecosystem, and industry standards.