Liliana Marie Prikler writes: >> Zig is perfectly happy compiling itself with GCC, and I believe it's >> the default. I'm pretty sure it either needs no native tools, or >> only llvm, but I wasn't able to test without compiling a whole GCC >> cross-toolchain. >> >> For cross compiling, you will also need to add "-DZIG_TARGET_TRIPLE=" >> to configure flags, and you might want to look into adding >> "-DZIG_TARGET_MCPU" (should take the same values as LLVM's -mcpu) to >> change the baseline CPU for ARM systems since we build for ARM7 by >> default. > I don't think we set mcpu for LLVM or Clang, so that one should be > fine. As for ZIG_TARGET_TRIPLET and the native inputs, do you have an > amended patch already lying around? Sure, I'll attach it. >> Full tests take quite a while, (it's supposed to be "an hour or two") >> so it may eventually be a good idea to limit what we test, such as >> using "-Dskip-release", which tests without optimization. IMO that >> should be enough for catching any Guix-based issues with Zig. > Is that a configure flag or a test flag? It's a test flag. You can check out build.zig for all the flags. >> I don't know if it affects the license, but Zig bundles the source >> for *many* components, such as glibc, musl, mingw, wasi, and from >> LLVM: libcxx, libcxxabi, libunwind, and tsan. > Good catch, could we unbundle some/all of those? I know they do modify some of them, so it would require some care. >> Zig doesn't seem to honor LIBRARY_PATH, but oddly enough it honors >> NIX_LDFLAGS and NIX_CFLAGS_COMPILE, so if we want it to see external >> libraries, something like this is needed: >> >> --8<---------------cut here---------------start------------->8--- >> (add-after 'check 'wrap-binary >> (lambda* (#:key outputs #:allow-other-keys) >> ;; TODO: test with 'zig cc' >> (wrap-program (string-append (assoc-ref outputs "out") >> "/bin/zig") >> `("NIX_LDFLAGS" prefix >> ("${LIBRARY_PATH:+-L${LIBRARY_PATH//:/ -L}}")) >> `("NIX_CFLAGS_COMPILE" prefix >> (,(string-append >> "${CPLUS_INCLUDE_PATH:+-isystem " >> "${CPLUS_INCLUDE_PATH//:/ -isystem }}")))))) >> --8<---------------cut here---------------end--------------->8--- > That is rather inelegant. I'd prefer we patch zig to honor > LIBRARY_PATH, CPLUS_INCLUDE_FLAGS and what other important environment > variables we find. Yeah, it's inelegant. I've never written Zig, so I didn't want to accidentally introduce any bugs. If you want to take a stab at it, take a look at lib/std/zig/system.zig, lines 30-140. -- Sarah