Skip to content

Commit 58d5b89

Browse files
committed
add zig-0.14.0
1 parent ada73db commit 58d5b89

12 files changed

+653
-0
lines changed

build/zig/build-0.14.sh

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
#!/usr/bin/bash
2+
#
3+
# {{{ CDDL HEADER
4+
#
5+
# This file and its contents are supplied under the terms of the
6+
# Common Development and Distribution License ("CDDL"), version 1.0.
7+
# You may only use this file in accordance with the terms of version
8+
# 1.0 of the CDDL.
9+
#
10+
# A full copy of the text of the CDDL should have accompanied this
11+
# source. A copy of the CDDL is also available via the Internet at
12+
# http://www.illumos.org/license/CDDL.
13+
# }}}
14+
15+
# Copyright 2024 OmniOS Community Edition (OmniOSce) Association.
16+
17+
. ../../lib/build.sh
18+
19+
PROG=zig
20+
VER=0.14.0
21+
MAJVER=${VER%%.*}
22+
MINVER=${VER%.*}
23+
MINVER=${MINVER#*.}
24+
PKG=ooce/developer/zig-014
25+
SUMMARY="$PROG programming language"
26+
DESC="$PROG is a general-purpose programming language and toolchain for "
27+
DESC+="maintaining robust, optimal, and reusable software."
28+
29+
min_rel 151052
30+
31+
#
32+
# Zig 0.14.x requires LLVM 19.1.7
33+
#
34+
set_clangver 19
35+
set_arch 64
36+
37+
CLANGFVER=`pkg_ver clang build-$CLANGVER.sh`
38+
39+
set_patchdir patches-$MAJVER.$MINVER
40+
OPREFIX=$PREFIX
41+
PREFIX+=/$PROG-$MAJVER.$MINVER
42+
43+
XFORM_ARGS="
44+
-DOPREFIX=${OPREFIX#/}
45+
-DPREFIX=${PREFIX#/}
46+
-DPROG=$PROG
47+
-DPKGROOT=$PROG-$MAJVER.$MINVER
48+
-DMEDIATOR=$PROG -DMEDIATOR_VERSION=$MAJVER.$MINVER
49+
"
50+
51+
#
52+
# CMAKE_BUILD_TYPE=RelWithDebInfo
53+
#
54+
# Keep debug info so symbols are available to the various
55+
# debugging tools.
56+
#
57+
# ZIG_STATIC_LLVM=on
58+
#
59+
# Embed the LLVM toolchain in the zig executable. This is
60+
# the preferred way to ship zig.
61+
#
62+
# ZIG_TARGET_MCPU=baseline
63+
#
64+
# Target the compiler to pentium4-era CPU features so it can
65+
# work on the maximum set of hosts. This only effects the
66+
# compiler executable, applications built with this compiler
67+
# can set their own CPU features.
68+
#
69+
CONFIGURE_OPTS[amd64]="
70+
-DCMAKE_BUILD_TYPE=RelWithDebInfo
71+
-DCMAKE_INSTALL_PREFIX=$PREFIX
72+
-DLLVM_INCLUDE_DIRS=$OPREFIX/llvm-$CLANGVER/include
73+
-DCLANG_INCLUDE_DIRS=$OPREFIX/llvm-$CLANGVER/include
74+
-DLLVM_LIBDIRS=$OPREFIX/llvm-$CLANGVER/lib
75+
-DCLANG_LIBDIRS=$OPREFIX/llvm-$CLANGVER/lib
76+
-DZIG_STATIC_LLVM=on
77+
-DZIG_TARGET_MCPU="baseline"
78+
"
79+
80+
init
81+
82+
#########################################################################
83+
# Download and build lld
84+
85+
save_buildenv
86+
87+
set_builddir llvm-project-$CLANGFVER.src/lld
88+
prep_build cmake+ninja
89+
90+
CONFIGURE_OPTS[amd64]="
91+
-DCMAKE_BUILD_TYPE=Release
92+
-DLLVM_MAIN_SRC_DIR=$TMPDIR/llvm-project-$CLANGFVER.src/llvm
93+
"
94+
95+
build_dependency -noctf lld-$CLANGVER llvm-project-$CLANGFVER.src/lld \
96+
llvm llvm-project $CLANGFVER.src
97+
98+
restore_buildenv
99+
100+
CONFIGURE_OPTS[amd64]+="
101+
-DLLD_INCLUDE_DIRS=$DEPROOT/usr/local/include
102+
-DLLD_LIBDIRS=$DEPROOT/usr/local/lib
103+
"
104+
105+
#########################################################################
106+
107+
note -n "Building $PROG"
108+
109+
set_builddir $PROG-$VER
110+
111+
CXXFLAGS+=" -fPIC"
112+
113+
download_source $PROG $PROG $VER
114+
patch_source
115+
prep_build cmake+ninja
116+
build -noctf # C++
117+
strip_install
118+
make_package
119+
clean_up
120+
121+
# Vim hints
122+
# vim:ts=4:sw=4:et:fdm=marker
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
From 841366f6c53387fd598a9f5b47f50a5334bb9b95 Mon Sep 17 00:00:00 2001
2+
From: Ryan Zezeski <[email protected]>
3+
Date: Fri, 14 Mar 2025 16:27:14 -0400
4+
Subject: [PATCH] add arc4random_buf
5+
6+
Add support for arc4random_buf to avoid relying on zig's internal
7+
tlcsprng implementation as there seems to be some flakiness with it's
8+
use of threadlocal when using the build runner to build the zig stage3
9+
compiler (see error below). This only works when the program is linked
10+
with libc, as should always be the case on illumos.
11+
12+
[19/19] Building stage3
13+
FAILED: stage3/bin/zig /tmp/build_rpz/zig-0.14.0/zig-0.14.0/zig-0.14.0-build/build.amd64/stage3/bin/zig
14+
15+
cd /tmp/build_rpz/zig-0.14.0/zig-0.14.0/zig-0.14.0 && /tmp/build_rpz/zig-0.14.0/zig-0.14.0/zig-0.14.0-b
16+
uild/build.amd64/zig2 build --prefix /tmp/build_rpz/zig-0.14.0/zig-0.14.0/zig-0.14.0-build/build.amd64/
17+
stage3 --zig-lib-dir /tmp/build_rpz/zig-0.14.0/zig-0.14.0/zig-0.14.0/lib -Dversion-string=0.14.0 -Dtarg
18+
et=native -Dcpu=baseline -Denable-llvm -Dconfig_h=/tmp/build_rpz/zig-0.14.0/zig-0.14.0/zig-0.14.0-build
19+
/build.amd64/config.h -Dno-langref -Doptimize=ReleaseFast
20+
Segmentation fault at address 0xfffffc7feeccf448
21+
/tmp/build_rpz/zig-0.14.0/zig-0.14.0/zig-0.14.0/lib/std/crypto/tlcsprng.zig:59:9: 0x1593a4f in tlsCsprn
22+
gFill (build)
23+
if (wipe_mem.len == 0) {
24+
^
25+
/tmp/build_rpz/zig-0.14.0/zig-0.14.0/zig-0.14.0/lib/std/Random.zig:58:13: 0x15efbe1 in bytes (build)
26+
r.fillFn(r.ptr, buf);
27+
^
28+
/tmp/build_rpz/zig-0.14.0/zig-0.14.0/zig-0.14.0/lib/std/fs/AtomicFile.zig:26:32: 0x15e84d5 in init (bui
29+
ld)
30+
std.crypto.random.bytes(rand_buf[0..]);
31+
^
32+
/tmp/build_rpz/zig-0.14.0/zig-0.14.0/zig-0.14.0/lib/std/fs/Dir.zig:2657:31: 0x15e8099 in atomicFile (bu
33+
ild)
34+
return AtomicFile.init(fs.path.basename(dest_path), options.mode, dir, true);
35+
^
36+
/tmp/build_rpz/zig-0.14.0/zig-0.14.0/zig-0.14.0/lib/std/fs/Dir.zig:2541:46: 0x15e8ca0 in updateFile (bu
37+
ild)
38+
var atomic_file = try dest_dir.atomicFile(dest_path, .{ .mode = actual_mode });
39+
^
40+
/tmp/build_rpz/zig-0.14.0/zig-0.14.0/zig-0.14.0/lib/std/Build/Step/InstallDir.zig:111:54: 0x1574176 in
41+
make (build)
42+
const prev_status = fs.Dir.updateFile(
43+
^
44+
/tmp/build_rpz/zig-0.14.0/zig-0.14.0/zig-0.14.0/lib/std/Build/Step.zig:231:13: 0x15545ff in make (build
45+
)
46+
s.makeFn(s, options) catch |err| switch (err) {
47+
^
48+
/tmp/build_rpz/zig-0.14.0/zig-0.14.0/zig-0.14.0/lib/compiler/build_runner.zig:1105:31: 0x151ca08 in workerMakeOneStep (build)
49+
const make_result = s.make(.{
50+
^
51+
/tmp/build_rpz/zig-0.14.0/zig-0.14.0/zig-0.14.0/lib/std/Thread/Pool.zig:119:39: 0x151d3d3 in runFn (build)
52+
@call(.auto, func, closure.arguments);
53+
^
54+
/tmp/build_rpz/zig-0.14.0/zig-0.14.0/zig-0.14.0/lib/std/Thread/Pool.zig:295:32: 0x159da4c in worker (build)
55+
run_node.data.runFn(&run_node.data, id);
56+
^
57+
/tmp/build_rpz/zig-0.14.0/zig-0.14.0/zig-0.14.0/lib/std/Thread.zig:488:13: 0x155323a in callFn__anon_100548 (build)
58+
@call(.auto, f, args);
59+
^
60+
/tmp/build_rpz/zig-0.14.0/zig-0.14.0/zig-0.14.0/lib/std/Thread.zig:757:30: 0x151c29e in entryFn (build)
61+
return callFn(f, args_ptr.*);
62+
^
63+
???:?:?: 0xfffffc7fef057326 in ??? (libc.so.1)
64+
Unwind information for `libc.so.1:0xfffffc7fef057326` was not available, trace may be incomplete
65+
66+
???:?:?: 0xfffffc7fef05766f in ??? (libc.so.1)
67+
???:?:?: 0x0 in ??? (???)
68+
error: the following build command crashed:
69+
/tmp/build_rpz/zig-0.14.0/zig-0.14.0/zig-0.14.0/.zig-cache/o/7d72ec58c6f1742b1ecb4d994da3a6df/build /tmp/build_rpz/zig-0.14.0/zig-0.14.0/zig-0.14.0-build/build.amd64/zig2 /tmp/build_rpz/zig-0.14.0/zig-0.14.0/zig-0.14.0/lib /tmp/build_rpz/zig-0.14.0/zig-0.14.0/zig-0.14.0 /tmp/build_rpz/zig-0.14.0/zig-0.14.0/zig-0.14.0/.zig-cache /export/home/rpz/.cache/zig --seed 0x97ac69e3 -Zb9a9429c1f2e840d --prefix /tmp/build_rpz/zig-0.14.0/zig-0.14.0/zig-0.14.0-build/build.amd64/stage3 -Dversion-string=0.14.0 -Dtarget=native -Dcpu=baseline -Denable-llvm -Dconfig_h=/tmp/build_rpz/zig-0.14.0/zig-0.14.0/zig-0.14.0-build/build.amd64/config.h -Dno-langref -Doptimize=ReleaseFast
70+
ninja: build stopped: subcommand failed.
71+
--- Make failed
72+
---
73+
lib/std/c.zig | 2 +-
74+
1 file changed, 1 insertion(+), 1 deletion(-)
75+
76+
diff --git a/lib/std/c.zig b/lib/std/c.zig
77+
index 9b7d36cb32..ad741407fd 100644
78+
--- a/lib/std/c.zig
79+
+++ b/lib/std/c.zig
80+
@@ -9327,7 +9327,7 @@ pub extern "c" fn sendfile64(out_fd: fd_t, in_fd: fd_t, offset: ?*i64, count: us
81+
pub extern "c" fn setrlimit64(resource: rlimit_resource, rlim: *const rlimit) c_int;
82+
83+
pub const arc4random_buf = switch (native_os) {
84+
- .dragonfly, .netbsd, .freebsd, .solaris, .openbsd, .macos, .ios, .tvos, .watchos, .visionos => private.arc4random_buf,
85+
+ .dragonfly, .netbsd, .freebsd, .illumos, .solaris, .openbsd, .macos, .ios, .tvos, .watchos, .visionos => private.arc4random_buf,
86+
else => {},
87+
};
88+
pub const getentropy = switch (native_os) {
89+
--
90+
2.43.0
91+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
From aa7fc1c9d627957e5c7df8a90e8613d8d4f78069 Mon Sep 17 00:00:00 2001
2+
From: Ryan Zezeski <[email protected]>
3+
Date: Thu, 13 Mar 2025 19:46:46 -0400
4+
Subject: [PATCH] fix watch init
5+
6+
I'm not sure how this was ever supposed to compile on platforms that
7+
don't implement the Watch API.
8+
---
9+
lib/std/Build/Watch.zig | 2 +-
10+
1 file changed, 1 insertion(+), 1 deletion(-)
11+
12+
diff --git a/lib/std/Build/Watch.zig b/lib/std/Build/Watch.zig
13+
index 2ddb3ca4c2..aa94a73f37 100644
14+
--- a/lib/std/Build/Watch.zig
15+
+++ b/lib/std/Build/Watch.zig
16+
@@ -819,7 +819,7 @@ const Os = switch (builtin.os.tag) {
17+
};
18+
19+
pub fn init() !Watch {
20+
- return Os.init();
21+
+ return if (Os != void) Os.init() else error.Unsupported;
22+
}
23+
24+
pub const Match = struct {
25+
--
26+
2.43.0
27+

0 commit comments

Comments
 (0)