Does HDF5 support cross-compiling ?
I am trying to cross-compile HDF5 for use with the ARM platform, and the build fails. Does HDF5 support cross-compiling?
No, there are two problems with cross-compiling in HDF5.
First, HDF5 uses AC_TRY_RUN in several places. This macro tries to compile and run a test program, but this does not work for cross-compiling because it builds the program for the host system, and tries to run it on the build system. To resolve this the macros would need to be replaced with a a non-dynamic test (that is, determine the correct setting without executing a test program), or amend each AC_TRY_RUN with an argument telling it what to do when cross-compiling (which would likely mean setting a pessimistic default for cross-compilations).
Many of these AC_TRY_RUN instances are for checks of compiler capabilities. For example, HDF5 checks to see if the Fortran compiler supports the intrinsic function "SIZEOF" by running a test program. Based on the result, a makefile conditional is set to toggle which source file to use when building H5test_kind (in this case, either H5test_kind_SIZEOF.f90 or H5test_kind.f90). There are also many C++ compiler checks. Other AC_TRY_RUN checks include: checking if large files are supported, checking if SZIP compression can encode, checking if gettimeofday uses the timezone struct, and many more for checking conversion capabilities.
The second (dealbreaking?) problem is the generation of H5Tinit.c and, to a lesser extent, H5libsettings.c which are actually generated within 'make', not by configure. The programs that generate them are C programs which are compiled to run on the target platform, but they are then run during 'make' on the build platform, and thus fail (or, in some cases, simply produce incorrect results). HDF5 would need to generate these source files during configure without executing a machine-dependent program on the build system. (In other words for H5Tinit.c, HDF5 would need to do what H5detect does, but in a scripting language that can be run during configure on the build platform. Since h5detect is supposed to detect machine byte order and floating point format on the target platform, there is not currently a solution for this.)
- - Last modified: 12 January 2015