`Zig Cc`: A Powerful Drop-In Replacement for GCC/Clang

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
www.influxdata.com
featured
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  • leakdice

    Monte Carlo leak diagnostic for Linux binaries

  • Right. Even in an entirely safe language you can have leaks, and valgrind is an effective way to find those leaks if you can afford the virtualisation overhead.

    If you can't afford the virtualisation overhead, and you need to find leaks you should try what Raymond Chen suggests in "The poor man's way of identifying memory leaks" (not bothering to link since Microsoft will only move it anyway, they have several times since I read it). If you are too lazy to do it by hand, or find the technique works but wish it less manual, this is what Leakdice does:

    https://github.com/tialaramex/leakdice

  • leakdice-rust

    Rust re-implementation of leakdice

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • dmd

    dmd D Programming Language compiler

  • D is taking a different approach. D is getting a builtin C compiler (called ImportC) that is a from scratch C compiler, now in prototype form.

    https://dlang.org/spec/importc.html

    It works by having an extra module called cparse.d

    https://github.com/dlang/dmd/blob/master/src/dmd/cparse.d

    which parses Standard C. The lexer and semantic routines of the D compiler are then tweaked to support C semantics. The same optimizer and code generator is used.

    As a side effect of using the D compiler's innards, ImportC can do things like handle forward references, and even execute C code at compile time!

  • libclang_rt.builtins-wasm32.a

    The missing libclang_rt.builtins-wasm32.a file to compile to WebAssembly.

  • Only for freestanding webassembly. In order to target WASI, you have to install the builtins (https://github.com/jedisct1/libclang_rt.builtins-wasm32.a), as well as the WASI libc, and fiddle with `—-sysroot`.

    Zig can target both without having to install anything else.

  • cross

    “Zero setup” cross compilation and “cross testing” of Rust crates

  • If you use the build-std nightly feature you can compile the entire standard library, even for a custom JSON target file, and it goes pretty quick. With a bit of attention that feature would be just fine at filling in the gaps in rustup’s prebuilt targets.

    But Zig’s approach isn’t actually about making everyone compile more things from scratch. It doesn’t compile libc from scratch any time you select a new target. Reading the article you can see the extreme lengths it goes to to avoid this.

    The main thing that’s missing from Rust is target-specific libc.so/etc, and an appropriate linker for every target. If you try cross compiling anything, you will soon run into this problem; your system will not have the correct target libc or an appropriate linker. You can generally only change one part of the triple before the experience starts falling apart. I can cross compile for iOS/tvOS/etc on my Mac; that’s about it.

    Zig manages to solve this for all its targets by pre-processing simplifications of the various libcs, which are then bundled into the Zig binary (as 3 very small files). It generates a useless but linkable .so file from the preprocessed files for any target on the fly. It gets you the correct libc headers. Then it uses LLD instead of making you hunt around on Ubuntu forum posts finding and downloading the correct GNU linker for your specific architecture. So you don’t link to a real libc, but you don’t have to compile one either. (Until you want to execute a binary with QEMU, but usually non-simulated target machines have a libc.so already.)

    If you’re saying this approach would be infeasible for Rust std/core, then yes obviously. It’s statically linked, you can’t get away with a fake .so file.

    But that was never really the issue. Rustc can build std’s rlib files for any target effortlessly. And yet cross compiling is still a pretty poor experience. The state of the art for Rust developers at the moment is rust-embedded/cross, which solves the same libc+linker problem that Zig does, naively, by literally using Docker and per-target Ubuntu images to download prebuilt GCC and libc packages from Apt. Basically we can do way better than that, because Zig showed us how.

    See this Dockerfile for what I mean: https://github.com/rust-embedded/cross/blob/master/docker/Do...

  • SaaSHub

    SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives

    SaaSHub logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • Uninitialized Memory: Unsafe Rust Is Too Hard

    10 projects | news.ycombinator.com | 30 Jan 2022
  • 7 Programming Languages Every Cloud Engineer Should Know in 2024!

    4 projects | dev.to | 5 Mar 2024
  • The C Bounded Model Checker: Criminally Underused

    7 projects | news.ycombinator.com | 30 Jan 2024
  • Odin Programming Language

    23 projects | news.ycombinator.com | 1 Jan 2024
  • C++ Should Be C++

    3 projects | news.ycombinator.com | 19 Dec 2023