Skip to content

Conversation

byrnHDF
Copy link
Contributor

@byrnHDF byrnHDF commented Aug 11, 2025

Another possibility using defaults and toolchain file could overwrite.
See #5709 and #5718

The expectation is that cross-compiling will use a toolchain file to provide the correct values.
The defaults are only one way to provide defaults for a specific compiler.

NOTE: The supplied toolchain and Fortran pre-gen files are specific for mingw/gfortran - each platform/compiler will need to supply its own set of files/values.


Important

Rework HDF5UseFortran.cmake to support cross-compilation by providing default KINDs and sizes.

  • Behavior:
    • Modify HDF5UseFortran.cmake to handle cross-compilation by providing default KINDs and sizes when CMAKE_CROSSCOMPILING is true.
    • Default values for INTEGER and REAL KINDs and their sizes are set when cross-compiling.
    • Error messages are adjusted to reflect cross-compilation scenarios.
  • Logic:
    • Conditional checks added for CMAKE_CROSSCOMPILING to determine if default values should be used.
    • Default values include INTEGER KINDs {1,2,4,8,16} and REAL KINDs {4,8,10,16}.
    • Default sizes for native kinds are set to 4 for INTEGER and REAL, and 8 for DOUBLE PRECISION when cross-compiling.
  • Misc:
    • Adjustments to verbose messages to indicate when defaults are used during cross-compilation.

This description was created by Ellipsis for 0b8f640. You can customize this summary. It will automatically update as commits are pushed.

set (PAC_FC_ALL_INTEGER_KINDS "\{1,2,4,8,16\}" CACHE INTERNAL "Find available INTEGER KINDs for Fortran")
set (PAC_FC_ALL_REAL_KINDS "\{4,8,10,16\}" CACHE INTERNAL "Find available REAL KINDs for Fortran")
set (${HDF_PREFIX}_PAC_FC_MAX_REAL_PRECISION 33 CACHE INTERNAL "Maximum decimal precision for REALs in Fortran")
set (PAC_FORTRAN_NUM_INTEGER_KINDS "5" CACHE INTERNAL "Number of valid integer kinds for Fortran")
Copy link

Choose a reason for hiding this comment

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

In the cross‐compile default branch, the default integer kinds count is inconsistent: 'PAC_FORTRAN_NUM_INTEGER_KINDS' is set to 5, but H5CONFIG_F_NUM_IKIND is hard‐coded to 4. Please align these values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are two different items.

else ()
# Use the default if there's no cache variable and cross-compiling
message (VERBOSE "Find available REAL KINDs for Fortran... yes (cross-compile default)")
set (PAC_FC_ALL_REAL_KINDS_SIZEOF "\{4,8,16,16\}" CACHE INTERNAL "Find available REAL KINDs for Fortran")
Copy link

Choose a reason for hiding this comment

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

The default REAL KIND SIZEOF value contains a duplicate '16' (i.e. "{4,8,16,16}"). Verify if this duplication is intentional or if it should differ (e.g. perhaps "{4,8,10,16}").

Suggested change
set (PAC_FC_ALL_REAL_KINDS_SIZEOF "\{4,8,16,16\}" CACHE INTERNAL "Find available REAL KINDs for Fortran")
set (PAC_FC_ALL_REAL_KINDS_SIZEOF "\{4,8,10,16\}" CACHE INTERNAL "Find available REAL KINDs for Fortran")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are correct values for linux

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's not Linux that determines this, but the compiler. Interpretation of KIND values depends on the compiler. For example, NAG, by default, uses sequential kind numbering, which is not what GNU does.

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, the idea is that toolchain specific overrides will modify this. This is just a simple default - the other option will be to skip the default and require an override.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could also change the "(cross-compile default)" to "(cross-compile gfortran default)"

@byrnHDF
Copy link
Contributor Author

byrnHDF commented Aug 12, 2025

The mingw dross-compile gets past the configure stage and then chokes on:
FAILED: [code=1] fortran/src/CMakeFiles/H5_buildiface.dir/H5_buildiface.F90.obj
FAILED: [code=1] fortran/src/CMakeFiles/H5match_types.dir/H5match_types.c.obj

because the values from the defaults are not correctly formatted. Once the syntax is correct then we can update the toolchain with the correct values.

