This is an archive of the discontinued LLVM Phabricator instance.

[libFuzzer][Windows] Use dllexport for all declarations in FuzzerInterface.h
ClosedPublic

Authored by metzman on Jan 27 2019, 12:37 PM.

Details

Summary

Use dllexport for all declarations in FuzzerInterface.h Use it for clang
even though clang supports default visibility attribute to prevent a
warning from being thrown when LLVMFuzzerMutate is defined with dllexport.
This makes FUZZER_INTERFACE_VISIBILITY (FuzzerInterface.h) consistent with
ATTRIBUTE_INTERFACE (FuzzerDefs.h) when using clang on Windows.

Diff Detail

Repository
rL LLVM

Event Timeline

metzman created this revision.Jan 27 2019, 12:37 PM
metzman updated this revision to Diff 183766.Jan 27 2019, 12:38 PM

Don't use default visibility with clang on Windows

metzman edited the summary of this revision. (Show Details)Jan 27 2019, 12:41 PM
metzman added reviewers: vitalybuka, morehouse.

Please take a look.
This change silences a warning when compiling libFuzzer for Windows with clang.
It shouldn't affect anything other than compiling libFuzzer with clang on Windows.

morehouse added inline comments.Jan 28 2019, 8:50 AM
compiler-rt/lib/fuzzer/FuzzerInterface.h
30 ↗(On Diff #183766)

Why only 32-bit? Also, shouldn't this be #if defined(_WIN32)?

metzman updated this revision to Diff 183889.Jan 28 2019, 9:19 AM
  • check if _WIN32 is defined
metzman marked an inline comment as done.Jan 28 2019, 9:30 AM
metzman added inline comments.
compiler-rt/lib/fuzzer/FuzzerInterface.h
30 ↗(On Diff #183766)

Why only 32-bit?

_WIN32 is defined for 64-bit and 32-bit builds. We use it in FuzzerDefs.h to set LIBFUZZER_WINDOWS.

Also, shouldn't this be #if defined(_WIN32)?

I've changed it to be this.

Funny that you noticed this though, since I came to the opposite conclusion when bikeshedding before uploading the initial patch.
#if defined(_WIN32) is more correct but #if _WIN32 works because undefined macros evaluate to false.
I did this to be consistent with FuzzerDefs.h which uses #if _WIN32 but should be using #if defined(_WIN32), (same for other platform macros).

This revision is now accepted and ready to land.Jan 28 2019, 9:48 AM
This revision was automatically updated to reflect the committed changes.