[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#74217: Bootstrapping Zig with no Binary Blobs
From: |
Hilton Chain |
Subject: |
bug#74217: Bootstrapping Zig with no Binary Blobs |
Date: |
Fri, 15 Nov 2024 11:29:10 +0800 |
On Thu, 14 Nov 2024 17:41:04 +0800,
Efraim Flashner wrote:
>
> [1 <text/plain; utf-8 (quoted-printable)>]
> On Thu, Nov 14, 2024 at 05:22:17PM +0800, Hilton Chain wrote:
> > 2. Pass libc to Zig's linker
> > This was the behavior in 0.9, but changed due to issue on macOS[1]. (btw,
> > our
> > CPLUS_INCLUDE_PATH also has issue with macOS target[2]). RUNPATH for glibc
> > was
> > missing because of this, since it's the linker handling each-lib-rpath.
> >
> > Since we do not support macOS anyway, can we restore this behavior?
>
> At worst I could see adding a comment that it would likely break future
> macOS cross-compiles. I don't see an issue with either putting it back
> unconditionally or trying to make it conditional based on
> (%current-system) or the contents of (%current-target-system).
Bad news: Zig 0.12 changed[1] behavior of each_lib_rpath, it won't filter
libraries now.
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 also have concern for Zig's relying on /usr/bin/env (Zig uses an ELF file
> > to
> > find dynamic linker, env is chosen for it's well-known). We have patched
> > this
> > reference, not sure if it will cause issue for cross-building Zig.
>
> We use search-input-file in the replacement, so it should choose the
> cross-binutils for the replacement /bin/env, so it shouldn't be a
> problem.
On Thu, 14 Nov 2024 17:47:23 +0800,
Motiejus Jakštys wrote:
>
> This file is only consulted when `-target=native`. I.e. when it needs
> to compile for the host. If target is specified, it will not consult
> that file.
>
> Just verified with zig 0.13.0:
>
> $ strace -f -e openat zig cc hello.c -o hello |& grep -w env
> openat(AT_FDCWD,
> "/nix/store/sf6y4arqcm100rnnl3dhpg732i774zp6-coreutils-9.5/bin/env",
> O_RDONLY|O_NOCTTY|O_CLOEXEC) = 5
> $ strace -f -e openat zig cc -target x86_64-linux-gnu.2.32 hello.c -o
> hello |& grep -w env
> $
Thanks! Then it should be in inputs. I don't want to add coreutils to it, so I
patched reference of /usr/bin/env to clang++ (it's both in inputs and RUNPATH)
instead.
---
[1]:
https://github.com/ziglang/zig/commit/852e7e24b5f15b489463bdabb0039e2a424e5ee6
- bug#74217: [PATCH 1/2] gnu: Add zig-0.10.0-610-bootstrap., (continued)
- bug#74217: Bootstrapping Zig with no Binary Blobs, Hilton Chain, 2024/11/13
- bug#74217: Bootstrapping Zig with no Binary Blobs, Efraim Flashner, 2024/11/13
- bug#74217: Bootstrapping Zig with no Binary Blobs, Hilton Chain, 2024/11/13
- bug#74217: Bootstrapping Zig with no Binary Blobs, Hilton Chain, 2024/11/13
- bug#74217: Bootstrapping Zig with no Binary Blobs, Hilton Chain, 2024/11/14
- bug#74217: Bootstrapping Zig with no Binary Blobs, Hilton Chain, 2024/11/14
- bug#74217: Bootstrapping Zig with no Binary Blobs, Efraim Flashner, 2024/11/14
- bug#74217: Bootstrapping Zig with no Binary Blobs,
Hilton Chain <=
- bug#74217: Bootstrapping Zig with no Binary Blobs, Hilton Chain, 2024/11/15
- bug#74217: Bootstrapping Zig with no Binary Blobs, Hilton Chain, 2024/11/16
- bug#74217: Bootstrapping Zig with no Binary Blobs, Motiejus Jakštys, 2024/11/16
- bug#74217: Bootstrapping Zig with no Binary Blobs, Hilton Chain, 2024/11/16
- bug#74217: Bootstrapping Zig with no Binary Blobs, Efraim Flashner, 2024/11/16
- bug#74217: Bootstrapping Zig with no Binary Blobs, Hilton Chain, 2024/11/16
- bug#74217: Bootstrapping Zig with no Binary Blobs, Hilton Chain, 2024/11/16
- bug#74217: Bootstrapping Zig with no Binary Blobs, Efraim Flashner, 2024/11/17
- bug#74217: Bootstrapping Zig with no Binary Blobs, Hilton Chain, 2024/11/17
- bug#74217: Bootstrapping Zig with no Binary Blobs, Hilton Chain, 2024/11/18