Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HDF5 doesn't work with cross #233

Open
a1ecbr0wn opened this issue Mar 19, 2023 · 0 comments
Open

HDF5 doesn't work with cross #233

a1ecbr0wn opened this issue Mar 19, 2023 · 0 comments

Comments

@a1ecbr0wn
Copy link

a1ecbr0wn commented Mar 19, 2023

If you use a custom cross container with a cross compiled version of the hdf5 library, there are a few issues that prevent the build of the hdf5-sys rust library.

e.g.,

  1. create a container with a version of the hdf5 library for another architecture and you tell it to find the package config file:
RUN apt-get install --assume-yes libhdf5-dev:armhf
ENV PKG_CONFIG_PATH_armv7-unknown-linux-gnueabihf=/usr/lib/arm-linux-gnueabihf/pkgconfig \
    PKG_CONFIG_LIBDIR_armv7_unknown_linux_gnueabihf=/usr/lib/arm-linux-gnueabihf \
    PKG_CONFIG_SYSROOT_DIR_armv7_unknown_linux_gnueabihf=/usr/lib/arm-linux-gnueabihf \
    CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc \
    CC_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc \
    CXX_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++ \
    BINDGEN_EXTRA_CLANG_ARGS_armv7_unknown_linux_gnueabihf="--sysroot=/usr/arm-linux-gnueabihf" \
    QEMU_LD_PREFIX=/usr/arm-linux-gnueabihf

run

cross build --target=armv7-unknown-linux-gnueabihf

The default looks in the wrong place for the binary, it looks in /usr/lib/arm-linux-gnueabihf/usr/include/hdf5/serial because it cant find the hdf5.pc file:

error: failed to run custom build command for `hdf5-sys v0.8.1`

Caused by:
  process didn't exit successfully: `/target/debug/build/hdf5-sys-c1e87a537622b7ea/build-script-build` (exit status: 101)
  --- stdout
  Attempting to find HDF5 via pkg-config...
  cargo:rerun-if-env-changed=HDF5_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_armv7-unknown-linux-gnueabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_armv7_unknown_linux_gnueabihf
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_ALLOW_CROSS
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS
  cargo:rerun-if-env-changed=PKG_CONFIG_armv7-unknown-linux-gnueabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_armv7_unknown_linux_gnueabihf
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=HDF5_STATIC
  cargo:rerun-if-env-changed=HDF5_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_armv7-unknown-linux-gnueabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_armv7_unknown_linux_gnueabihf
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_armv7-unknown-linux-gnueabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_armv7_unknown_linux_gnueabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_armv7-unknown-linux-gnueabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_armv7_unknown_linux_gnueabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=SYSROOT
  cargo:rerun-if-env-changed=HDF5_STATIC
  cargo:rerun-if-env-changed=HDF5_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_armv7-unknown-linux-gnueabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_armv7_unknown_linux_gnueabihf
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=HDF5_STATIC
  cargo:rerun-if-env-changed=HDF5_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_armv7-unknown-linux-gnueabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_armv7_unknown_linux_gnueabihf
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_armv7-unknown-linux-gnueabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_armv7_unknown_linux_gnueabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_armv7-unknown-linux-gnueabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_armv7_unknown_linux_gnueabihf
  Found HDF5 pkg-config entry
      Include paths:
      - "/usr/lib/arm-linux-gnueabihf/usr/include/hdf5/serial"
      Link paths:
      - "/usr/lib/arm-linux-gnueabihf/usr/lib/arm-linux-gnueabihf/hdf5/serial"
  Unable to locate HDF5 headers from pkg-config info.
  Found HDF5 headers at:
      "/usr/include/hdf5/serial"
  Adding to link path:
      "/usr/lib/x86_64-linux-gnu/hdf5/serial"
  Parsing HDF5 config from:
      "/usr/include/hdf5/serial/H5pubconf.h"
  Looking for HDF5 library binary...
  Adding extra link paths (ld)...
      /usr/local/lib/x86_64-linux-gnu
      /lib/x86_64-linux-gnu
      /usr/lib/x86_64-linux-gnu
      /usr/lib/x86_64-linux-gnu64
      /usr/local/lib64
      /lib64
      /usr/lib64
      /usr/local/lib
      /lib
      /usr/lib
      /usr/x86_64-linux-gnu/lib64
      /usr/x86_64-linux-gnu/lib

  --- stderr
  thread 'main' panicked at 'Unable to infer HDF5 library runtime version (can't find the binary).', /cargo/registry/src/index.crates.io-6f17d22bba15001f/hdf5-sys-0.8.1/build.rs:155:5
  1. If you tell the set parameters to tell hdf5-sys build where to find the the binary anyway, the cross build still failes as it tries to link the library as the wrong architecture:
ENV HDF5_DIR=/usr/lib/arm-linux-gnueabihf/hdf5/serial

run

cross build --target=armv7-unknown-linux-gnueabihf

Complains about the wrong ELF class: ELFCLASS32:

error: failed to run custom build command for `hdf5-sys v0.8.1`

Caused by:
  process didn't exit successfully: `/target/debug/build/hdf5-sys-c1e87a537622b7ea/build-script-build` (exit status: 101)
  --- stdout
  Setting HDF5 root from environment variable:
      HDF5_DIR = "/usr/lib/arm-linux-gnueabihf/hdf5/serial"
  Custom HDF5_DIR provided; rpath can be set via:
      RUSTFLAGS="-C link-args=-Wl,-rpath,/usr/lib/arm-linux-gnueabihf/hdf5/serial/lib"
  Parsing HDF5 config from:
      "/usr/lib/arm-linux-gnueabihf/hdf5/serial/include/H5pubconf.h"
  Looking for HDF5 library binary...
  Adding extra link paths (ld)...
      /usr/local/lib/x86_64-linux-gnu
      /lib/x86_64-linux-gnu
      /usr/lib/x86_64-linux-gnu
      /usr/lib/x86_64-linux-gnu64
      /usr/local/lib64
      /lib64
      /usr/lib64
      /usr/local/lib
      /lib
      /usr/lib
      /usr/x86_64-linux-gnu/lib64
      /usr/x86_64-linux-gnu/lib
  Attempting to load: "/usr/lib/arm-linux-gnueabihf/hdf5/serial/lib/libhdf5.so"
      => /usr/lib/arm-linux-gnueabihf/hdf5/serial/lib/libhdf5.so: wrong ELF class: ELFCLASS32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant