meilisearch / heed

A fully typed LMDB wrapper with minimum overhead 🐦
https://docs.rs/heed
MIT License
635 stars 58 forks source link

Incompatibility of lmdb-master-sys Package with Cross-Compilation #281

Open Losses opened 2 months ago

Losses commented 2 months ago

Description

The lmdb-master-sys package in the heed crate does not support cross-compilation correctly. When attempting to cross-compile using the command:

cargo build --target aarch64-unknown-linux-gnu

the library generates incompatible binary files:

8c28d618c08bdb0c-mdb.o:                                                         ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), with debug_info, not stripped
8c28d618c08bdb0c-midl.o:                                                        ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), with debug_info, not stripped
lmdb_master_sys-f5d577e22e9dc6e8.lmdb_master_sys.4026053b71a9477b-cgu.0.rcgu.o: ELF 64-bit LSB relocatable, ARM aarch64, version 1 (SYSV), not stripped

This results in a linking error:

aarch64-unknown-linux-gnu-ld: release/deps/liblmdb_master_sys-4cb3ac6e86087a04.rlib: error adding symbols: file in wrong format
collect2: error: ld returned 1 exit status

Context

Some libraries, such as zstd, can resolve cross-compilation issues by setting environment variables:

export PKG_CONFIG_ALLOW_CROSS=1
export ZSTD_SYS_USE_PKG_CONFIG=1

However, it appears that lmdb-master-sys does not utilize pkg-config for its configuration. This results in the generation of object files for the host architecture instead of the target architecture.

Steps to Reproduce

  1. Set up a cross-compilation environment for aarch64-unknown-linux-gnu.
  2. Attempt to build a project that includes the heed crate with the following command:
cargo build --target aarch64-unknown-linux-gnu
  1. Observe the generated object files and the resulting linking error.

Expected Behavior

The lmdb-master-sys package should correctly generate object files for the target architecture (aarch64-unknown-linux-gnu) and link them without errors.

Actual Behavior

The package generates object files for the host architecture (x86-64), leading to a linking error.

Additional Information

Thank you for your attention to this issue. Please let me know if you need any further information or assistance in reproducing the problem.