Skip to content

[6.30] Backport fix of argument passing conventions for hbook#22574

Merged
hageboeck merged 5 commits into
root-project:v6-30-00-patchesfrom
hageboeck:hbook_6.30
Jun 11, 2026
Merged

[6.30] Backport fix of argument passing conventions for hbook#22574
hageboeck merged 5 commits into
root-project:v6-30-00-patchesfrom
hageboeck:hbook_6.30

Conversation

@hageboeck

Copy link
Copy Markdown
Member

guitargeek and others added 5 commits June 11, 2026 10:51
According to the `gfortran` argument passing conventions, for any
Fortran procedure, the compiler will automatically define a C prototype.
This is what we use in `h2root`.

Note that for procedures like `HROPEN` that takes string arguments, the
signature of the C prototype will have extra arguments for the string
lengths, which we also have to include in our forward declaration and
usage. However, the type of these was changed with GCC 8 to size_t, so
we have to also account for that as recommended in [1]. Otherwise, we
get undefined behavor, which causes the `h2root` test to fail on ARM64
with GCC 14.

[1] https://gcc.gnu.org/onlinedocs/gfortran/Argument-passing-conventions.html

(cherry picked from commit aafddfb)
(cherry picked from commit f10c0ac)
Follow-up of root-project@aafddfb

(cherry picked from commit 34af31c)
(cherry picked from commit bcdd4fb)
When variable-length strings are passed into functions compiled by
gfortran, the lengths of the strings have to be passed at the end of the
argument list as size_t. When using gcc <= 7 or clang (where the
__GNUC__ macro might return unpredictable values), we were putting int on
the C side, which got interpreted as size_t on the fortran side.

(cherry picked from commit 3a9316e)
(cherry picked from commit 575fa7d)
Follow-up of root-project#20535

(cherry picked from commit 4ac2999)
(cherry picked from commit 3c3717f)
When variable-length strings are passed into functions compiled by
gfortran, the lengths of the strings have to be passed at the end of the
argument list as size_t. When using gcc <= 7 or clang (where the
__GNUC__ macro might return unpredictable values), we were putting int on
the C side, which got interpreted as size_t on the fortran side.

(cherry picked from commit 19fdba0)
(cherry picked from commit ed8a5dd)
@hageboeck hageboeck requested a review from dpiparo June 11, 2026 08:53
@hageboeck hageboeck self-assigned this Jun 11, 2026
@hageboeck hageboeck requested review from lmoneta and pcanal as code owners June 11, 2026 08:53
@hageboeck hageboeck changed the title [6.30] Fix argument passing conventions for hbook [6.30] Backport fix of argument passing conventions for hbook Jun 11, 2026
@github-actions

Copy link
Copy Markdown

Test Results

     5 files       5 suites   15h 42m 33s ⏱️
 2 477 tests  2 477 ✅ 0 💤 0 ❌
12 229 runs  12 229 ✅ 0 💤 0 ❌

Results for commit 38eab04.

@hageboeck hageboeck merged commit 98df303 into root-project:v6-30-00-patches Jun 11, 2026
7 of 8 checks passed
@hageboeck hageboeck deleted the hbook_6.30 branch June 11, 2026 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants