diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index e4d77d8a3..848ccdcca 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -473,14 +473,11 @@ jobs: submodules: true - name: Build - run: zig build + run: zig build -Dsupport_jit - name: Test run: | - # Zig does something weird with the stack - it uses more space than the - # equivalent plain C program. - ulimit -S -s 65536 - srcdir=`pwd` pcre2test=`pwd`/zig-out/bin/pcre2test ./RunTest + srcdir=`pwd` pcre2test=`pwd`/zig-out/bin/pcre2test ./RunTest -bigstack bazel: # Tests with: Bazel build system diff --git a/build.zig b/build.zig index 51427d9dd..94cea6415 100644 --- a/build.zig +++ b/build.zig @@ -11,7 +11,7 @@ pub fn build(b: *std.Build) !void { const optimize = b.standardOptimizeOption(.{}); const linkage = b.option(std.builtin.LinkMode, "linkage", "whether to statically or dynamically link the library") orelse @as(std.builtin.LinkMode, if (target.result.isGnuLibC()) .dynamic else .static); const codeUnitWidth = b.option(CodeUnitWidth, "code-unit-width", "Sets the code unit width") orelse .@"8"; - const jit = b.option(bool, "JIT", "Enable/disable JIT compiler support") orelse false; + const jit = b.option(bool, "support_jit", "Enable/disable JIT compiler support") orelse false; const pcre2_header_dir = b.addWriteFiles(); const pcre2_header = pcre2_header_dir.addCopyFile(b.path("src/pcre2.h.generic"), "pcre2.h"); @@ -26,6 +26,11 @@ pub fn build(b: *std.Build) !void { .HAVE_UNISTD_H = (target.result.os.tag != .windows), .HAVE_WINDOWS_H = (target.result.os.tag == .windows), + .HAVE_ATTRIBUTE_UNINITIALIZED = true, + .HAVE_BUILTIN_MUL_OVERFLOW = true, + .HAVE_BUILTIN_UNREACHABLE = true, + .HAVE_VISIBILITY = true, + .HAVE_MEMMOVE = true, .HAVE_STRERROR = true, @@ -48,7 +53,7 @@ pub fn build(b: *std.Build) !void { }, ); - // pcre2-8/16/32.so + // pcre2-8/16/32 library const lib_mod = b.createModule(.{ .target = target, @@ -122,11 +127,11 @@ pub fn build(b: *std.Build) !void { .link_libc = true, }); - pcre2test_mod.addImport(b.fmt("pcre2-{s}", .{@tagName(codeUnitWidth)}), lib_mod); - pcre2test_mod.addCMacro("HAVE_CONFIG_H", ""); if (linkage == .static) { pcre2test_mod.addCMacro("PCRE2_STATIC", ""); + } else { + pcre2test_mod.addCMacro("PCRE2POSIX_SHARED", ""); } const pcre2test = b.addExecutable(.{ @@ -134,7 +139,7 @@ pub fn build(b: *std.Build) !void { .root_module = pcre2test_mod, }); - // pcre2-posix.so + // pcre2-posix library if (codeUnitWidth == CodeUnitWidth.@"8") { const posixLib_mod = b.createModule(.{ @@ -143,12 +148,12 @@ pub fn build(b: *std.Build) !void { .link_libc = true, }); - pcre2test_mod.addImport("pcre2_posix", posixLib_mod); - posixLib_mod.addCMacro("HAVE_CONFIG_H", ""); posixLib_mod.addCMacro("PCRE2_CODE_UNIT_WIDTH", @tagName(codeUnitWidth)); if (linkage == .static) { posixLib_mod.addCMacro("PCRE2_STATIC", ""); + } else { + posixLib_mod.addCMacro("PCRE2POSIX_SHARED", ""); } const posixLib = b.addLibrary(.{ @@ -167,8 +172,12 @@ pub fn build(b: *std.Build) !void { }, }); + posixLib.linkLibrary(lib); + posixLib.installHeader(b.path("src/pcre2posix.h"), "pcre2posix.h"); b.installArtifact(posixLib); + + pcre2test.linkLibrary(posixLib); } // pcre2test (again) @@ -181,5 +190,7 @@ pub fn build(b: *std.Build) !void { .file = b.path("src/pcre2test.c"), }); + pcre2test.linkLibrary(lib); + b.installArtifact(pcre2test); }