Vector35 / binaryninja-api

Public API, examples, documentation and issues for Binary Ninja
https://binary.ninja/
MIT License
906 stars 207 forks source link

bindgen & LLVM 18 support for Rust #5390

Closed yujack008 closed 1 month ago

yujack008 commented 4 months ago

I getting start with https://rust.binary.ninja/binaryninja/index.html#writing-a-plugin My rustc version is rustc 1.77.0 (aedd173a2 2024-03-17) My LIBCLANG_PATH is "E:\clang+llvm-18.1.5-x86_64-pc-windows-msvc\bin" step: 1.cargo new --lib deobf 2.edit Cargo.toml

[lib]
crate-type = ["cdylib"]

[dependencies]
binaryninja = {git = "https://github.com/Vector35/binaryninja-api.git", branch = "dev"}

3.cargo build

then get so much error!

error[E0425]: cannot find function, tuple struct or tuple variant `BNFreeQualifiedNameTypeAndId` in this scope
    --> D:\Projects\Rust\binaryninja-api\rust\src\types.rs:2489:13
     |
2470 | pub struct QualifiedNameTypeAndId(pub(crate) BNQualifiedNameTypeAndId);
     | ----------------------------------------------------------------------- similarly named tuple struct `QualifiedNameTypeAndId` defined here
...
2489 |             BNFreeQualifiedNameTypeAndId(&mut self.0);
     |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: a tuple struct with a similar name exists: `QualifiedNameTypeAndId`

error[E0425]: cannot find function, tuple struct or tuple variant `BNFreeTypeIdList` in this scope
    --> D:\Projects\Rust\binaryninja-api\rust\src\types.rs:2500:9
     |
2500 |         BNFreeTypeIdList(raw, count);
     |         ^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `BNAllocString` in this scope
    --> D:\Projects\Rust\binaryninja-api\rust\src\types.rs:2527:23
     |
2527 |                 name: BNAllocString(name.into_bytes_with_nul().as_ref().as_ptr() as *mut _),
     |                       ^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `BNFreeString` in this scope
    --> D:\Projects\Rust\binaryninja-api\rust\src\types.rs:2567:13
     |
     |             ^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `BNFreeNameAndTypeList` in this scope
    --> D:\Projects\Rust\binaryninja-api\rust\src\types.rs:2580:9
     |
2580 |         BNFreeNameAndTypeList(raw, count);
     |         ^^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `BNFreeType` in this scope
    --> D:\Projects\Rust\binaryninja-api\rust\src\types.rs:2649:18
     |
2649 |         unsafe { BNFreeType(handle.0.type_) }
     |                  ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `BNFreeDataVariables` in this scope
    --> D:\Projects\Rust\binaryninja-api\rust\src\types.rs:2659:9
     |
2659 |         BNFreeDataVariables(raw, count);
     |         ^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `BNGetArchitectureIntrinsicName` in this scope
    --> D:\Projects\Rust\binaryninja-api\rust\src\types.rs:2722:33
     |
2722 |         let name_ptr = unsafe { BNGetArchitectureIntrinsicName(self.arch.0, self.index) };
     |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
negasora commented 4 months ago

Are you using the build.rs from the guide?

yujack008 commented 4 months ago

Are you using the build.rs from the guide?

i have build fine on llvm 17.0.6

ElykDeer commented 4 months ago

I believe that this is a duplicate from Slack. User resolved this by downgrading to LLVM 17.0.6. Internally we're still on LLVM 16. No real idea about the effort required to fix this will be, but I'm hoping it's just some new flags we need to set (or something similar). I'll leave this open to track the status of bindgen/LLVM18 support.

fuzyll commented 1 month ago

This should have been fixed when I pulled in #5700 and I didn't realize there was a separate issue created for it. If anyone is still having issues, please let me know, but 4.1 stable and onward should work with LLVM 18 now that the bindgen version has been bumped.