void-packages icon indicating copy to clipboard operation
void-packages copied to clipboard

zig: update to 0.12.0.

Open OliveThePuffin opened this issue 1 year ago • 22 comments

Testing the changes

  • I tested the changes in this PR: YES

Local build testing

  • I built this PR locally for my native architecture, (ARCH-LIBC) x86_64-glibc

OliveThePuffin avatar Apr 20 '24 16:04 OliveThePuffin

This should close https://github.com/void-linux/void-packages/issues/45424

OliveThePuffin avatar Apr 20 '24 16:04 OliveThePuffin

Did you try building anything with it? Hopefully soon river or waylock will tag a release using zig 0.12..

dkwo avatar Apr 20 '24 18:04 dkwo

Yeah. I built some of my advent of code stuff which works fine. I also built https://github.com/andrewrk/poop with it and it works without a hitch

OliveThePuffin avatar Apr 20 '24 23:04 OliveThePuffin

You need to rebuild (aka revbump) packages in the repo which which require zig for building and commit them within this PR. See https://github.com/void-linux/void-packages/pull/49436 as an example for how this workflow.

icp1994 avatar Apr 21 '24 08:04 icp1994

Oh, I see what you mean now.

So river, waylock, ncdu2, zls, and linuxwave (templates that use zig-build) all must build in this repo before merging. Makes sense.

I'll try to bump them now and see, but due to the breaking nature of early zig, this may have to wait a while.

OliveThePuffin avatar Apr 21 '24 15:04 OliveThePuffin

Did some tests, our zig-build build_style needs to be ported to use -Doptimize=ReleaseSafe for setting profile, but ncdu2 2.4 also sets a preferred optimize level which replaces this flag with -Drelease=<bool> altogether :/

tranzystorekk avatar Apr 21 '24 19:04 tranzystorekk

I'm starting to think I bit off more than I could chew

OliveThePuffin avatar Apr 22 '24 02:04 OliveThePuffin

@OliveThePuffin are you planning on finishing this up?

realcharmer avatar May 03 '24 12:05 realcharmer

I did, but right now the repo/xbps-src is breaking on me saying that "neither git or chroot-git are available in your system!" which is just false. I zapped and binary-bootstrapped, but nothing is fixing this. If you want to, feel free to take it away.

OliveThePuffin avatar May 03 '24 16:05 OliveThePuffin

I did, but right now the repo/xbps-src is breaking on me saying that "neither git or chroot-git are available in your system!" which is just false. I zapped and binary-bootstrapped, but nothing is fixing this. If you want to, feel free to take it away.

update master branch, and rebase this branch against master

Luciogi avatar May 05 '24 17:05 Luciogi

@realcharmer I tried to build against the updates you made but it doesn't seem to be working. I'm getting these errors:

/builddir/river-0.3.0/build.zig:7:25: error: unable to load '/builddir/river-0.3.0/deps/zig-wayland/build.zig': FileNotFound
/builddir/river-0.3.0/build.zig:67:40: error: no field or member function named 'execAllowFail' in 'Build'

Is there anything you did to make it work?

OliveThePuffin avatar May 07 '24 15:05 OliveThePuffin

river 0.3.0 won't support zig 0.12, we need to wait for 0.4.0, there seems to be some work being done

tranzystorekk avatar May 07 '24 16:05 tranzystorekk

New river and waylock are now out, which makes this PR viable. However, the build style probably needs upgrading to use zig package manager, see e.g. https://codeberg.org/river/river/src/branch/master/PACKAGING.md

This works for me on x86_64 with static zig 0.12, but it needs some refinement to be included in void's build style:

 # Template file for 'river'
 pkgname=river
-version=0.2.4
-revision=3
+version=0.3.2
+revision=1
 archs="~i686* ~armv6l* ~armv7l*"
 build_style=zig-build
-configure_args="$(vopt_if xwayland -Dxwayland) -Dpie"
-hostmakedepends="pkg-config wayland-devel scdoc"
-makedepends="wlroots0.16-devel libevdev-devel pixman-devel
+hostmakedepends="pkg-config wayland-devel scdoc"
+makedepends="wlroots0.17-devel libevdev-devel pixman-devel
  wayland-protocols libxkbcommon-devel wayland-devel"
-depends="$(vopt_if xwayland xorg-server-xwayland)"
+depends="xorg-server-xwayland"
 short_desc="Dynamic tiling Wayland compositor"
 maintainer="Orphaned <[email protected]>"
 license="GPL-3.0-only"
 homepage="https://codeberg.org/river/river"
 distfiles="https://codeberg.org/river/river/releases/download/v${version}/river-${version}.tar.gz"
