Skip to content
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

zig: update to 0.12.0. #49935

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

Conversation

OliveThePuffin
Copy link
Contributor

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 OliveThePuffin changed the title zig: update to 0.12.0 zig: update to 0.12.0. Apr 20, 2024
@OliveThePuffin
Copy link
Contributor Author

This should close #45424

srcpkgs/zig/template Outdated Show resolved Hide resolved
@dkwo
Copy link
Contributor

dkwo commented Apr 20, 2024

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

@OliveThePuffin
Copy link
Contributor Author

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

@icp1994
Copy link
Contributor

icp1994 commented Apr 21, 2024

You need to rebuild (aka revbump) packages in the repo which which require zig for building and commit them within this PR. See #49436 as an example for how this workflow.

@OliveThePuffin
Copy link
Contributor Author

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 OliveThePuffin marked this pull request as draft April 21, 2024 16:02
@tranzystorekk
Copy link
Contributor

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 :/

@OliveThePuffin
Copy link
Contributor Author

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

@realcharmer
Copy link
Contributor

@OliveThePuffin are you planning on finishing this up?

@OliveThePuffin
Copy link
Contributor Author

OliveThePuffin commented May 3, 2024

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.

@Luciogi
Copy link
Contributor

Luciogi commented May 5, 2024

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

@OliveThePuffin
Copy link
Contributor Author

@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?

@tranzystorekk
Copy link
Contributor

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

@dkwo
Copy link
Contributor

dkwo commented May 20, 2024

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 <orphan@voidlinux.org>"
 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
Copy link
Contributor

dkwo commented May 20, 2024

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 <orphan@voidlinux.org>"
 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
+} 

@tranzystorekk
Copy link
Contributor

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

@dkwo
Copy link
Contributor

dkwo commented May 20, 2024

makes sense

@tranzystorekk
Copy link
Contributor

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

@realcharmer
Copy link
Contributor

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

@jason1987d
Copy link
Contributor

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.

@tranzystorekk
Copy link
Contributor

tranzystorekk commented May 23, 2024

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}
 }

@OutOfContainment
Copy link

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

@dkwo
Copy link
Contributor

dkwo commented May 23, 2024

@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 <orphan@voidlinux.org>"
 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.)

@icp1994
Copy link
Contributor

icp1994 commented May 25, 2024

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

@tranzystorekk
Copy link
Contributor

tranzystorekk commented May 25, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants