diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc b/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc index bf7127443c4175..ac9db9807adb70 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc @@ -338,6 +338,9 @@ bool ShouldMockFailureToOpen(const char *path) { } #if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_GO +# ifndef O_CLOEXEC +# define O_CLOEXEC 0 +# endif int GetNamedMappingFd(const char *name, uptr size, int *flags) { if (!common_flags()->decorate_proc_maps || !name) return -1; diff --git a/compiler-rt/lib/xray/xray_x86_64.cc b/compiler-rt/lib/xray/xray_x86_64.cc index e63ee1b3bd02eb..209aa7a106bbcc 100644 --- a/compiler-rt/lib/xray/xray_x86_64.cc +++ b/compiler-rt/lib/xray/xray_x86_64.cc @@ -49,6 +49,9 @@ retryingReadSome(int Fd, char *Begin, char *End) XRAY_NEVER_INSTRUMENT { return std::make_pair(TotalBytesRead, true); } +#ifndef O_CLOEXEC +# define O_CLOEXEC 0 +#endif static bool readValueFromFile(const char *Filename, long long *Value) XRAY_NEVER_INSTRUMENT { int Fd = open(Filename, O_RDONLY | O_CLOEXEC);