Subject: bug#74217: Bootstrapping Zig with no Binary Blobs

From: Efraim Flashner <[email-masked]>
Date: Sun, 17 Nov 2024 09:16:13 +0200

On Fri, Nov 15, 2024 at 10:30:40PM +0800, Hilton Chain wrote:
> On Fri, 15 Nov 2024 11:29:10 +0800,
> Hilton Chain wrote:
> >
> > Good news: Thanks to this diff, I know how to add libc to RUNPATH now :)
> >
> > Another forced push, I have ensured consistent behavior for
> > (CROSS_)?LIBRARY_PATH and added libc RUNPATH without restoring the behavior
> > passing '-lc' to linker.
> >
> > Who said not going to implement a ld-wrapper within Zig?  :P
> > Fortunately it was already there :)
> >
> > BTW, adding pkg-config to native-inputs works for ncdu.
> 
> 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.

I found a patch after the 0.13.0 release that switches from hardcoding
pkg-config to using the PKG_CONFIG environment variable and falling back
to pkg-config, so I backported it to 0.12 and was able to use that and
guix's regular pkg-config package.  I've added those patches to the
wip-zig-bootstrap tree.

We now have a couple of phases that are before the 'build phase, do you
think it'd be better to consolidate them into a 'configure phase?
There's no 'configure' script to run, but it does do a lot of
preparation before the actual 'build phase...

-- 
Efraim Flashner   <[email-masked]>   אפרים פלשנר
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted