-
Notifications
You must be signed in to change notification settings - Fork 85
Add cargo features for arch support #180
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
Conversation
All archs enabled: 43MB. No archs enabled: 18MB. Only x86 arch enabled: 25MB.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds cargo feature flags for selective architecture support in Capstone, reducing binary size when non-essential architectures are disabled. Key changes include updating Cargo.toml files to include new arch-specific feature flags, modifying build.rs to conditionally define arch macros, and updating test configuration to gate tests based on specific arch features.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
cstool/Cargo.toml | Updated capstone dependency to disable default features and added arch flags. |
capstone-sys/build.rs | Introduced a macro to conditionally define architecture flags based on features. |
capstone-sys/Cargo.toml | Added default inclusion of support_all_archs and arch-specific features. |
capstone-rs/src/test.rs | Adjusted test configuration to require explicit arch flags for certain tests. |
capstone-rs/src/arch/m68k.rs | Modified test configuration for m68k to also require the arch_m68k flag. |
capstone-rs/Cargo.toml | Extended default features to include support_all_archs and mapped arch flags. |
.github/workflows/main.yml | Added a workflow to run tests with only a limited set of arch features enabled. |
This pr implements the first and second approach for issue #61, which conditionally compiles capstone arch support based on cargo feature flags and enables arch modules on Rust side.
It reduces file size greatly:
cargo build
:cstool
is 31MB in sizecargo build --no-default-features --features full,arch_x86
:cstool
is 19MB in sizeIt disable Rust arch modules if feature flag is not provided. Creating capstone instance with disabled archs will fail with errors.