Subject: Re: Bootstrapping Zig with no Binary Blobs

From: Hilton Chain <[email-masked]>
Date: Sat, 16 Nov 2024 14:54:55 +0800

On Fri, 15 Nov 2024 22:30:40 +0800,
Hilton Chain wrote:
>
> I have locally made the "use-system-paths" patch larger so that Zig can really
> honor "CROSS_" environment variables.
>
> The next issue is cross building with pkg-config.  Zig only invokes
> "pkg-config", but we don't have a "pkg-config" with search path for target
> inputs.  I can add a pkg-config-for-zig to workaround this, and then... It's
> dynamic linker path, I'll look into it soon.

Adding a file with content like the following and passing --libc <this file> to
zig works, RUNPATH is correct and no need to set CC then.

--8<---------------cut here---------------start------------->8---
include_dir=/gnu/store/dfx90sc16nphh6bd07sjyri6x4s51zni-glibc-cross-aarch64-linux-gnu-2.39/include
sys_include_dir=/gnu/store/dfx90sc16nphh6bd07sjyri6x4s51zni-glibc-cross-aarch64-linux-gnu-2.39/include
crt_dir=/gnu/store/dfx90sc16nphh6bd07sjyri6x4s51zni-glibc-cross-aarch64-linux-gnu-2.39/lib
msvc_lib_dir=
kernel32_lib_dir=
gcc_dir=
--8<---------------cut here---------------end--------------->8---

For cross builds interpreter path like /lib/ld-linux-aarch64.so.1 is used in
output binary, I'll find a way to fix it.

> Also for reproducibility, bin/zig is the only file differs and here's the diff,
> I don't know about this part so I currently have no idea on fixing it.

This seem to be an upstream issue, Zig is reproducible only on the same machine.
I'll verify it and report to upstream.