omniosorg / omnios-extra

Packages for OmniOS extra
https://omnios.org
Other
26 stars 58 forks source link

zig: update to 0.11.0 #1338

Closed rzezeski closed 11 months ago

rzezeski commented 1 year ago

I'd like to submit this work to update the Zig package to 0.11.0. This upgrade required a bit of work as Zig has transitioned to its self-hosted compiler since the 0.9.1 version. I won't claim that everything works but I see 35,172 of Zig's tests passing when running zig build test -Dskip-non-native. My own personal Zig application also compiled and ran. I wanted to try compiling/running ncdu but it requires ncursesw and I don't see that available on our system.

I didn't generate the diffs as described in the instructions. I just used git diff. All the patches seem to apply fine. But let me know if you want this changed. After this lands I'll start looking at Zig 0.12.0 dev and start upstreaming patches. I'll also see about getting a proper illumos tag like we have in Go/Rust/etc.

oetiker commented 1 year ago

try to make ci build pass

rzezeski commented 1 year ago

I decided this patch needs a bit more work after some discussion with @citrus-it. We'd like to keep some version of Zig available for all supported releases, which means 0.9.1 needs to stick around for a bit longer. Furthermore, ncdu is written in Zig and the current version (2.2.1) relies on zig-0.9.1 to build correctly. This is the case because Zig is free to make breaking changes across the board up until the 1.0.0 release. We can't just bump all versions to the latest because Zig tracks latest LLVM, and from my understanding we don't have support for newer LLVMs on older OmniOS releases.

All that said, I'm going to restructure this change so that we have separate zig9 and zig11 packages. I think this also makes it easier to support a development package in the form of zig12, but I'm not going to do that in this change.

rzezeski commented 1 year ago

I see this message during the pkg lint stage when building zig-0.9 after I've already built zig-0.11. It seems like it's referring to the lack of mediation between the two packages.

--- Formatting manifest
Do you want to run pkglint? (y/n) y

Lint engine setup...
Starting lint run...

ERROR pkglint.dupaction010.2      path opt/ooce/bin/zig has missing mediator attributes across actions in pkg://local.omnios/ooce/developer/zig-0.11@0.11.0,5.11-151047.0:20230915T041933Z pkg:/ooce/developer/zig-0.9@0.9.1,5.11-151047.0

However, their manifests show that there is a mediation in place and I can even install both of them at the same time.

zig-0.9 manifest:

link mediator=zig mediator-version=0.9 path=opt/ooce/bin/zig target=../zig-0.9/bin/zig

zig-0.11 manifest

link mediator=zig mediator-version=0.11 path=opt/ooce/bin/zig target=../zig-0.11/bin/zig
rpz@kalm:~/src/omnios-extra$ pkg list | grep zig
ooce/developer/zig-0.11 (local.omnios)            0.11.0-151047.0            im-
ooce/developer/zig-0.9 (local.omnios)             0.9.1-151047.0             im-

rpz@kalm:~$ zig version
0.11.0

rpz@kalm:~$ ls -la $(which zig)
lrwxrwxrwx   1 root     root          19 Sep 14 22:47 /opt/ooce/bin/zig -> ../zig-0.11/bin/zig

rpz@kalm:~$ ls /opt/ooce/zig*
/opt/ooce/zig-0.11:
bin  lib

/opt/ooce/zig-0.9:
bin  lib
rzezeski commented 12 months ago

@hadfl I've made the changes you requested. I still need to build/test on my end with these changes but I wanted to push it out for review first. You'll definitely want to double-check my work around the obsolete packaging stuff and make sure I didn't mess that up.

I also added another patch to make sure the zig compiler uses frame pointers even when built in an optimized release mode.

rzezeski commented 12 months ago

Both packages build with the latest changes. I can install both versions at the same time.

rpz@kalm:~/src/omnios-extra$ pkg list | grep zig
ooce/developer/zig-011 (local.omnios)             0.11.0-151047.0            im-
ooce/developer/zig-09 (local.omnios)              0.9.1-151047.0             im-

rpz@kalm:~/src/omnios-extra$ zig version
0.11.0

rpz@kalm:~/src/omnios-extra$ ls -la $(which zig)
lrwxrwxrwx   1 root     root          19 Sep 18 17:13 /opt/ooce/bin/zig -> ../zig-0.11/bin/zig

I still see a failure during pkglint and I have no idea why.

--- Formatting manifest
Do you want to run pkglint? (y/n) y

Lint engine setup...
Starting lint run...

ERROR pkglint.dupaction010.2      path opt/ooce/bin/zig has missing mediator attributes across actions in pkg://local.omnios/ooce/developer/zig-011@0.11.0,5.11-151047.0:20230918T191625Z pkg:/ooce/developer/zig-09@0.9.1,5.11-151047.0
----- pkglint failed

I'm not sure how to test the package renaming.

rzezeski commented 12 months ago

The mediator warning is something you can ignore. When it's doing the pkglint, it's checking the new package against the existing published ones, and the old zig package delivers opt/ooce/bin/zig as a link, but that link doesn't have any mediator attributes on it, hence the conflict.

It isn't taking the renamed package into account because it's not published yet. This should be fine once everything is published.

You're right, taking a closer look at the error you can see the zig-011 FMRI comes from local.omnios whereas the zig-09 comes from the existing ooce repo. It fooled me because I would have expected it to still use the old package name zig, but I guess it ends up using the new name instead.

Anyways, I think I fixed the other issues you mentioned.

The-King-of-Toasters commented 11 months ago

Thank you @rzezeski! I'm the author of the initial Illumos port, but I've been struggling to keep it working on my own. I'll try to prepare a pr to get these patches upstream. Note that Zig has recently changed over to llvm 17, so there may be build failures if you start packaging 0.12.

rzezeski commented 11 months ago

@The-King-of-Toasters If you don't mind I'd like to get these upstreamed myself so I can engage the Zig community with illumos support going forward. I want to work towards getting a proper illumos tag and making sure various bits work.

The-King-of-Toasters commented 11 months ago

Of course!

My dream when starting the port was to have Illumos be at least a Tier 2 supported system like FreeBSD. This requires a CI system and proper support for evented IO using evports that I never got around to add.

rzezeski commented 11 months ago

@The-King-of-Toasters Thanks. And thank you for your initial work, otherwise I might not have done this work at all.

I'm in the process of bringing up 0.12.0-dev as we speak and that's what I'm going to base my initial upstream patches on.