Make it possible to link to custom runtime in another dep#106
Merged
fitzgen merged 4 commits intorust-fuzz:mainfrom May 11, 2023
Merged
Make it possible to link to custom runtime in another dep#106fitzgen merged 4 commits intorust-fuzz:mainfrom
fitzgen merged 4 commits intorust-fuzz:mainfrom
Conversation
fitzgen
reviewed
May 9, 2023
Member
fitzgen
left a comment
There was a problem hiding this comment.
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") { |
Member
There was a problem hiding this comment.
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?
Contributor
Author
|
I also added details in the README about CUSTOM_LIBFUZZER_PATH as it seemed relevant. |
Contributor
Author
|
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. |
Member
|
Published 0.4.7 |
Contributor
Author
|
Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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