Skip to content

Conversation

@qaptoR
Copy link
Contributor

@qaptoR qaptoR commented Mar 7, 2025

fixes #722

notable changes are that .root_module fields needs dedicated *Module structs created (cannot be anonymous.

additionally, those modules are now how we add the C macros to the files being compiled.

also, for the pcre2test executable that we build, instead of having linkLibrary steps, I've directly added the pcre2 and posix modules as imports into the .root_module of the executable.

lastly, two new default values were necessary to give values: PCRE2GREP_BUFSIZE and _MAX_BUFSIZE for the config_header.

None of this was explicitly outlined in the zig documentation. It was inferred from the std.Build, std.Build.Compile, and std.Build.Module listings in the zig std Library reference.

Copy link
Member

@NWilson NWilson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You or I will also need to update the CI build to validate this against 0.14. +My mistake - the CI is already using Zig "latest" so it has started testing against 0.14 already.+

I don't know Zig at all, so I'll just leave this PR open for a few days (or a week maybe?) in case anyone else from the Zig community comes by to comment.

Then I'll merge it, if it all builds and the tests pass.

build.zig Outdated
const config_header = b.addConfigHeader(
.{
.style = .{ .cmake = b.path("src/config-cmake.h.in") },
.style = .{ .cmake = b.path("config-cmake.h.in") },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a couple of regressions, here and below "pcre2_compile_cgroup.c".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh! i see what you mean now. took me a while to understand this (namely figuring out that I wasn't on master!)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that we won't target PRs at old release branches like 10.45. Aiming for master is correct, since the next release will come from there.

build.zig Outdated
const pcre2test = b.addExecutable(.{
.name = "pcre2test",
.root_module = pcre2test_mod,
.linkage = linkage,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does "linkage" mean for an executable? Altering the linkage to choose between libpcre2-8.{so,a} shouldn't force a property change on the pcre2test binary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another great question. This was likely added in an effort to fix some error messages when I hadn't yet removed the previous linkLibrary() steps.

I inferred the necessity by the executeable simply having the field at all, and the fact that we were 'linking libraries'. But once I switched to Importing the libraries into the pcre2test module, that likely was no longer a meaningful inference. I'll also test this now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it does seem like this is a redundant line, likely because we are importing now, instead of linking. likely whatever error it initially suppressed was a red herring.

@qaptoR
Copy link
Contributor Author

qaptoR commented Mar 7, 2025

@NWilson Definitely pause on merging.

I naively made this pull request assuming the build worked on master, but I forgot that the repo I was using to rewrite the build.zig file was a release/10.45 branch (that I got following the steps in the Sheran test repo I had mentioned earlier).

It looks like the build.zig is failing now on master because of a missing config-cmake.h.in.
Looking at the directory listing of both branches, it looks like there's more changes to the build system.

so. this PR should be for the 10.45 branch. or just be halted until I can figure out how to do without those files.

EDIT:
okay, as I said above, It's all making more sense once I put your comment about regressions together with this revelation.

It IS building now on master, so I'll push those changes, as well as the removal of the .linkage redundant line

@qaptoR qaptoR force-pushed the update_zig_build_0.14 branch from be9f687 to 89b5f95 Compare March 7, 2025 16:24
@NWilson NWilson changed the title update build.zig for release of 0.14.0 breaking langugage changes update build.zig for release of 0.14.0 breaking language changes Mar 15, 2025
@NWilson
Copy link
Member

NWilson commented Mar 17, 2025

Thank you @qaptoR for these changes! I will merge them. Enough time has passed and no-one else has said anything.

I can see a few small things that could be cleaned up, now that we only support Zig 0.14 (this PR drops support for Zig 0.13, which is probably OK). I'll do those in a follow-up PR.

@NWilson NWilson merged commit fa68936 into PCRE2Project:master Mar 17, 2025
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update build.zig against breaking changes in 0.14.0 release

2 participants