Skip to content

[herd] Expose herd as a dune library#1905

Merged
fsestini merged 1 commit into
herd:masterfrom
fsestini:herd-core-lib
Jul 10, 2026
Merged

[herd] Expose herd as a dune library#1905
fsestini merged 1 commit into
herd:masterfrom
fsestini:herd-core-lib

Conversation

@fsestini

@fsestini fsestini commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

This PR implements step 4 of the plan documented in issue #1782: it makes herd available as a dune library, herd_core, so that other OCaml tools in the repository can depend on its internals directly.

Note that the broader plan to make herd's core code properly library-like and client-agnostic is still work in progress. In other words, this PR does not claim to provide a polished or stable API, nor does it address all remaining issues and TODOs described in the aforementioned issue #1782.

That said, the API that herd does currently offer (mainly through its modules ParseTest and Top_herd) is already useful enough for other internal tools to take advantage of it. See, for example, my upcoming tool litmus2desc (#1903), which runs herd directly in OCaml via the herd_core library added here.

Since the proposed herd_core library is intended for internal use only (at least of now), I think it is reasonable to expose it now as an incremental step, while continuing the remaining refactoring work tracked in #1782.

Let me know your thoughts.

PS: This PR also updates herd/rc11.ml to use explicit namespacing for record field accessors. Adding the module to the wrapped herd_core library made the compiler report warnings 40 and 42 for various record accesses. The PR only adds explicit module names to those field accesses, it does not change any of the logic. As an aside, rc11.ml does not currently appear to be used anywhere in herd.

@HadrienRenaud HadrienRenaud left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hi @fsestini, this looks good to me, I don't see any negative to this.

By curiosity, did you notice a difference in compilation time (from clean or just with small edits)?

@fsestini

fsestini commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator Author

Hi @fsestini, this looks good to me, I don't see any negative to this.

By curiosity, did you notice a difference in compilation time (from clean or just with small edits)?

Thanks @HadrienRenaud . I did not felt a noticeable difference as I was developing, but did not measure it. I've now run a simple time measurement, both from clean. The difference seems mostly noise:

This PR:
dune build herd/herd.exe  136.25s user 26.95s system 509% cpu 32.016 total

master:
dune build herd/herd.exe  134.48s user 26.46s system 490% cpu 32.804 total

Comment thread herd/dune

(executable
(name herd)
(public_name herd7)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Are there any plans on having more opam metadata files on the top level? it might be worth adding (package herdtools7) if that's the case

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Are there any plans on having more opam metadata files on the top level? it might be worth adding (package herdtools7) if that's the case

Added: 92904d8

Comment thread herd/dune Outdated
(libraries unix herdtools)
(wrapped true)
(modules
(:standard \ herd cli lexConf_herd itimer))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is more of a question than a concern. Shouldn't lexConf_herd be part of the library? For example www also needs it. Is there any herd interface that wouldn't need it?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, you're right.

@relokin relokin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks Filippo!

@fsestini fsestini merged commit 930caaf into herd:master Jul 10, 2026
3 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.

4 participants