Page MenuHomeFreeBSD

Draft: Uses/zig.mk
Needs ReviewPublic

Authored by arrowd on Sat, Jul 5, 4:01 PM.
Tags
None
Referenced Files
F124666021: D51165.id158832.diff
Tue, Jul 29, 1:29 AM
F124651625: D51165.id158017.diff
Mon, Jul 28, 10:38 PM
Unknown Object (File)
Sat, Jul 26, 9:35 AM
Unknown Object (File)
Sat, Jul 26, 9:30 AM
Unknown Object (File)
Fri, Jul 25, 12:31 PM
Unknown Object (File)
Fri, Jul 25, 12:03 PM
Unknown Object (File)
Thu, Jul 24, 10:12 PM
Unknown Object (File)
Thu, Jul 24, 4:39 PM
Tokens
"Like" token, awarded by guest-charlesrocket.

Details

Reviewers
fuz
Group Reviewers
portmgr
Contributor Reviewers (ports)
Summary

This is a RFC for the Zig language support in FreeBSD Ports. This Diff
consists of

  • USES=zig implementation
  • OPT_ZIG_BOOL addition to bsd.options.mk
  • ports-mgmt/zig2tuple port for a utility that gathers Zig dependencies
  • x11/ghostty port which is a first complex consumer of the proposed machinery

Both ports build in Poudriere, but there are a lot of deficiencies that I need
help dealing with:

  1. @mat expressed a desire to have ZIG_TUPLE named differently. I'm totally open to bikeshedding on this and I'm sure Kenneth (zig2tuple author) will also agree to rename the tool.
  2. URLs from ZIG_TUPLE are added to MASTER_SITES. Some dependencies may be hosted on GitHub, which raises the following warning from within the framework:

MASTER_SITES contains https://github.com/natecraddock/zf/archive/:zf
, please use USE_GITHUB instead.

This can be worked around by making zig.mk append a group with a special name,
and Framework to exclude this group from warning. Otherwise, zig2tuple can be
modified to emit GH_TUPLE for such dependencies.

  1. Zig allows us to choose where to place dependencies listed in ZIG_TUPLE, but it requires directories to be named as it expects. At the same time, we don't know the directory name that is contained inside the dependency archive, so I extract it into an empty temporary directory and then do mv ${TMPDIR}/* ${TARGETDIR}. Not sure if there is a better way to solve this.
  1. Zig does not have separate build and install stages. At least, I haven't figured a way to separate them, so I made do-build a noop and do-install to perform both building and installing. This allows make restage to work.
  1. Due to p.3, we do not want Framework to extract Zig dependencies - we're extracting them manually in zig-pre-extract. But Framework lacks the opposite of EXTRACT_ONLY, so for now dependencies get extracted twice. Depending on how p.3 is going to be handled we might or might not want to introduce EXTRACT_NOT.

Diff Detail

Repository
R11 FreeBSD ports repository
Lint
No Lint Coverage
Unit
No Test Coverage
Build Status
Buildable 65595
Build 62478: arc lint + arc unit

Event Timeline

arrowd requested review of this revision.Sat, Jul 5, 4:01 PM
arrowd created this revision.
diizzy added inline comments.
Mk/Uses/zig.mk
46

Cut 'n paste error

75

cpu should line up with CPUTYPE according to https://github.com/ziglang/zig/issues/21818

77

Zig is a bit inconsistent with optimization, small/ReleaseSmall is probably a bit more consistent / safe and aligns slightly better to the framework

https://github.com/ziglang/zig/blob/0.14.1/src/link/Elf.zig#L1721
https://github.com/ziglang/zig/blob/0.14.1/src/Compilation.zig#L6083

x11/ghostty/pkg-plist
471

Should be under MANPAGES not DOCS/PORTDOCS
https://cgit.freebsd.org/ports/tree/Mk/bsd.options.desc.mk#n328

I'm not a fan of USES=zig doing all the building in the stage step. Would it be possible to have the building be done in the build step and only stage in the stage step?

The port fails to build on 15-CURRENT outside of Poudriere:

install
└─ install ghostty
   └─ zig build-exe ghostty ReleaseFast native-native failure
error: warning(link): unexpected LLD stderr:
ld.lld: warning: /usr/home/fuz.ports/x11/ghostty/work/ghostty-206d41844e88176a398f149e8e2c8f6e2fdbd28a/.zig-cache/o/6eac6580fb9da6bb1f7ed3b445acecbf/libcimgui.a: archive member '/usr/local/lib/libfreetype.so' is neither ET_REL nor LLVM bitcode

Will now try again with Poudriere.

In D51165#1171109, @fuz wrote:

I'm not a fan of USES=zig doing all the building in the stage step. Would it be possible to have the building be done in the build step and only stage in the stage step?

Like I said in p.4, I haven't found a way to do that.

Works fine for me in Poudriere. Please address the issues raised by @diizzy. LGTM conditional on that.

x11/ghostty/pkg-plist
471

It should be unconditional, really.

This revision is now accepted and ready to land.Tue, Jul 15, 10:35 PM
arrowd added inline comments.
Mk/Uses/zig.mk
75

The issue you referenced talks about WebAssembly. I'm confused what you want me to do there.

x11/ghostty/pkg-plist
471

No, it requires Pandoc, a heavy dependency.

This revision now requires review to proceed.Sun, Jul 20, 2:54 PM
Mk/Uses/zig.mk
75

https://wiki.gentoo.org/wiki/Zig makes it a bit clear, don't hardcode it to baseline?

Mk/Uses/zig.mk
75

More googling led me to this: https://ziggit.dev/t/exe-files-not-interchangeable-among-identical-linux-systems/2708/6
So it seems we should pass -target instead. The only thing left is to figure out a proper target tuple.