From 1bc85cbbb80397cbc165500cc336fe8325bed07d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lu=C3=ADs=20Marques?= Date: Wed, 25 Nov 2020 00:03:34 +0000 Subject: [PATCH] [Sanitizer][RISCV] Fix redefinition of REG_SP The include header sys/ucontext.h already defines REG_SP as 2, causing redefinition warnings during compilation. This patch fixes that issue. (We also can't just use the numerical definition provided by the header, as REG_SP is used in this file this refers to a struct field.) Differential Revision: https://reviews.llvm.org/D90934 --- .../sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp index 0f1cadfeae39..2ecf87b096a1 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp @@ -513,6 +513,8 @@ static constexpr uptr kExtraRegs[] = {0}; #elif SANITIZER_RISCV64 typedef struct user_regs_struct regs_struct; +// sys/ucontext.h already defines REG_SP as 2. Undefine it first. +#undef REG_SP #define REG_SP sp static constexpr uptr kExtraRegs[] = {0}; #define ARCH_IOVEC_FOR_GETREGSET -- 2.34.1