OPERATING SYSTEMSOS Linux

Zig as a Multi-OS Build System (with Loris Cro)

The ZigLang team have put an astonishing amount of effort into making Zig work an effective tool for compiling C across different architectures. Work that benefits the Zig language, but also has a chance to benefit languages like Python and Rust. Or indeed, any language that uses native C libraries somewhere in its stack.

So this week we’re joined by Loris Cro of the Zig team to dive into how you make a reliable, cross-platform toolchain that can compile C anywhere it finds it. And in doing so, 

Zig Homepage: https://ziglang.org/
Zig on Github: https://github.com/ziglang/zig
MingW for Windows: https://www.mingw-w64.org/
All Your Codebase: https://allyourcodebase.com/
Ziglang on PyPi: https://pypi.org/project/ziglang/
Shout out to Whitequark: https://pypi.org/user/whitequark/
Darling: https://www.darlinghq.org/
WineHQ: https://www.winehq.org/
PyPi Stats: https://pypistats.org/packages/__all__
The Zine static site generator: https://zine-ssg.io/
The Zine source code: https://github.com/kristoff-it/zine

Loris’ website: https://kristoff.it/
Kris on Mastodon: http://mastodon.social/@krisajenkins
Kris on LinkedIn: https://www.linkedin.com/in/krisjenkins/
Kris on Twitter: https://twitter.com/krisajenkins

0:00 Intro
3:17 How Zig’s Solving A Python Problem
15:53 Bundling the Whole C Toolchain
25:20 Making Linking Portable
36:23 Cross Platform Compilation & CI
48:08 The Language is the Build Tool
1:09:20 Would You Use Zig Just As A Build Language?
1:13:16 A Static Site Generator in Zig
1:17:38 Outro

source

by Developer Voices

linux foundation

26 thoughts on “Zig as a Multi-OS Build System (with Loris Cro)

  • Last time I looked at the pypi stats, the data were hosted in a Google BigQuery data set.

  • what are the latest projects that are being written in Zig? can anyone point me towards them?

  • 25:35 that has been long solved on posix systems by using pkg-config. Just ask pkg-config for a library name and it gives you all of the compile flags to use and include header paths (including the ones needed by that packages dependencies, recursively). All c/c++ build systems support pkg-config (including zig).

  • I see zig everywhere, so I'm curious now. I code in JS and some Python for a living. Do I need to learn C before learning Zig?

  • Kris, your channels are the opposite of tech-influencer memes. I always come away having learned something and with other things to read more about.

  • Another great interview! It was so valuable to learn how Zig prioritizes building in a sane way on the world of static/compiled programs. I'm dealing with Python + C dependency issues as I was listening to this… gotta give Zig another try.

  • I LOVE the idea of Zig, comptime, and its C compilation superpowers… But I've bounced off it HARD twice as a Windows user because it requires workarounds on Windows for things that are fine on Linux and Mac, and that's at the learning stage — examples in tutorials and documentation. I'm SO on-board when it's resolved those things.

  • I'm not a Zig developer in any way, but I like C and I write a lot of code in it.
    I think that the problem stated is not about C and the pain of building C, but mostly about the complexity that operating systems provide, which often limits one's ability to compile/build projects. The fact that some operating systems doesn't ship with a C compiler seems so stupid to me.
    However, I'm not stating that C is perfect, and I think that Zig could be a great successor, maybe even better than Rust.

  • I don't get how can you run Windows or MacOS linker on Linux though even if you have it packaged since the linker itself is a windows/macos app not a linux app?

  • 5:18 C programmers will instantly disagree with you
    No. i think using C libraries from python with pip is easier than trying to configure and build C libraries yourself. Especially if you write C on windows, where there is no system package manager, when you do not use Visual Studio, where the configure shell scripts don't run, where there is no standard location where C libraries should be installed to, where the MSVC compiler and linker live in weird directories and are not on path.

    Basically the only C libraries that are easy to integrate into your C project are header-only. Especially when you want to also build for weird targets e. g. WebAssembly and so on.

  • Loris is absolutely right about python democratizing access to C libraries.

  • Many people would agree that the Zig proyect is aiming to achieve great things in system's development, perhaps the most visionary. And many more would agree that 'echo' is a better for the Developer Voices entrance, the most humanly resounding software channel on Earth. Just sayin 🙂

  • This is has quickly turned into my favorite tech podcast. The only "issue" I have is that after every episode I feel like switching programming language 😋

  • zig zigged my threads so I am zaggin the std

  • Why a language designer want to be strict with line endings ? What's so special on it ? Is there any benefit in doing that ?

  • This came out at the perfect time. I am trying to compile an open source game project written in C and I've felt like I've been banging my head against a wall lol

  • Recently got into zig after seeing so much of it online, did the whole ray tracing in a weekend thing and I'm loving every bit of it.

  • I'm experiencing those compiling issues right now! I wanted to cross compile an SDL2 program using SDL_gfx to Windows and I can't get the SDL_gfx to compile.
    I'm thinking of replacing that functionality with my own implementation, love C but getting to compile things is definitely a challenge.

  • Great introduction. Dealing with a C/C++ library will never not seem daunting. Even being packaged by my distro won't guarantee that it will play nicely with my current project and the build system I'm using there. So it's usually down to building it myself and lord help me if I need to make any modifications there!
    Zig is making bold statements about being the last build system you'll ever need, so It's definitely on my radar in that regard. Can't wait to dive into this episode and see what Zig has to offer and where it's headed!

  • I should really try Zig some more, been using Odin for a while but the lack of cross platform compiling/linking and well the lack of some more niche platforms like Cortex M7 has driven me back to C 😅. Maybe Zig is the answer I've been looking for although the build system is still a huge mystery to me

  • Can’t get enough Zig! Thanks for the new episode 🎉

Comments are closed.