@byrnHDF
Copy link
Contributor Author

byrnHDF commented Sep 2, 2025

The latest update fixes the Fortran configuration issue with PRE-GENERATED files. And the build succeeds. The tests fail because they are failing with the WINE emulator - maybe someone can suggest a fix?

@byrnHDF
Copy link
Contributor Author

byrnHDF commented Sep 3, 2025

CMake applies the CMAKE_CROSSCOMPILING_EMULATOR for cross compiling and does not need to be specified in the command line. The WINEPATH ENV must be added to calls involving wine emulator. Added this to the mingw toolchain. Only 24 tests failed mostly h5_test_api and hl_test tests. Will need to investigate which of these tests are expected to fail with wine emulator.

@byrnHDF
Copy link
Contributor Author

byrnHDF commented Sep 3, 2025

Fixed the h5_api_test by excluding them if cross-compiling.
Fixed the properties for HL and SWMR check
Leaving 5 failures:
3 - H5TEST-testhdf5-base (Failed)
8 - H5TESTXPR-cache_api (Failed)
65 - H5TEST-swmr (Failed)
89 - H5TEST-filenotclosed (Failed)
93 - H5TEST-err_compat (Failed)

@byrnHDF
Copy link
Contributor Author

byrnHDF commented Sep 4, 2025

Note that 3 - H5TEST-testhdf5-base (Failed) is because :
HDF_CHECK_TYPE_SIZE (off_t ${HDF_PREFIX}_SIZEOF_OFF_T) needs to be 4 and not 8

@byrnHDF
Copy link
Contributor Author

byrnHDF commented Sep 4, 2025

Although the CI doesn't show it - there are only 4 failing tests on my local fedora system. The ubuntu runner seems to have a char set issue causing problems. Likely a missing system dependency?
As far as code changes for CMake, I believe this PR to be complete.

@hmaarrfk
Copy link

hmaarrfk commented Sep 4, 2025

16k lines!!!! I really hope this is "improving things" beyond just "cross compilation workflows". I really think cross compilation is critical, but this has definitely gone "beyond" the scope I originally imaged this being.

@byrnHDF
Copy link
Contributor Author

byrnHDF commented Sep 4, 2025

So the big change is that CMake will apply the CMAKE_CROSS_COMPILING_EMULATER as needed - had to remove that from the commands
The wine64 emulator requires setting WINEPATH env var. A global setting didn't work for me so I added that to the test properties.
Finally the other changes concern the Fortran configure and the Fortran generated files.

@hmaarrfk
Copy link

hmaarrfk commented Sep 4, 2025

Are you able to provide points and tips to the failures in: conda-forge/hdf5-feedstock#268

@byrnHDF
Copy link
Contributor Author

byrnHDF commented Sep 5, 2025

Are you able to provide points and tips to the failures in: conda-forge/hdf5-feedstock#268

I haven't tried mpi and cross-compiling - is that the issue?

@byrnHDF
Copy link
Contributor Author

byrnHDF commented Sep 5, 2025

Note that the supplied pre-gen files and configure defaults were specific for mingw-gfortran. Other compilers will likely need other values and files. The best thing would be to create a stable of toolchain files and dirs.

@hmaarrfk
Copy link

hmaarrfk commented Sep 6, 2025

i'm honestly not sure how much time i have to troubleshoot this with you all. i'm really sorry. you can see my checklist, i got pretty far. but i need some hands on keyboard debugging from some1 who is willing to look at things from a conda-forge standpoint. Its free to make a PR, which will run on our infrastructure.

To be honest, it is very likely that we will be able to, by 2026, to run on native runners for OSX on conda-forge. I'm willing to wait, or simply to stick on the HDF5 V1, and "not accelerate" its deployment.

@byrnHDF
Copy link
Contributor Author

byrnHDF commented Sep 7, 2025

Yes I believe that running on native machines is the best plan. Our use of native runners has been very beneficial.

@ajelenak
Copy link
Contributor

ajelenak commented Sep 8, 2025

it is very likely that we will be able to, by 2026, to run on native runners for OSX on conda-forge.

@hmaarrfk Do you know when in 2026 this may happen?

@hmaarrfk
Copy link

hmaarrfk commented Sep 8, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: To be triaged
Development

Successfully merging this pull request may close these issues.

5 participants