Page MenuHomeFreeBSD

lang/zig: force baseline instead of native compilation
ClosedPublic

Authored by dch on Jan 30 2023, 8:29 PM.
Tags
None
Referenced Files
F84045130: D38284.diff
Sat, May 18, 2:13 PM
Unknown Object (File)
Mon, May 13, 5:44 PM
Unknown Object (File)
Mon, May 6, 7:48 AM
Unknown Object (File)
Mon, May 6, 7:48 AM
Unknown Object (File)
Mon, May 6, 7:48 AM
Unknown Object (File)
Mon, May 6, 7:48 AM
Unknown Object (File)
Mon, May 6, 7:48 AM
Unknown Object (File)
Mon, May 6, 7:48 AM
Subscribers

Details

Summary

Systems that don't have AVX2 or newer CPU instructions will crash
with SIGILL. Using baseline zig target should address this but
make zig slower everywhere for everyone.

PR: 269206

Diff Detail

Repository
rP FreeBSD ports repository
Lint
No Lint Coverage
Unit
No Test Coverage
Build Status
Buildable 49342
Build 46232: arc lint + arc unit

Event Timeline

dch requested review of this revision.Jan 30 2023, 8:29 PM

use suggested trick from irc zig channel

dch retitled this revision from lang/zig: provide build-time toggle for old PCs to lang/zig: force baseline instead of native compilation.Jan 30 2023, 9:05 PM
dch edited the summary of this revision. (Show Details)

According to https://github.com/ziglang/zig/blob/master/CMakeLists.txt#L115 ZIG_TARGET_MCPU also gets used for compiler switch -mcpu= so what you could possibly do is mapping it to ${CPUTYPE} (https://cgit.freebsd.org/src/tree/share/examples/etc/make.conf?h=releng/13.1#n56) if its undefined.
Is mcpu/mtune=baseline defined anywhere? I found option generic documented but that seems like it's going to change between compiler versions.

Does this obsolete -Dcpu=${CPUTYPE:Ubaseline} in consumers like x11-wm/river?

lang/zig/Makefile
31

How CMAKE_FLAGS is passed to the build script? USES=cmake has CMAKE_ARGS but not CMAKE_FLAGS.

Also, the type can be annotated e.g., -DZIG_TARGET_MCPU:STRING=baseline.

amend flags after IRC convo with zig devs and ok from zig users

dch marked an inline comment as done.

the --verbose addition allows seeing after the build, in the logs, what tuples were chosen.

lang/zig/Makefile
31

this has since been fixed locally but not pushed up to phab. I'm not familiar with type annotations but
apparently clang or cmake can infer a string. I'll roll with whatever's done in general in ports.

This revision is now accepted and ready to land.Feb 4 2023, 11:17 PM
dch marked an inline comment as done.Feb 4 2023, 11:17 PM