aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhiddenpath <hiddenpath@yandex-team.com>2023-05-09 23:03:47 +0300
committerhiddenpath <hiddenpath@yandex-team.com>2023-05-09 23:03:47 +0300
commita2b07bdd8ae0998c6f7b5ec402a830da91198ac5 (patch)
tree74195a085a1b7b92bf63ec9f46338088122c1475
parent397ebd37186df6996be059e4d7cbe28d0a5c3c26 (diff)
downloadydb-a2b07bdd8ae0998c6f7b5ec402a830da91198ac5.tar.gz
Mute -Wdeprecated-declarations error when thread sanitizer enabled on darwin platform
При сборке проектов с ```--sanitize=thread``` под **darwin**, по умолчанию попадет ```util``` и его часть ```system/context.h```, где в случае ```thread_sanitizer_enabled``` выставляется ```USE_UCONTEXT_CONT```, что приводит к использованию [депрекейтнутного](https://opensource.apple.com/source/libplatform/libplatform-125/include/ucontext.h.auto.html) ```<ucontext.h>``` из [macos_sdk](https://a.yandex-team.ru/arcadia/build/platform/macos_sdk/ya.make?rev=rXXXXXX#L6). Без должных изменений, сборка падает с ошибкой. ```In file included from /Users/hiddenpath/.ya/build/build_root/fnjm/000128/util/all_system_1.cpp:13: In file included from /Users/hiddenpath/arcadia/util/system/context.cpp:31: In file included from /Users/hiddenpath/arcadia/util/system/context.h:46: /Users/hiddenpath/.ya/tools/v4/2088833948/usr/include/ucontext.h:51:2: error: The deprecated ucontext routines require _XOPEN_SOURCE to be defined #error The deprecated ucontext routines require _XOPEN_SOURCE to be defined ^ In file included from /Users/hiddenpath/.ya/build/build_root/fnjm/000128/util/all_system_1.cpp:13: In file included from /Users/hiddenpath/arcadia/util/system/context.cpp:31: /Users/hiddenpath/arcadia/util/system/context.h:68:9: error: use of undeclared identifier 'getcontext' getcontext(&Ctx_); ^ /Users/hiddenpath/arcadia/util/system/context.h:72:9: error: use of undeclared identifier 'getcontext' getcontext(&Ctx_); ^ /Users/hiddenpath/arcadia/util/system/context.h:80:9: error: use of undeclared identifier 'makecontext' makecontext(&Ctx_, (ucontext_func_t)ContextTrampoLine, 1, c.TrampoLine); ^ /Users/hiddenpath/arcadia/util/system/context.h:87:9: error: use of undeclared identifier 'swapcontext' swapcontext(&Ctx_, &next->Ctx_); ^ 5 errors generated. Failed
-rw-r--r--util/system/context.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/util/system/context.h b/util/system/context.h
index 91c0831338..c04a462365 100644
--- a/util/system/context.h
+++ b/util/system/context.h
@@ -22,6 +22,11 @@
*/
#if defined(thread_sanitizer_enabled)
#define USE_UCONTEXT_CONT
+ #if defined(_darwin_)
+ #define _XOPEN_SOURCE 700
+ #pragma clang diagnostic push
+ #pragma clang diagnostic ignored "-Wdeprecated-declarations"
+ #endif
#elif defined(_bionic_) || defined(__IOS__)
#define USE_GENERIC_CONT
#elif defined(_cygwin_)
@@ -172,6 +177,11 @@ static inline size_t MachineContextSize() noexcept {
#undef EXTRA_PUSH_ARGS
#endif
+#if defined(_darwin_) && defined(thread_sanitizer_enabled)
+ #pragma clang diagnostic pop
+ #undef _XOPEN_SOURCE
+#endif
+
struct TExceptionSafeContext: public TContMachineContext {
using TContMachineContext::TContMachineContext;