-checksum=26c1c41a65ce3804069afad6988410515cf478d2b76303ebc699766d3d4dc69f
+checksum=acb273487eb0cf9222c14e050c0faad692f426dba599b62e4c743ba43328ee9e
+_deps="https://codeberg.org/ifreund/zig-pixman/archive/v0.1.0.tar.gz
+ https://codeberg.org/ifreund/zig-wayland/archive/v0.1.0.tar.gz
+ https://codeberg.org/ifreund/zig-wlroots/archive/v0.17.0.tar.gz
+ https://codeberg.org/ifreund/zig-xkbcommon/archive/v0.1.0.tar.gz"
 
-build_options="xwayland"
-build_options_default="xwayland"
-desc_option_xwayland="Enable Xwayland support"
+post_fetch() {
+       for _d in $_deps; do
+               zig fetch --global-cache-dir $XBPS_BUILDDIR/zig-input $_d
+       done
+}
+
+do_build() {
+       DESTDIR="zig-out" zig build --system $XBPS_BUILDDIR/zig-input/p -Doptimize=ReleaseSafe -Dpie -Dxwayland --prefix /usr -Dcpu=baseline install
+}
+
+do_check() {
+       zig build --system $XBPS_BUILDDIR/zig-input/p test
+}

dkwo avatar May 20 '24 18:05 dkwo

Similarly:

 # Template file for 'waylock'
 pkgname=waylock
-version=0.6.2
+version=1.1.0
 revision=1
 build_style=zig-build
-configure_args="-Dpie"
 hostmakedepends="pkg-config wayland-devel scdoc"
 makedepends="libxkbcommon-devel pam-devel wayland-protocols wayland-devel"
 short_desc="Simple screenlocker for wayland compositors"
@@ -11,7 +10,19 @@ maintainer="Orphaned <[email protected]>"
 license="ISC"
 homepage="https://codeberg.org/ifreund/waylock"
 distfiles="https://codeberg.org/ifreund/waylock/releases/download/v${version}/waylock-${version}.tar.gz"
-checksum=4a794dedd1b11f3b9bb7b46f8a93c20aac5ac1d40a851cabaa7ae84fd36686fa
+checksum=fd200ddaf416e45a8dc6e212fb8b0fba2cf7bdcfaf5f65a361d8b0313600d02e
+_deps="https://codeberg.org/ifreund/zig-wayland/archive/v0.1.0.tar.gz
+ https://codeberg.org/ifreund/zig-xkbcommon/archive/v0.1.0.tar.gz"
+
+post_fetch() {
+       for _d in $_deps; do
+               zig fetch --global-cache-dir $XBPS_BUILDDIR/zig-input $_d
+       done
+}
+
+do_build() {
+       DESTDIR="zig-out" zig build --system $XBPS_BUILDDIR/zig-input/p -Doptimize=ReleaseSafe -Dpie --prefix /usr -Dcpu=baseline install
+} 

dkwo avatar May 20 '24 18:05 dkwo

since the zig pm scheme behaves similar to cargo we could just configure global cache in the build style and et voila

tranzystorekk avatar May 20 '24 18:05 tranzystorekk

makes sense

dkwo avatar May 20 '24 18:05 dkwo

Just tested for waylock and river, adding --global-cache-dir /host/zig to zig-build style works well

tranzystorekk avatar May 20 '24 20:05 tranzystorekk

Thanks for the heads-up, I'll update both PRs tomorrow.

realcharmer avatar May 20 '24 22:05 realcharmer

Seeing river 0.3.2 uses zig 0.12 now. Also OP, do not get discouraged. Void packaging is not for the faint of heart. You will get fail, many times. The maintainers here have put me through eternal bootcamp with attitude to match.

jason1987d avatar May 22 '24 02:05 jason1987d

I prepared build_style changes that should make package templates not require custom fetch/do_build hacks:

 common/build-style/zig-build.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/build-style/zig-build.sh b/common/build-style/zig-build.sh
index 205c4cadf53f8c..e0245e8cd7eb63 100644
--- a/common/build-style/zig-build.sh
+++ b/common/build-style/zig-build.sh
@@ -30,9 +30,11 @@ do_build() {
 	# prefix used by the zig build system.
 	DESTDIR="zig-out" zig build \
 		--sysroot "${XBPS_CROSS_BASE}" \
+		--search-prefix /usr \
+		--global-cache-dir /host/zig \
 		--libc xbps_zig_libc.txt \
 		-Dtarget="${zig_target}" -Dcpu="${zig_cpu}" \
-		-Drelease-safe --prefix /usr install \
+		--release=safe --prefix /usr install \
 		${configure_args}
 }

