Skip to content

Support installing zig 'lib' directory to 'share' #6000

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
daurnimator opened this issue Aug 9, 2020 · 6 comments
Closed

Support installing zig 'lib' directory to 'share' #6000

daurnimator opened this issue Aug 9, 2020 · 6 comments
Labels
proposal This issue suggests modifications. If it also has the "accepted" label then it is planned. zig build system std.Build, the build runner, `zig build` subcommand, package management
Milestone

Comments

@daurnimator
Copy link
Contributor

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 in share, not lib.

directory description
/usr/share Architecture-independent (shared) data.
/usr/lib Libraries for the binaries in /usr/bin and /usr/sbin.
/usr/lib<qual> Alternative format libraries, e.g. /usr/lib32 for 32-bit libraries on a 64-bit machine (optional).

References

@daurnimator daurnimator added the proposal This issue suggests modifications. If it also has the "accepted" label then it is planned. label Aug 9, 2020
@daurnimator
Copy link
Contributor Author

uh, I just realised this is a dupe of #2219

@andrewrk andrewrk added the zig build system std.Build, the build runner, `zig build` subcommand, package management label Oct 4, 2020
@andrewrk andrewrk added this to the 0.8.0 milestone Oct 4, 2020
@andrewrk andrewrk added the accepted This proposal is planned. label Oct 4, 2020
@andrewrk andrewrk modified the milestones: 0.8.0, 0.9.0 May 19, 2021
@McSinyx
Copy link
Contributor

McSinyx commented Sep 28, 2021

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.

@andrewrk andrewrk modified the milestones: 0.9.0, 0.10.0 Nov 20, 2021
@andrewrk andrewrk modified the milestones: 0.10.0, 0.11.0 Apr 16, 2022
@matu3ba
Copy link
Contributor

matu3ba commented Jan 3, 2023

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).

@andrewrk andrewrk modified the milestones: 0.11.0, 0.12.0 Jul 20, 2023
@andrewrk
Copy link
Member

andrewrk commented Jul 22, 2023

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?

@ifreund
Copy link
Member

ifreund commented Jul 22, 2023

@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.
  • 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.
  • /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

@andrewrk andrewrk removed the accepted This proposal is planned. label Jul 22, 2023
@andrewrk
Copy link
Member

andrewrk commented Jul 22, 2023

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.

@andrewrk andrewrk closed this as not planned Won't fix, can't repro, duplicate, stale Jul 22, 2023
@andrewrk andrewrk modified the milestones: 0.12.0, 0.11.0 Jul 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal This issue suggests modifications. If it also has the "accepted" label then it is planned. zig build system std.Build, the build runner, `zig build` subcommand, package management
Projects
None yet
Development

No branches or pull requests

5 participants