KyleMayes / clang-sys

Rust bindings for libclang.
Apache License 2.0
128 stars 65 forks source link

By this limitation, I unable to use X32 ABI to compile stuff. #158

Closed e99243506bigplay closed 1 year ago

e99243506bigplay commented 1 year ago

https://github.com/KyleMayes/clang-sys/blob/aaacdefa5d304139e03b97e640c13a01239e5077/build/dynamic.rs#L60-L62

I am try to compile https://github.com/aptos-labs/aptos-core in x86 64-bit x32 ABI environment, then stuck on librocksdb-sys. Trace to bindgen, then found the problem is on clang-sys.

root@9da8455f1833:~/aptos-core# OPENSSL_DIR=/root/openssl/target-x32/usr/local/ RUSTFLAGS="--cfg tokio_unstable -C target-feature=+crt-static" nice -19 cargo build --release --package aptos-node  --target=x86_64-unknown-linux-gnux32
   Compiling librocksdb-sys v0.8.0+7.4.4 (https://github.com/aptos-labs/rust-rocksdb#3698ab20)
   Compiling git2 v0.15.0
   Compiling aptos-cached-packages v0.1.0 (/root/aptos-core/aptos-move/framework/cached-packages)
error: failed to run custom build command for `librocksdb-sys v0.8.0+7.4.4 (https://github.com/aptos-labs/rust-rocksdb#3698ab20)`

Caused by:
  process didn't exit successfully: `/root/aptos-core/target/release/build/librocksdb-sys-ebdbd85e1d21858d/build-script-build` (exit status: 101)
  --- stderr
  thread 'main' panicked at 'Unable to find libclang: "couldn't find any valid shared libraries matching: ['libclang.so', 'libclang-*.so', 'libclang.so.*', 'libclang-*.so.*'], set the `LIBCLANG_PATH` environment variable to a path where one of these files can be found (invalid: [(/usr/lib/llvm-15/lib/libclang.so.1: invalid ELF class (32-bit)), (/usr/lib/llvm-15/lib/libclang-15.so.1: invalid ELF class (32-bit)), (/usr/lib/x86_64-linux-gnux32/libclang-15.so.1: invalid ELF class (32-bit)), (/usr/lib/x86_64-linux-gnux32/libclang-15.so.15: invalid ELF class (32-bit)), (/usr/lib/x86_64-linux-gnux32/libclang-15.so.15.0.6: invalid ELF class (32-bit))])"', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.60.1/src/lib.rs:2172:31
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...

BTW, you could try to get x32 ABI environment by use docker image xddxdd/debian-x32 easily.

EDIT: oh no, I was using x86_64-unknown-linux-gnu toolchain.

root@9da8455f1833:~/aptos-core# file /root/aptos-core/target/release/build/librocksdb-sys-d4979fb5a13ea18a/build-script-build
/root/aptos-core/target/release/build/librocksdb-sys-d4979fb5a13ea18a/build-script-build: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=92b4a3338ec5f05c6f659c7ca4f7c34855965284, for GNU/Linux 3.2.0, with debug_info, not stripped
e99243506bigplay commented 1 year ago

Closing for not sure this issue is valid or not.