tranzystorekk avatar May 23 '24 07:05 tranzystorekk

Quote from Andrew:

I'm planning to release 0.13.0 and 0.12.1 on Monday, primarily featuring the LLVM 18 upgrade and musl 1.2.5 upgrade. If there are any other impactful changes you want to land, you have 5 days to get them in. 0.12.1 will be the last release in the 0.12.x series. the release is primarily aimed at helping distributions package zig since it updates to LLVM 18. distros which have llvm 17 can package zig 0.12.1; distros that have llvm 18 can package 0.13.0

OutOfContainment avatar May 23 '24 11:05 OutOfContainment

@tranzystorekk Great! I can confirm that works for me, with the trivial update for waylock, and this one for river:

# Template file for 'river'
 pkgname=river
-version=0.2.4
-revision=3
+version=0.3.2
+revision=1
 archs="~i686* ~armv6l* ~armv7l*"
 build_style=zig-build
-configure_args="$(vopt_if xwayland -Dxwayland) -Dpie"
+configure_args="-Dpie -Dxwayland"
 hostmakedepends="pkg-config wayland-devel scdoc"
-makedepends="wlroots0.16-devel libevdev-devel pixman-devel
+makedepends="wlroots0.17-devel libevdev-devel pixman-devel
  wayland-protocols libxkbcommon-devel wayland-devel"
-depends="$(vopt_if xwayland xorg-server-xwayland)"
+depends="xorg-server-xwayland"
 short_desc="Dynamic tiling Wayland compositor"
 maintainer="Orphaned <[email protected]>"
 license="GPL-3.0-only"
 homepage="https://codeberg.org/river/river"
 distfiles="https://codeberg.org/river/river/releases/download/v${version}/river-${version}.tar.gz"
-checksum=26c1c41a65ce3804069afad6988410515cf478d2b76303ebc699766d3d4dc69f
+checksum=acb273487eb0cf9222c14e050c0faad692f426dba599b62e4c743ba43328ee9e
 
-build_options="xwayland"
-build_options_default="xwayland"
-desc_option_xwayland="Enable Xwayland support"
+do_check() {
+       zig build --system /host/zig/p test
+}

(The reason for removing the xwayland option is that, even if build with it, it can be disabled at runtime.)

dkwo avatar May 23 '24 13:05 dkwo

Shouldn't --global-cache-dir be something like ${XBPS_HOSTDIR}/zigcache rather than /host/zig?

icp1994 avatar May 25 '24 14:05 icp1994

i took it from the cargo/rust style, afaiu its ~~symlinked~~ bind mounted anyway

tranzystorekk avatar May 25 '24 16:05 tranzystorekk

I'm assuming based on the logs of the build that the failed river compile is a source code issue

OliveThePuffin avatar Jun 12 '24 02:06 OliveThePuffin

zig 0.12.1 is available

Luciogi avatar Jun 12 '24 03:06 Luciogi

I'm assuming based on the logs of the build that the failed river compile is a source code issue

no, that's my bad, search prefix should be --search-prefix "${XBPS_CROSS_BASE}/usr"

tranzystorekk avatar Jun 12 '24 06:06 tranzystorekk

Zig, river, and waylock should all be updated now. I even minimally tested some functionality on my machine and it works.

Now, there are a few other packages that depend on zig that seem to not have a trivial update:

linuxwave - still on just 0.10.1 - I guess we either keep waiting or eventually ditch it. I see there's something in progress here: https://github.com/orhun/linuxwave/pull/28 zls - comes with software from 3 repos. I can update the main one, but I'm not so sure about the others ncdu2 - seems like it would be trivial but fails at do-patch for some reason. I'm guessing it's because of this:

Did some tests, our zig-build build_style needs to be ported to use -Doptimize=ReleaseSafe for setting profile, but ncdu2 2.4 also sets a preferred optimize level which replaces this flag with -Drelease=<bool> altogether :/

Thoughts?

OliveThePuffin avatar Jun 13 '24 00:06 OliveThePuffin

My tested changes:

  • ncdu2: https://github.com/tranzystorekk/void-packages/commit/5843ee4b885aeb8a9c7e56343e9c2aa0c0f046f2
  • zls: https://github.com/tranzystorekk/void-packages/commit/9086dcbac5209c40d15ea6954927f9a82ddefe8e
  • linuxwave: the PR you mentioned should work already, the only wip is making its CI work with newer zig

tranzystorekk avatar Jun 13 '24 06:06 tranzystorekk

There is zig 0.13.0 out since 07.06.2024.

river and waylock are both available in new versions with 0.13.0 support.

Does an update to the newest version make sense?

dataCobra avatar Jun 13 '24 07:06 dataCobra