Cross compiling HDF5 for aarch64


#1

Hi All.
I am having a trouble compiling HDF5 for AARH64-linux-elf target (build on x86_64). My compiler does not have libquadmath enabled and I am getting the following error:

checking for a BSD-compatible install... /usr/bin/install -c

checking whether build environment is sane… yes

checking for x86_64-pc-linux-gnu-strip… no

checking for strip… strip

checking for a thread-safe mkdir -p… /usr/bin/mkdir -p

checking for gawk… gawk

checking whether make sets $(MAKE)… yes

checking whether make supports nested variables… yes

checking whether make supports nested variables… (cached) yes

checking whether to enable maintainer-specific portions of Makefiles… no

checking build system type… x86_64-unknown-linux-gnu

checking host system type… x86_64-pc-linux-gnu

checking shell variables initial values… done

checking if basename works… yes

checking if xargs works… yes

checking for cached host… none

checking enable warnings as errors… no

checking for config x86_64-pc-linux-gnu… no

checking for config x86_64-pc-linux-gnu… no

checking for config pc-linux-gnu… no

checking for config pc-linux-gnu… no

checking for config x86_64-linux-gnu… no

checking for config x86_64-linux-gnu… no

checking for config x86_64-pc… no

checking for config linux-gnu… found

compiler ‘aarch64-linux-gcc’ is GNU gcc-12.2.0

compiler ‘aarch64-linux-gfortran’ is GNU gfortran-12.2.0

compiler ‘aarch64-linux-g++’ is GNU g+±12.2.0

checking for config …/config/site-specific/host-ben-VirtualBox… no

checking for clang sanitizer checks… checking build mode… production

checking for x86_64-pc-linux-gnu-gcc… aarch64-linux-gcc

checking whether the C compiler works… yes

checking for C compiler default output file name… a.out

checking for suffix of executables…

checking whether we are cross compiling… yes

checking for suffix of object files… o

checking whether we are using the GNU C compiler… yes

checking whether aarch64-linux-gcc accepts -g… yes

checking for aarch64-linux-gcc option to accept ISO C89… none needed

checking whether aarch64-linux-gcc understands -c and -o together… yes

checking for style of include used by make… GNU

checking dependency style of aarch64-linux-gcc… gcc3

checking if unsupported combinations of configure options are allowed… no

checking how to run the C preprocessor… aarch64-linux-gcc -E

checking for grep that handles long lines and -e… /usr/bin/grep

checking for egrep… /usr/bin/grep -E

checking for ANSI C header files… yes

checking for sys/types.h… yes

checking for sys/stat.h… yes

checking for stdlib.h… yes

checking for string.h… yes

checking for memory.h… yes

checking for strings.h… yes

checking for inttypes.h… yes

checking for stdint.h… yes

checking for unistd.h… yes

checking for off_t… yes

checking for ssize_t… yes

checking whether byte ordering is bigendian… no

checking size of char… 1

checking size of short… 2

checking size of int… 4

checking size of unsigned… 4

checking size of long… 8

checking size of long long… 8

checking size of float… 4

checking size of double… 8

checking size of long double… 16

checking size of __float128… 0

checking size of _Quad… 0

checking quadmath.h usability… no

checking quadmath.h presence… no

checking for quadmath.h… no

checking maximum decimal precision for C… configure: error: in `/home/ben/ann/hdf5/build-arch64’:

configure: error: cannot run test program while cross compiling

See `config.log’ for more details

Is there a way to compile hdf5 library without libquadmath?


#2

Hi, @shapiroben88!

Thanks for trying AARH64-linux-elf target!

Do you mean without libquadmath?

If so, I think there should be a way.
Please submit an issue on https://github.com/HDFGroup/hdf5/issues.


#3

If quad math is not supported, it tries to compile and run a simple C program which should not use quad math. Can you provide the output from config.log?


#4

I’ve also tried to compile using the aarch64 cross-compilation toolchain, but ran into a lot of problems. My requirement is to put the HDF5 library into a new embedded device. What puzzles me is this:

  1. Because it is difficult to compile embedded devices, can it be transplanted after completing cross-compilation locally? Where should I modify the CMakeLists.txt file?
  2. I cannot provide the initialized H5lisettings.c.
    In trying it out, it turns out that part of the HDF5 build process is dynamically generating some source code, compiling it, executing it, and capturing the result to generate more source code.
    How can I make H5make_libsettings initialize the parameters related to H5lib_settings.c according to the system that needs to be transplanted? ps, the target system can only run programs with static link
    Have you encountered similar problems? I’m really confused
    There is not a complete document on the Internet that completes the cross-porting of the hdf5 library. Maybe we can communicate more.

#5

