`zig cc`: a Powerful Drop-In Replacement for GCC/Clang - Andrew Kelley - eviltoast

Through witchcraft and dark magic, Zig contains a C standard library and cross compiler for every architecture in 45 megabytes.

  • mint_tamas@lemmy.world
    link
    fedilink
    English
    arrow-up
    5
    arrow-down
    2
    ·
    1 year ago

    “Clang and GCC cannot do this” this is such a dishonest claim. A certain clang distribution he tried “couldn’t do it”, but that does not mean that clang in general can’t cross-compile. In fact, the reason zig can is LLVM itself. You can build a custom distribution with all your favorite targets from clang (just like you can build a whole compiler for a new language).

    • etewar@lemmy.blahaj.zone
      link
      fedilink
      English
      arrow-up
      4
      arrow-down
      1
      ·
      1 year ago

      The magical thing here are C header files. While it is certainly possible to crosscompile using traditional tooling, what zig does here is an all-in-one package that lets you cross-compile not only to a different architecture, but a different libc or operating system. Most impressive is it’s support for selecting target glibc version.

      Actually there was some effort (I think currently on halt) to make those headers usable outside of zig. So yeah, it’s not a thing that is (or rather must be) zig specific, but right now zig is the only language that does that AFAIK

      • mint_tamas@lemmy.world
        link
        fedilink
        English
        arrow-up
        3
        ·
        1 year ago

        Like I said - you can build a distribution of LLVM with your favorite targets, including sysroots and have it cross compile with ease (or you can download toolchains that others built). What zig does is not special and it is highly misleading (and needlessly contrarian) to claim that clang/LLVM is not capable of doing the same when the very thing enabling zig to do this is LLVM.