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

embed default corpus #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

evanrichter
Copy link

hey thanks for this tool, it came in handy identifying 8051 firmware today!

when in doubt, it's always 8051 ;)

anyway, I hit a small snag when trying to just cargo install --git https://github.com/trou/cpu_rec_rs and go (because the corpus wasn't on my local disk). Not too big of a deal, but a self-contained binary would be more convenient than keeping a copy of the corpus files around.

This obviously bloats the binary size. I chose postcard to encode the corpus, which is relatively compact, but the corpus still weighs in around 40MB.

So then I compressed it with lz4 and landed around 32MB for the executable (apple m1 mach-o binary).

In my opinion that's a good tradeoff, what do you think?

@trou
Copy link
Owner

trou commented Jul 1, 2023

Hello. Thank you for your PR. I'd be happy to merge it if there's a way to embed the corpus when using "cargo install". Unfortunately I could not find a simple way to do that. Do you have any idea on how to do this?

@evanrichter
Copy link
Author

That's precisely what this PR does! You can verify with something like

cd /tmp # no corpus here
cargo install --force --git https://github.com/evanrichter/cpu_rec_rs
ls -lah ~/.cargo/bin/cpu_rec_rs # verify binary size is ~32 MB

@trou
Copy link
Owner

trou commented Jul 1, 2023

Sorry, I forgot "only" in embed the corpus only when using "cargo install".

@evanrichter
Copy link
Author

We could make it conditional on release vs. debug, but I don't know a way to change behavior of cargo install more precisely

though this does increase binary size by ~40MB
~25% reduction in binary size
@evanrichter
Copy link
Author

rebased to fix conflicts

jevinskie added a commit to jevinskie/cpu_rec_rs that referenced this pull request May 25, 2024
…4 to avoid needing to know compression/decompression size. Bugs with manual corpus dir specificiation remain
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants