Skip to content

Commit 03a00fd

Browse files
authored
A few further tweaks to Zig 0.14 support (#731)
Followup to #722 * Fix Windows build warning by adding PCRE2_STATIC to pcre2test * Remove unnecessary `.linkLibc()` command, now that we have `link_libc = true` in the Module declarations * Update the old `std.Build.Step.Compile.create(...)` calls to the brand-new `b.addLibrary(...)` function. They added this exactly for our use-case, to allow dynamically selecting between `addStaticLibrary/addDynamicLibrary` variants. * Bump zig stack usage in CI
1 parent 3a4310e commit 03a00fd

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

.github/workflows/dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ jobs:
432432
run: |
433433
# Zig does something weird with the stack - it uses more space than the
434434
# equivalent plain C program.
435-
ulimit -S -s 16384
435+
ulimit -S -s 65536
436436
srcdir=`pwd` pcre2test=`pwd`/zig-out/bin/pcre2test ./RunTest
437437
438438
bazel:

build.zig

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,14 @@ pub fn build(b: *std.Build) !void {
4141
.PCRE2_MAX_VARLOOKBEHIND = 255,
4242
.NEWLINE_DEFAULT = 2,
4343
.PCRE2_PARENS_NEST_LIMIT = 250,
44-
4544
.PCRE2GREP_BUFSIZE = 20480,
4645
.PCRE2GREP_MAX_BUFSIZE = 1048576,
4746
},
4847
);
4948

5049
// pcre2-8/16/32.so
5150

52-
const lib_mod = std.Build.Module.create(b, .{
51+
const lib_mod = b.createModule(.{
5352
.target = target,
5453
.optimize = optimize,
5554
.link_libc = true,
@@ -61,10 +60,9 @@ pub fn build(b: *std.Build) !void {
6160
lib_mod.addCMacro("PCRE2_STATIC", "");
6261
}
6362

64-
const lib = std.Build.Step.Compile.create(b, .{
63+
const lib = b.addLibrary(.{
6564
.name = b.fmt("pcre2-{s}", .{@tagName(codeUnitWidth)}),
6665
.root_module = lib_mod,
67-
.kind = .lib,
6866
.linkage = linkage,
6967
});
7068

@@ -115,14 +113,18 @@ pub fn build(b: *std.Build) !void {
115113

116114
// pcre2test
117115

118-
const pcre2test_mod = std.Build.Module.create(b, .{
116+
const pcre2test_mod = b.createModule(.{
119117
.target = target,
120118
.optimize = optimize,
121119
.link_libc = true,
122-
.imports = &.{std.Build.Module.Import{ .name = b.fmt("pcre2-{s}", .{@tagName(codeUnitWidth)}), .module = lib_mod }},
123120
});
124121

122+
pcre2test_mod.addImport(b.fmt("pcre2-{s}", .{@tagName(codeUnitWidth)}), lib_mod);
123+
125124
pcre2test_mod.addCMacro("HAVE_CONFIG_H", "");
125+
if (linkage == .static) {
126+
pcre2test_mod.addCMacro("PCRE2_STATIC", "");
127+
}
126128

127129
const pcre2test = b.addExecutable(.{
128130
.name = "pcre2test",
@@ -132,7 +134,7 @@ pub fn build(b: *std.Build) !void {
132134
// pcre2-posix.so
133135

134136
if (codeUnitWidth == CodeUnitWidth.@"8") {
135-
const posixLib_mod = std.Build.Module.create(b, .{
137+
const posixLib_mod = b.createModule(.{
136138
.target = target,
137139
.optimize = optimize,
138140
.link_libc = true,
@@ -146,10 +148,9 @@ pub fn build(b: *std.Build) !void {
146148
posixLib_mod.addCMacro("PCRE2_STATIC", "");
147149
}
148150

149-
const posixLib = std.Build.Step.Compile.create(b, .{
151+
const posixLib = b.addLibrary(.{
150152
.name = "pcre2-posix",
151153
.root_module = posixLib_mod,
152-
.kind = .lib,
153154
.linkage = linkage,
154155
});
155156

@@ -177,7 +178,5 @@ pub fn build(b: *std.Build) !void {
177178
.file = b.path("src/pcre2test.c"),
178179
});
179180

180-
pcre2test.linkLibC();
181-
182181
b.installArtifact(pcre2test);
183182
}

0 commit comments

Comments
 (0)