Skip to content

Commit c28ab62

Browse files
authored
[NFCI] Move SANITIZER_WEAK_IMPORT to sanitizer_common (#79208)
SANITIZER_WEAK_IMPORT is useful for any call that needs to be conditionally linked in. This is currently used for the tsan_dispatch_interceptors, but can be used for other calls introduced in newer versions of MacOS. (such as `aligned_alloc` in this PR #79198). This PR moves the definition to a higher level so it can be used in other sanitizers.
1 parent 1a300d6 commit c28ab62

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,20 @@
3535
# define SANITIZER_INTERFACE_ATTRIBUTE __declspec(dllexport)
3636
#endif
3737
# define SANITIZER_WEAK_ATTRIBUTE
38+
# define SANITIZER_WEAK_IMPORT
3839
#elif SANITIZER_GO
3940
# define SANITIZER_INTERFACE_ATTRIBUTE
4041
# define SANITIZER_WEAK_ATTRIBUTE
42+
# define SANITIZER_WEAK_IMPORT
4143
#else
4244
# define SANITIZER_INTERFACE_ATTRIBUTE __attribute__((visibility("default")))
4345
# define SANITIZER_WEAK_ATTRIBUTE __attribute__((weak))
44-
#endif
46+
# if SANITIZER_APPLE
47+
# define SANITIZER_WEAK_IMPORT extern "C" __attribute((weak_import))
48+
# else
49+
# define SANITIZER_WEAK_IMPORT extern "C" SANITIZER_WEAK_ATTRIBUTE
50+
# endif // SANITIZER_APPLE
51+
#endif // SANITIZER_WINDOWS
4552

4653
//--------------------------- WEAK FUNCTIONS ---------------------------------//
4754
// When working with weak functions, to simplify the code and make it more

compiler-rt/lib/tsan/rtl/tsan_dispatch_defs.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,6 @@ extern const dispatch_block_t _dispatch_data_destructor_munmap;
5656
# define DISPATCH_NOESCAPE
5757
#endif
5858

59-
#if SANITIZER_APPLE
60-
# define SANITIZER_WEAK_IMPORT extern "C" __attribute((weak_import))
61-
#else
62-
# define SANITIZER_WEAK_IMPORT extern "C" __attribute((weak))
63-
#endif
64-
65-
6659
// Data types used in dispatch APIs
6760
typedef unsigned long size_t;
6861
typedef unsigned long uintptr_t;

0 commit comments

Comments
 (0)