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

From: Hilton Chain <[email-masked]>
Date: Fri, 15 Nov 2024 22:30:40 +0800

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.

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.
--8<---------------cut here---------------start------------->8---
--- /gnu/store/gqdi4drfn3js5cwgfmlpkyfm2xf3l5b0-zig-0.10.1/bin/zig
+++ cuirass/gqdi4drfn3js5cwgfmlpkyfm2xf3l5b0-zig-0.10.1/bin/zig
├── readelf --wide --decompress --string-dump=.rodata {}
│ @@ -77024,14 +77024,16 @@
│    [149be0]  +�&
│    [149bf9]  )&
│    [149c12]  %
│    [149c28]  VO$
│    [149c40]  D�(
│    [149c59]  >$
│    [149c70]  8�%
│ +  [149c94]  ;
│ +  [149ca0]  ;
│    [149ca8]  '
│    [149cb0]  uespemos�odnarodarenegylsetybdet
│    [149cf0]  p��
│    [149d11]  O'
│    [149d21]  5&
│    [149d31]  f&
│    [149d40]  SJ'
--8<---------------cut here---------------end--------------->8---

--8<---------------cut here---------------start------------->8---
--- /gnu/store/466cm9xpjqg80iqracj4qirsrdha1rnk-zig-0.11.0/bin/zig
+++ cuirass/466cm9xpjqg80iqracj4qirsrdha1rnk-zig-0.11.0/bin/zig
├── readelf --wide --decompress --string-dump=.rodata {}
│ @@ -64905,14 +64905,16 @@
│    [ 5ae48]  xpnt4win2kvistawin10ws2003win8_1win10_th2win10_rs1win10_rs2win10_rs3win10_rs4win10_rs5win10_19h1
│    [ 5aef0]
│    [ 5aef8]  #
│    [ 5af00]  %
│    [ 5af08]  %
│    [ 5af10]  &
│    [ 5af78]  celfhexrawmachospirvdxcontainer
│ +  [ 5afc0]  ;
│ +  [ 5aff8]  ;
│    [ 5b070]  E
│    [ 5b0b4]  ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_
│    [ 5b350]
│    [ 5b380]  @
│    [ 5b3e0]
│    [ 5b420]  ]
│    [ 5b5e0]  %
--8<---------------cut here---------------end--------------->8---