Skip to content

fix: non-cppflags version of adding the git version string to dart - #1187

Open
hkershaw-brown wants to merge 1 commit into
mainfrom
fix-version
Open

hkershaw-brown wants to merge 1 commit into
mainfrom
fix-version

Conversation

@hkershaw-brown

@hkershaw-brown hkershaw-brown commented Sep 2, 2026 •

Copy link
Copy Markdown
Collaborator

Description:

non-cppflags version of adding the git version string to dart
Buildfunction dartversion now writes the module with the dart version string. The cppdefs version string was not surviing certain mpiifort compiler wrappers. Rather than keep adding escapes \\, to get the string preprocessed, this pull request creates the version_mod.f90 file during the build.

temp file created with temp.$$ to avoid race condition creating the file (when multiple quickbuilds are run simultaneously)
Sanitizing the string for funky characters and trimming just incase people get creating with tags. Note I am in two minds about whether this should be bash substitution since we already use bash substitution elsewhere in the buildfunctions.

git_version="${git_version//[^A-Za-z0-9._+-]/_}" 
git_version="${git_version:0:64}" 

Currently checking whether the version has changed before overwriting version_mod.f90. Quickbuild.sh removes all .o and .mod so stuff gets rebuild anyway, but possibly at somepoint we may be more sensible about compiling.
removes the -c from the mkmf calls in the build functions.

Fixes issue

fixes #1164

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Documentation changes needed?

  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.

Tests

Please describe any tests you ran to verify your changes.
I am testing the builds with CIRRUS on this pull request.
Still to test:

  • outofcore builds
  • funky tags
  • run all quickbuild.sh on Derecho

Checklist for merging

  • Updated changelog entry
  • Documentation updated
  • Update conf.py

Checklist for release

  • Merge into main
  • Create release from the main branch with appropriate tag
  • Delete feature-branch

Testing Datasets

  • Dataset needed for testing available upon request
  • Dataset download instructions included
  • No dataset needed

@hkershaw-brown

Copy link
Copy Markdown
Collaborator Author

Note we cannot be more sensible about compiling without the other race condition (obs_def_mod, obs_kind_mod) when preprocess out-of-the-box in dart is writing the same file for all dart builds.

@hkershaw-brown hkershaw-brown added the build-system issues related to building dart label Sep 2, 2026
@mjs2369
mjs2369 self-requested a review September 10, 2026 18:14

@mjs2369 mjs2369 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 @hkershaw-brown I failed your challenge and could not break this code, so kudos

The value of git_version is now read as plain text with the printf and string format directive; this means it can't be read as a format string or interpreted as pure fortran code like in the issue share by our user.

And I think we are protected from edge cases in the git_version as well, since you replace all characters that aren't a letter, digit, or ., _, +,- with underscores; this command is also performed in posix so the character classification is in plain ASCII.

I also went ahead and did run_all quickbuilds on Derecho and the results were identical with those on main (10 FAILED for each compiler, except ifx which also fails for GSI2DART and therefore is 11)

I think this is ready to go!

P.S. I learned some cool things reviewing this PR

@hkershaw-brown
hkershaw-brown marked this pull request as draft October 6, 2026 19:58
@hkershaw-brown
hkershaw-brown marked this pull request as ready for review October 6, 2026 20:00
Buildfunction dartversion now writes the module with the dart version
string. The cppdefs version string was not surviing certain mpiifort
compiler wrappers.

fixes #1164

temp file created with temp.$$ to avoid race condition creating the file
(when multiple quickbuilds are run simultanously)
stanitizing the string for funky characters.
removes the -c from the mkmf calls

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build-system issues related to building dart

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Build failure with mpiifort: DART_VERSION macro loses quotes in version_mod.F90

2 participants