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
Unknown Object (File)
Thu, May 2, 1:12 PM
Unknown Object (File)
Fri, Apr 26, 1:25 PM
Unknown Object (File)
Thu, Apr 25, 9:31 PM
Unknown Object (File)
Fri, Apr 12, 6:11 AM
Unknown Object (File)
Fri, Apr 12, 5:38 AM
Unknown Object (File)
Mar 12 2024, 6:07 PM
Unknown Object (File)
Mar 5 2024, 7:10 AM
Unknown Object (File)
Feb 16 2024, 2:10 PM
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
R11 FreeBSD ports repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

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