H5make_libsettings just creates the source for the text file - it uses definitions and settings already processed.
The key file is the H5detect process and configuration. There are ways to pregenerate the configuration and use pre-created files to avoid cross-compile issues.
Part of it is CMake documented, part is setting options for HDF5.


#6

I cannot upload attachments because I am new user, but here is a
Link.

It is a tag hdf5-1_13_2 from hdf5 github. I am using standard aarch64-linux cross compiler (compiling on x86_64 for aarch64). It always fails for not finding libquadmath support. Also in older tags.


#7

Should I report it as a bug or new feature? I guess it has been cross-compiled to aarch64 before…


#8

I think it should be a new feature since HDF doesn’t support aarch64 officially.

I would appreciate if you could contribute a GitHub Action example like [1] that fails to build as well via a pull request.

[1] https://github.com/uraimo/run-on-arch-action


#9

Thks a lot.
This is also one of the problems I encountered! How can I pregenerate the H5detect and H5init files of the target machine during cross compilation? Where can I get relevant documentation?
Can you give me a hand? I’m exhausted.


#10

Hi @hyoklee.
I’ve tried running run-on-arch-action but without success.
Can you give me a hint on how to use that? I saw that workflow need to be defined via yaml file. I did that, but I couldn’t find how start the build and specify to it my yaml file.
Is there any documentation or explanation on how to run the ‘run-on-arch-action’ project?


#11

Hi @shapiroben88!

May I see your YML file on GitHub?

Here’s the starting point: https://github.com/hyoklee/hdf5/actions/runs/3464788504
Please click Workflow file for the YML.

I hope we can keep working together to build HDF5 on GitHub using aarch64.


#12

Hi, @shapiroben88!

I could build HDF5 using CMake and GitHub Action.
It took 3 hours.
Here’s my workflow file: https://github.com/hyoklee/hdf5/blob/develop/.github/workflows/aarch64.yml

Have you tried CMake instead of autoconf?

Finally, testing on GitHub takes too long.
I’d appreciate if you could donate a hardware.
Then, I can run test quickly and regularly.


#13

What parts need to be modified in the cmakelist file, can you provide specific statements? We are expecting a reply


#14

Did you compile successfully? We are expecting a reply


#15

You don’t have to modify any.

See GitHub Action status badges from http://github.com/hyoklee/hdf5.
Both Armv7 and Aarch64 pass test 100%.
Just use CMake.

mkdir build
cmake ..
make
make test

#16

@hyoklee see, you did a build in ubuntu aarch64 docker. I am interested in building it with a cross-compiler.
So the host is x86_64 with a aarch64-linux-elf cross compiler. Is the only supported way of building is docker?


#17

Since I don’t know your exact setting without your hardware donation or a cloud instance with SSH account, please describe your platform in GitHub Action. We can go from there. I’m willing to test anything for you in terms of ARM support of HDF5.


#18

@hyoklee Can you try that:

name: x86_64 cross aarch64 CMake

on: [push, pull_request]

jobs:
x86_64_cross_aarch64_job:
# The host should always be Linux
runs-on: ubuntu-latest
name: Build on ubuntu-latest x86_64 for aarch64
steps:
- uses: actions/checkout@v3
- uses: uraimo/run-on-arch-action@v2
name: Run commands
id: runcmd
with:
arch: x86_64
distro: ubuntu_latest

      # Not required, but speeds up builds by storing container images in
      # a GitHub package registry.
      githubToken: ${{ github.token }}
      install: |
        apt-get update -q -y
        apt-get install -q -y git
        apt-get install -q -y cmake
        apt-get install -q -y gcc-aarch64-linux-gnu
      run: |
        echo ::set-output name=uname::$(uname -a)
        git clone https://github.com/hyoklee/hdf5
        cd hdf5
        mkdir build
        cd build
        cmake .. -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc -DCMAKE_AR=aarch64-linux-gnu-ar 
        make
        make test
  - name: Get the output
    # Echo the `uname` output parameter from the `runcmd` step
    run: |
      echo "The uname output was ${{ steps.runcmd.outputs.uname }}"

I didn’t execute it because I don’t know how to, but I think it should be ok. It’s x86_64 ubuntu with aarch64-linux-gnu toolchain installed. Then the CMAKE is using this toolchain.
Another general question, Is there any binding to OS feature like threads? I also want to try compile with baremetal aarch64 compiler and just wanted to know if it’s possible in general?


#19

Hi,

Thanks for providing your setting in YML.

I’m testing it now using your setting with and without Docker:

It will take a few hours to get result since my account is personal. :crossed_fingers:


#20

Thanks for your patience, but what I want to do:
Build platform: ubuntu22.04
Toolchain: aarch64-linux-musl
Target platform: aarch64
It seems that using these commands can’t solve the problem, can you provide more specific help? looking forward to reply