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

bindgen & LLVM 18 support for Rust #5390

Closed
yujack008 opened this issue May 10, 2024 · 4 comments
Closed

bindgen & LLVM 18 support for Rust #5390

yujack008 opened this issue May 10, 2024 · 4 comments
Assignees
Labels
Component: Rust API Issue needs changes to the Rust API Effort: Low Issue should take < 1 week Impact: High Issue adds or blocks important functionality Type: Bug Issue is a non-crashing bug with repro steps
Milestone

Comments

@yujack008
Copy link

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
Copy link
Member

Are you using the build.rs from the guide?

@yujack008
Copy link
Author

Are you using the build.rs from the guide?

i have build fine on llvm 17.0.6

@xusheng6 xusheng6 added Type: Bug Issue is a non-crashing bug with repro steps Component: Rust API Issue needs changes to the Rust API State: Awaiting Triage Issue is waiting for more in-depth triage from a developer labels May 14, 2024
@ElykDeer ElykDeer added Impact: High Issue adds or blocks important functionality Effort: Low Issue should take < 1 week and removed State: Awaiting Triage Issue is waiting for more in-depth triage from a developer labels May 23, 2024
@ElykDeer
Copy link
Member

ElykDeer commented May 23, 2024

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.

@ElykDeer ElykDeer changed the title Rust Api Bug bindgen & LLVM 18 support for Rust May 23, 2024
@ElykDeer ElykDeer removed their assignment May 23, 2024
@emesare emesare self-assigned this Jul 26, 2024
@fuzyll fuzyll assigned fuzyll and unassigned emesare Aug 19, 2024
@fuzyll fuzyll added this to the Elysium milestone Aug 19, 2024
@fuzyll
Copy link
Contributor

fuzyll commented Aug 19, 2024

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.

@fuzyll fuzyll closed this as completed Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Rust API Issue needs changes to the Rust API Effort: Low Issue should take < 1 week Impact: High Issue adds or blocks important functionality Type: Bug Issue is a non-crashing bug with repro steps
Projects
None yet
Development

No branches or pull requests

6 participants