-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
[rtsan] Add include guards around posix interceptors, tests #113188
Conversation
@llvm/pr-subscribers-compiler-rt-sanitizer Author: Chris Apple (cjappl) ChangesFull diff: https://github.com/llvm/llvm-project/pull/113188.diff 2 Files Affected:
diff --git a/compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp b/compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp
index 63b0ca28a1f409..890d6c11c40762 100644
--- a/compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp
+++ b/compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp
@@ -8,12 +8,14 @@
//
//===----------------------------------------------------------------------===//
+#include "sanitizer_common/sanitizer_platform.h"
+#if SANITIZER_POSIX
+
#include "rtsan/rtsan_interceptors.h"
#include "interception/interception.h"
#include "sanitizer_common/sanitizer_allocator_dlsym.h"
#include "sanitizer_common/sanitizer_allocator_internal.h"
-#include "sanitizer_common/sanitizer_platform.h"
#include "sanitizer_common/sanitizer_platform_interceptors.h"
#include "interception/interception.h"
@@ -608,3 +610,5 @@ void __rtsan::InitializeInterceptors() {
INTERCEPT_FUNCTION(recvfrom);
INTERCEPT_FUNCTION(shutdown);
}
+
+#endif // SANITIZER_POSIX
diff --git a/compiler-rt/lib/rtsan/tests/rtsan_test_interceptors_posix.cpp b/compiler-rt/lib/rtsan/tests/rtsan_test_interceptors_posix.cpp
index f7a281f13e2ff6..6233c3e91800e1 100644
--- a/compiler-rt/lib/rtsan/tests/rtsan_test_interceptors_posix.cpp
+++ b/compiler-rt/lib/rtsan/tests/rtsan_test_interceptors_posix.cpp
@@ -8,9 +8,11 @@
//
//===----------------------------------------------------------------------===//
+#include "sanitizer_common/sanitizer_platform.h"
+#if SANITIZER_POSIX
+
#include "gtest/gtest.h"
-#include "sanitizer_common/sanitizer_platform.h"
#include "sanitizer_common/sanitizer_platform_interceptors.h"
#include "rtsan_test_utilities.h"
@@ -704,3 +706,5 @@ TEST(TestRtsanInterceptors, ShutdownOnASocketDiesWhenRealtime) {
ExpectRealtimeDeath(Func, "shutdown");
ExpectNonRealtimeSurvival(Func);
}
+
+#endif // SANITIZER_POSIX
|
Is there strong motivation for doing this in the source rather than in the CMake configuration? |
There seems to be strong precedent to do it via ifdefs. Take for instance the platform specific malloc files in asan:
I'm not opposed to doing this in CMake (and it would be my first gut reaction in a project I controlled) but this seems to be the way I've seen around the codebase. |
OK cool - thanks for summarising these. I'll leave it to others with more experience in the codebase to weigh in here then :) |
This is another in preparation for windows exploration, trying to get all the sub-pieces in place