Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dune-build-info: spurious git describe output instead of version string #11225

Open
ydirson opened this issue Dec 18, 2024 · 0 comments
Open

Comments

@ydirson
Copy link

ydirson commented Dec 18, 2024

Context

Build of a package for an ocaml product, where the source tarball gets unpacked in a build tree inside a git-managed tree. In our case it is a RPM build, but the default setup for a Yocto tree would be similar.

Expected Behavior

When dune-project has a (version whatever) statement, this doc makes me expect to get that that version in build_info

Actual Behavior

The binaries get a git describe string instead of the version specified in dune-project.

On a CentOS 7 base, this happens only when the git tree is actually dirty, which makes me wonder whether the doc matches the actual behavior; on AlmaLinux 10 with the same ocaml and dune versions starting with the same clean git tree, after the dune install run the tree is seen as dirty with no actual diff (by git diff-index HEAD and gitk), and git update-index --refresh (or git status) syncs back the index and confirms no actual diff is present.

Since the git tree under which the build occurs is not the one for the package, it would make sense to use the GIT_CEILING_DIRECTORIES envvar to prevent git from looking in the directory above the one containing dune-project. This could possibly be a job for dune itself, but as of today I would have to set it myself... but AFAICT this envvar does not get propagated by dune to child processes, so this workaround is also unavailable.

  • even with a version statement in dune-project a call to git describe is issued
  • as an added woe, setting GIT_CEILING_DIRECTORIES in environment to protect from git describe looking at an unrelated history has no effect (could it be that
    let ic, oc, ec = Unix.open_process_args_full path args (Unix.environment ()) in
    purges the environment?)

Reproduction

Starting from a dune init project and adding the code from the doc, my reproduction attempts are blocked by the lack of DUNE_PLACEHOLDER in the resulting binary - however, the program indeed accesses the version, as if the version string was hardcoded from the start. Help on this gladly accepted :)

Specifications

  • Version of dune (output of dune --version): 3.15.3
  • Version of ocaml (output of ocamlc --version): 4.14.2
  • Operating system (distribution and version): AlmaLinux 10 beta (and CentOS 7)

Additional information

For now the only workaround seem to be patching the dune-installed binaries to replace the spurious git describe output with the actual version string.

Wrapping up

There are indeed several items coming out of the initial symptom, maybe it would be worth opening separate issues for those?

  • undocumented precedence of git describe on explicit version when the tree is dirty
  • lack of ability to use DUNE_PLACEHOLDER envvar
  • possible use of DUNE_PLACEHOLDER directly by dune
  • dune install dirtying the git tree
  • reproduction of DUNE_PLACEHOLDER use (and possibly extend the documentation to help with its understanding)
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

No branches or pull requests

1 participant