Use alternatename for external functions only when using
MSVC since Clang doesn't support it and MSVC doesn't support
Clang's method (weak aliases).
Details
Diff Detail
- Repository
- rCRT Compiler Runtime
Event Timeline
Matt could you please take a look?
For context, this patch is part of a series that I am trying to land to get libFuzzer working when compiled by MSVC.
@rnk or @thakis what do you think of this workaround for this bug I came up with?
I tried using things like volatile loads of the function pointers to prevent the optimizer from getting in the way, but I couldn't come up with a reliable solution, so I decided not to use alternatename when using clang.
compiler-rt/lib/fuzzer/FuzzerExtFunctionsAlternatename.cpp | ||
---|---|---|
38 ↗ | (On Diff #180931) | Maybe move the above macros into FuzzerDefs.h or create a FuzzerWinDefs.h. Then FuzzerExtFunctionsAlternatename.cpp is unneeded, and we can reuse FuzzerExtFunctionsWeakAlias.cpp. |
compiler-rt/lib/fuzzer/FuzzerExtFunctionsWeakAlias.cpp | ||
26 ↗ | (On Diff #180931) | This attribute could also become a macro in FuzzerDefs.h or FuzzerWinDefs.h |
compiler-rt/lib/fuzzer/FuzzerExtFunctionsAlternatename.cpp | ||
---|---|---|
38 ↗ | (On Diff #180931) | What do you think of moving them both into a single file FuzzerExtFunctionsWin.cpp? |
compiler-rt/lib/fuzzer/FuzzerExtFunctionsWeakAlias.cpp | ||
26 ↗ | (On Diff #180931) | If you agree with my above comment to create FuzzerExtFunctionsWin.cpp, then what do you think of just defining this as a macro in that file? |
compiler-rt/lib/fuzzer/FuzzerExtFunctionsWeakAlias.cpp | ||
---|---|---|
26 ↗ | (On Diff #180931) | SGTM |
compiler-rt/lib/fuzzer/FuzzerExtFunctionsWindows.cpp | ||
---|---|---|
37 ↗ | (On Diff #181640) | Let's move all the macros outside of the extern "C" block except for the EXT_FUNC definition. |
56 ↗ | (On Diff #181640) | You can make the definition of WIN_WEAK_ALIAS depend on LIBFUZZER_MSVC and then use the same EXT_FUNC as above. |