Add new build option to support Windows DLLs #388
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.
Hi - this PR implements a new build argument:
--no-include-main-msvc
- in order to help enable support for building and fuzzing Windows DLLs.I recently ran into an issue when attempting to fuzz a Windows-only DLL (#386) where the
/include:main
linker argument that is added duringFuzzProject::cargo()
for MSVC-based builds gave the DLL amain
symbol it could not resolve, which caused linking to fail:The DLL is, by nature, completely separate from the fuzzing targets in my cargo-fuzz repository, but I still wanted it to be a dependency listed in
fuzz/Cargo.toml
, so that it would be built and instrumented in the exact same way as the fuzzing target binaries. I found that by controlling whether or not/include:main
is added to thecargo build
arguments executed by cargo-fuzz, I was able to set up a "dummy" fuzzing target that provides its own main function:Then, by executing
cargo fuzz run --no-include-main-msvc dummy_target
, the DLL would be built successfully. I could then proceed to run all other fuzzing targets, which would load in the instrumented DLL and fuzz it.TL;DR: This solution allows Windows DLLs to be instrumented & fuzzed, but only if manual control over
/include:main
is allowed (hence,--no-include-main-msvc
). This resolves #386.