-
Notifications
You must be signed in to change notification settings - Fork 109
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
Expose Environment Variables during Build #387
base: main
Are you sure you want to change the base?
Conversation
…'exec_build()') for dependencies to detect when cargo-fuzz is running
c0cb777
to
e2b684b
Compare
Hi @fitzgen - just bumping this to you. Would love to get your feedback on the change and potentially get it merged. |
…llows for Windows DLLs to be built *without* the '/include:main' linker argument. This, plus a few other tricks, allows for Windows DLLs to be built for fuzzing.
Thanks! Do you mind splitting these features out into different PRs so we can discuss them independently? |
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.
Thanks! A couple things to address before we merge this.
…t up subprocess environment. Also, changed function name to better indicate it's role as a helper function
@fitzgen - Thanks for reviewing these PRs! I've addressed your comments; let me know what you thin. |
Thanks! Just fyi I’m on vacation and won’t be able to look at this again until the middle of next week. |
Hi - this PR implements a way to expose environment variables during the build command that's executed during
exec_build()
. This is done with the aim to give dependencies the ability to detect a cargo-fuzz build versus a non-cargo-fuzz build.I implemented this feature while doing work to get cargo-fuzz working on Windows to build and fuzz a DLL. Certain dependencies may need to use different built settings when being built for production versus for fuzzing. Exposing these environment variables at build-time allow
build.rs
scripts to detect cargo-fuzz builds.Currently just two environment variables are exposed, but more could of course be added:
CARGO_FUZZ
- A flag that's set to1
when cargo-fuzz is performing a build. Useful for detecting cargo-fuzz without wanting any extra information.CARGO_FUZZ_MANIFEST
- Exposes the path to the cargo-fuzzCargo.toml
manifest that was used whencargo fuzz [build/run/etc.]
was invoked. Useful in the event a user needs to determine which fuzzing project ran the command.Use-Case Example
As I mentioned above, a user may need to modify the build flags in a fuzzing dependency, but only when the dependency is being built for fuzzing. A brief example of how this would work: