1. 133
  1.  

  2. 15

    Very well-written, Andrew. Like reading a summary of your recent youTube coding videos.

    1. 5

      Zig looks pretty promising. The only thing that’s stopping me from using it right now is the fact that I was unable to (cross-)compile the compiler for ARM32…

      1. 5

        If I recall correctly, one of the things that blocked Rust from using LLD for so long was that a linker on its own is not enough: you need system libraries to link against and C Runtime Start object files to link with and whatever procedure you follow to acquire those things will probably give you a native linker anyway.

        Actually building dozens of libc/kernel variations and shipping them with the compiler seems like an absolute ton of work to set up and maintain, but I can’t deny it seems to make cross-compilation painless.

        1. 2

          Anyway, that’s a lot less work than to maintain cross-compilation on per-project basis (or leaving it as an exercise to a user). Also, I don’t think that Zig ships complete build output with the compiler.

          When you request a certain version of glibc, Zig creates a dummy .so files to link against, which contain exactly the correct set of symbols (with appropriate name mangling) based on the requested version.

          1. 1

            you need system libraries to link against

            You don’t actually need them. It’s just that LLVM and GNU linkers have no portable way to specify the target .so/.dll/.dylib path and exported symbols, etc. other than looking at the file itself, thus implying compilation on the target system.

            1. 4

              By “system libraries” I meant things like libc.so, but also things like crt1.o mentioned in the OP. One of my frustrations with Rust’s cross-compilation support is that apparently mingw needs the linker and the crt1.o to match; Rust depends on the linker being installed separately but ships its own crt1.o and of course they often don’t match leading to linking failures.

              1. 1

                mingw needs the linker and the crt1.o to match

                Do you mean that the host linker that Rust shells out to cannot link shipped CRT? That seems more like an issue with how Rust does linking than with the fact that it ships C runtime.

                1. 3

                  I don’t know exactly how to describe the problem, but apparently it was fixed earlier this year.

          2. 3

            This sounds so cool. I’m afraid to ask whether it supports C++…

            1. 14
            2. 3

              Amazing. I was awed by the first zig post here, and I’m blown away again by this one. I want to play with this.

              1. 3

                Monocypher’s test suit works under “zig cc”.

                1. 2

                  I’m quite curious about Zig and installing it now on WSL2 aarch64 to see how it goes. I wish it could cross-compile or work under Windows 10 aarch64.

                  1. 1

                    That target is supported but not (yet) well tested