Closed daurnimator closed 1 year ago
uh, I just realised this is a dupe of https://github.com/ziglang/zig/issues/2219
How about non standard libraries? Is installing them to and looking up from data dirs (I'm stealing XDG terminology here) be supported by the build system? Currently there's only path for bin, lib and header (include), plus the prefix, so Zig libraries are installed without the interface to call them.
Is this issue still relevant or can this be closed? Zig does not deal with FHS or any system-wide package installing (is agnostic whatever user demands), but it tries to search system-packages (if requested).
What is the full path that you are suggesting for it to go into? /usr/share/zig/lib/
(example file: /usr/share/zig/lib/std/std.zig
)?
Related question, what would be the directory that the system would install zig packages to for #14281? When in non-system mode, this looks like ~/.cache/p/*
, for example:
andy@ark ~> ls ~/.cache/zig/p/
12202e4412ade6d1b8c45a606fc83cfa242a0ac47a70578aef9d5fa3b0bb33ab5618
12203d04cafc97f952d74cdb077e74c0ab3414f9f6b5fbd159112c62bfa584a0dbed
122080904d2975b1a46f61fdd4e865b81d69c74abe5d4103fa5bf1709ab1aa64a0a8
1220effe396ff365d1c5b3c2ca658f1b5b946d8b539b523a131ab65cc106d4c70241
Would that be /usr/share/zig/packages/
?
@daurnimator represents Archlinux; can I get confirmation from a different distro to confirm that these paths are desired?
@andrewrk I put this question to the #xbps IRC channel (void linux packaging). To summarize:
/usr/src
seems to be the ideal location if strictly adhering to the Filesystem Hierarchy Standard./usr/lib
in a very similar way to what Zig currently does./usr/share
is not seen as an improvement over /usr/lib
.Personally, I don't see a strong motivation to change Zig's defaults away from /usr/lib
. It is consistent with other popular languages and what all existing Zig users expect.
As for the path for system-provided zig packages, I'd suggest /usr/lib/zig/packages/
as I see consistency with the location of the standard library source code as the most important issue there.
11:16 <ifreund> anyone have strong opinions on zig installing its standard library source code to /usr/lib/zig/ rather than /usr/share/zig/ ?
11:16 <ifreund> if so please drop a comment here https://github.com/ziglang/zig/issues/6000#issuecomment-1646512199
11:17 <abby> ifreund: wouldn't it make sense to follow hier(7) and use /usr/src?
11:19 <ifreund> abby: maybe? I really don't have any strong opinions and /usr/src is currently empty on my machine
11:21 <aedinius> Because we dont often ship source...
11:21 <aedinius> But in the few cases we do, I have it there. kernel-headers and dkms modules for example.
11:22 <abby> yeah it's all dkms and kernel headers in xlocate
11:23 <abby> rust-src is in /usr/lib/rustlib/src
11:24 <aedinius> Hm. Anyway, I second /usr/src if that's a viable location, otherwise /usr/lib would be more appropriate than /usr/share imo
11:24 <ifreund> aedinius: what's your reasoning for /usr/lib over /usr/share as a second choice?
11:25 <aedinius> I think /usr/share should be more for assets and this seems more code-y than asset-y
11:26 <ifreund> That's fair. Mind if I drop this snippet of the log as a comment on that issue?
11:27 <abby> if including my messages, fine by me
11:27 <tranzystorek_> usr/src would be canonical, I recall alpine even symlinking it for rust
11:28 <aedinius> Fine with me, too.
11:28 <tranzystorek_> but if no zig tools expect it there it might be a pointless action, similar to rust
11:29 <leah2> what does go use?
11:30 <ifreund> tranzystorek_: this is about what upstream zig should default to/recommend
11:30 <tranzystorek_> ah
11:31 <ifreund> leah2: xls suggests /usr/lib/go/src
11:31 <ifreund> but also /usr/share/go/misc ??
11:31 <leah2> ok
11:32 <ifreund> perhaps the latter is more like example code
11:34 <ifreund> It's looking to me like /usr/share/zig would not be an improvement over the current /usr/lib/zig though, and if any change is done it should likely be to use /usr/src/zig
11:35 <tranzystorek_> agreed, share seems like the most confusing location
11:37 <tranzystorek_> i only hope usr/src wouldn't turn out a similarly dead FHS piece as usr/games
11:43 <tranzystorek_> I also see that the main question of that zig discussion is about system-managed external dependencies, similar to /usr/lib/python3.11/site-packages
11:44 <tranzystorek_> i'd see /usr/src as more of a home for zig's std library and other sources
11:46 <ifreund> tranzystorek_: I think that for that second question consistency with where the zig standard library sources and whatnot are found is the most important thing
11:48 <tranzystorek_> there's also the question of whether we even want to host zig libs instead of doing static builds like in rust's case
11:48 <ifreund> really though, it looks like all of Rust, Go, and Python use /usr/lib and I don't know of any language using /usr/src
11:49 <tranzystorek_> yeah
Thanks void linux folks! This was very helpful.
All of Rust, Python, and Go install their standard library source code to /usr/lib in a very similar way to what Zig currently does.
Alright then let's stick with this standard pattern.
Zig expects to find the standard library and other architecture independent files by searching for a directory named
lib
. To follow standard convention of unix systems, architecture independent files should be inshare
, notlib
./usr/share
/usr/lib
/usr/lib<qual>
References
FILE-HIERARCHY(7)