diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_posix.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_posix.cpp index d890a3a317737c..c7f5557cb6c4e6 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_posix.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_posix.cpp @@ -340,6 +340,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.cpp b/compiler-rt/lib/xray/xray_x86_64.cpp index e63ee1b3bd02eb..209aa7a106bbcc 100644 --- a/compiler-rt/lib/xray/xray_x86_64.cpp +++ b/compiler-rt/lib/xray/xray_x86_64.cpp @@ -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);