-
Notifications
You must be signed in to change notification settings - Fork 47
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
Make it possible to link to custom runtime in another dep #106
Conversation
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.
LGTM, but I think we should name the feature link_libfuzzer
just in case we ever get the ability to link any other libfuzzer-compatible engines.
Can you also add a new subsection to the README about the new feature? Thanks!
build.rs
Outdated
println!("cargo:rerun-if-env-changed=CUSTOM_LIBFUZZER_PATH"); | ||
if let Ok(custom) = ::std::env::var("CUSTOM_LIBFUZZER_PATH") { | ||
println!("cargo:rerun-if-changed={custom}"); | ||
if cfg!(feature = "link") { |
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.
Can we move all the linking code out to a new function that is also cfg(feature = "link")
so that it is easier to read this giant if
with no else?
I also added details in the README about CUSTOM_LIBFUZZER_PATH as it seemed relevant. |
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.
Lovely, thank you!
Can a release be cut for this? We would like to publish a downstream crate that depends on this but cannot depend on the git revision. |
Published 0.4.7 |
Thank you! |
We are implementing AFLplusplus/LibAFL#981, but don't want to make too much impact on the downstream users of libfuzzer-sys. As a compromise, this PR adds a default feature,
link
, which, when enabled, links to the libfuzzer runtime or the CUSTOM_LIBFUZZER_RUNTIME. When not enabled, it does not link to the fuzzer runtime.This allows us to link to a custom runtime in our own dependency while reusing the infrastructure already provided by libfuzzer-sys (namely, fuzz_target and custom_mutator). See an example of this use case here:
https://github.com/AFLplusplus/LibAFL/blob/libfuzzer/libafl_libfuzzer/build.rs
https://github.com/AFLplusplus/LibAFL/blob/libfuzzer/libafl_libfuzzer/Cargo.toml#L17