rust-rocksdb: error: failed to run custom build command for `librocksdb-sys v0.6.1+6.28.2`

i have a project that is dependant on that specific version of librocksdb-sys and wheni run cargo build --release it show the following

error:failed to run custom build command for `librocksdb-sys v0.6.1+6.28.2`
Caused by:
  process didn't exit successfully: `/home/ezio/projects/testhex/target/debug/build/librocksdb-sys-2c05e423d101bec2/build-script-build` (exit status: 101)
  --- stderr
  thread 'main' panicked at '"enum_(unnamed_at_rocksdb/include/rocksdb/c_h_860_1)" is not a valid Ident', /home/ezio/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-1.0.56/src/fallback.rs:811:9
  stack backtrace:
     0: rust_begin_unwind
               at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/panicking.rs:575:5
     1: core::panicking::panic_fmt
               at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/core/src/panicking.rs:64:14
     2: proc_macro2::fallback::validate_ident
               at /home/ezio/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-1.0.56/src/fallback.rs:811:9
     3: proc_macro2::fallback::Ident::_new
               at /home/ezio/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-1.0.56/src/fallback.rs:753:9
     4: proc_macro2::fallback::Ident::new
               at /home/ezio/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-1.0.56/src/fallback.rs:763:9
     5: proc_macro2::Ident::new
               at /home/ezio/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-1.0.56/src/lib.rs:972:21
     6: bindgen::ir::context::BindgenContext::rust_ident_raw
               at /home/ezio/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.59.2/src/ir/context.rs:878:9
     7: bindgen::ir::context::BindgenContext::rust_ident
               at /home/ezio/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.59.2/src/ir/context.rs:870:9
     8: <bindgen::ir::enum_ty::Enum as bindgen::codegen::CodeGenerator>::codegen
               at /home/ezio/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.59.2/src/codegen/mod.rs:2907:21
     9: <bindgen::ir::ty::Type as bindgen::codegen::CodeGenerator>::codegen
               at /home/ezio/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.59.2/src/codegen/mod.rs:1004:39
    10: <bindgen::ir::item::Item as bindgen::codegen::CodeGenerator>::codegen
               at /home/ezio/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.59.2/src/codegen/mod.rs:492:17
    11: <bindgen::ir::module::Module as bindgen::codegen::CodeGenerator>::codegen::{{closure}}
               at /home/ezio/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.59.2/src/codegen/mod.rs:515:21
    12: <bindgen::ir::module::Module as bindgen::codegen::CodeGenerator>::codegen
               at /home/ezio/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.59.2/src/codegen/mod.rs:545:13
    13: <bindgen::ir::item::Item as bindgen::codegen::CodeGenerator>::codegen
               at /home/ezio/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.59.2/src/codegen/mod.rs:483:17
    14: bindgen::codegen::codegen::{{closure}}
               at /home/ezio/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.59.2/src/codegen/mod.rs:4287:9
    15: bindgen::ir::context::BindgenContext::gen
               at /home/ezio/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.59.2/src/ir/context.rs:1190:19
    16: bindgen::codegen::codegen
               at /home/ezio/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.59.2/src/codegen/mod.rs:4251:5
    17: bindgen::Bindings::generate
               at /home/ezio/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.59.2/src/lib.rs:2374:32
    18: bindgen::Builder::generate
               at /home/ezio/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.59.2/src/lib.rs:1478:9
    19: build_script_build::bindgen_rocksdb
               at ./build.rs:36:20
    20: build_script_build::main
               at ./build.rs:325:5
    21: core::ops::function::FnOnce::call_once
               at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/core/src/ops/function.rs:250:5
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

i tried runing adding the same on an empty project with cargo add librocksdb-sys@0.6.1+6.28.2 and the same error appears

environment:

Default host: x86_64-unknown-linux-gnu
rustup home:  /home/ezio/.rustup

installed toolchains
--------------------

stable-x86_64-unknown-linux-gnu (default)
nightly-2022-11-11-x86_64-unknown-linux-gnu
nightly-2022-11-30-x86_64-unknown-linux-gnu
nightly-x86_64-unknown-linux-gnu
1.63.0-x86_64-unknown-linux-gnu
1.68.2-x86_64-unknown-linux-gnu

active toolchain
----------------

stable-x86_64-unknown-linux-gnu (default)
rustc 1.68.2 (9eb3afe9e 2023-03-27)

OS: opensuse tumbleweed (latest update)

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Comments: 16 (2 by maintainers)

Commits related to this issue

Most upvoted comments

I get a similar error on macOS with Apple Clang 15.x and RocksDb 7.x. The fix for me was to either:

  • downgrade to Clang 14.x (if you’re on macOS, downgrade your Xcode developer tools/Xcode in general to 14.x)
  • upgrade the Rust bindgen dependency to >= 0.62

Thank you, this helped me out! I ran this before the compile I was trying to do, and it fixed the error.

brew install llvm@14
export PATH="/opt/homebrew/opt/llvm@14/bin:$PATH" 
clang --version # Should return 14

@aleksuss i wonder why it worked when i distro hopped!

Older Clang? It seems that this problem appears only with LLVM/Clang 16 that was released just a month ago or so.

I get a similar error on macOS with Apple Clang 15.x and RocksDb 7.x. The fix for me was to either:

  • downgrade to Clang 14.x (if you’re on macOS, downgrade your Xcode developer tools/Xcode in general to 14.x)
  • upgrade the Rust bindgen dependency to >= 0.62

I have similar error on Fedora 38.