-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[fuzzer] fix clang-cl build fuzzer lit test failure #112339
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
[fuzzer] fix clang-cl build fuzzer lit test failure #112339
Conversation
@llvm/pr-subscribers-compiler-rt-sanitizer Author: Wu Yingcong (yingcong-wu) ChangesThe
The related commits are 53a81d4 and e31efd8. Following the change in e31efd8 can fix these failures. As for the issue mentioned in the comment that alternatename support in clang not good enough(https://bugs.llvm.org/show_bug.cgi?id=40218). I find that using Full diff: https://github.com/llvm/llvm-project/pull/112339.diff 1 Files Affected:
diff --git a/compiler-rt/lib/fuzzer/FuzzerExtFunctionsWindows.cpp b/compiler-rt/lib/fuzzer/FuzzerExtFunctionsWindows.cpp
index 688bad1d51ca5b..dfc32ac9db2979 100644
--- a/compiler-rt/lib/fuzzer/FuzzerExtFunctionsWindows.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerExtFunctionsWindows.cpp
@@ -22,6 +22,11 @@ using namespace fuzzer;
#define STRINGIFY(A) STRINGIFY_(A)
#if LIBFUZZER_MSVC
+#define GET_FUNCTION_ADDRESS(fn) &fn
+#else
+#define GET_FUNCTION_ADDRESS(fn) __builtin_function_start(fn)
+#endif // LIBFUZER_MSVC
+
// Copied from compiler-rt/lib/sanitizer_common/sanitizer_win_defs.h
#if defined(_M_IX86) || defined(__i386__)
#define WIN_SYM_PREFIX "_"
@@ -31,17 +36,9 @@ using namespace fuzzer;
// Declare external functions as having alternativenames, so that we can
// determine if they are not defined.
-#define EXTERNAL_FUNC(Name, Default) \
- __pragma(comment(linker, "/alternatename:" WIN_SYM_PREFIX STRINGIFY( \
+#define EXTERNAL_FUNC(Name, Default) \
+ __pragma(comment(linker, "/alternatename:" WIN_SYM_PREFIX STRINGIFY( \
Name) "=" WIN_SYM_PREFIX STRINGIFY(Default)))
-#else
-// Declare external functions as weak to allow them to default to a specified
-// function if not defined explicitly. We must use weak symbols because clang's
-// support for alternatename is not 100%, see
-// https://bugs.llvm.org/show_bug.cgi?id=40218 for more details.
-#define EXTERNAL_FUNC(Name, Default) \
- __attribute__((weak, alias(STRINGIFY(Default))))
-#endif // LIBFUZZER_MSVC
extern "C" {
#define EXT_FUNC(NAME, RETURN_TYPE, FUNC_SIG, WARN) \
@@ -57,20 +54,23 @@ extern "C" {
}
template <typename T>
-static T *GetFnPtr(T *Fun, T *FunDef, const char *FnName, bool WarnIfMissing) {
+static T *GetFnPtr(void *Fun, void *FunDef, const char *FnName,
+ bool WarnIfMissing) {
if (Fun == FunDef) {
if (WarnIfMissing)
Printf("WARNING: Failed to find function \"%s\".\n", FnName);
return nullptr;
}
- return Fun;
+ return (T *)Fun;
}
namespace fuzzer {
ExternalFunctions::ExternalFunctions() {
-#define EXT_FUNC(NAME, RETURN_TYPE, FUNC_SIG, WARN) \
- this->NAME = GetFnPtr<decltype(::NAME)>(::NAME, ::NAME##Def, #NAME, WARN);
+#define EXT_FUNC(NAME, RETURN_TYPE, FUNC_SIG, WARN) \
+ this->NAME = GetFnPtr<decltype(::NAME)>(GET_FUNCTION_ADDRESS(::NAME), \
+ GET_FUNCTION_ADDRESS(::NAME##Def), \
+ #NAME, WARN);
#include "FuzzerExtFunctions.def"
|
This broke building for me on x64 and i686 using mingw to build as a shared object. Logs at https://github.com/Zentrik/llvm_julia_tester/actions/runs/11392238393/job/31697854988#step:9:5200. Unfortunately, I'm not going to have time to look into this until next week, but I'll see if I can figure out what's going on then. |
Okay, I will take a look when I have time too. @Zentrik Please keep me posted for any updates on this. Thank you. |
I can see it fails with
But no any detailed error information is provided. We can guard this change to exclude MinGW. But I think it is best for us to root-cause this problem first. |
Fixed the build issue for me |
The
check-fuzzer
runs fine with cl build llvm, but the following lit tests fail with clang-cl build llvmThe related commits are 53a81d4 and e31efd8. Following the change in e31efd8 can fix these failures.
As for the issue mentioned in the comment that alternatename support in clang not good enough(https://bugs.llvm.org/show_bug.cgi?id=40218). I find that using
__builtin_function_start(func)
instead of directly usingfunc
would make it work as intended.