Index: contrib/compiler-rt/lib/builtins/int_lib.h =================================================================== --- contrib/compiler-rt/lib/builtins/int_lib.h +++ contrib/compiler-rt/lib/builtins/int_lib.h @@ -74,11 +74,13 @@ * global header to prevent other C files from making the detour * through __c?zdi2() as well. * - * This problem has only been observed on FreeBSD for sparc64 and - * mips64 with GCC 4.2.1. + * This problem has been observed on FreeBSD for sparc64 and + * mips64 with GCC 4.2.1, and for riscv with GCC 5.2.0. + * Presumably it's any version of GCC, and targeting an arch that + * does not have dedicated bit counting instructions. */ #if defined(__FreeBSD__) && (defined(__sparc64__) || \ - defined(__mips_n64) || defined(__mips_o64)) + defined(__mips_n64) || defined(__mips_o64) || defined(__riscv__)) si_int __clzsi2(si_int); si_int __ctzsi2(si_int); #define __builtin_clz __clzsi2 Index: contrib/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h =================================================================== --- contrib/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h +++ contrib/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h @@ -76,6 +76,10 @@ #elif defined(__powerpc64__) const unsigned struct_kernel_stat_sz = 144; const unsigned struct_kernel_stat64_sz = 104; +#elif defined(__riscv__) + /* RISCVTODO: check that these values are correct */ + const unsigned struct_kernel_stat_sz = 128; + const unsigned struct_kernel_stat64_sz = 128; #elif defined(__mips__) #if SANITIZER_WORDSIZE == 64 const unsigned struct_kernel_stat_sz = 216; @@ -103,7 +107,7 @@ #if SANITIZER_LINUX || SANITIZER_FREEBSD -#if defined(__powerpc64__) +#if defined(__powerpc64__) || defined(__riscv__) const unsigned struct___old_kernel_stat_sz = 0; #else const unsigned struct___old_kernel_stat_sz = 32; @@ -481,7 +485,7 @@ typedef long __sanitizer___kernel_off_t; #endif -#if defined(__powerpc__) || defined(__mips__) +#if defined(__powerpc__) || defined(__mips__) || defined(__riscv__) typedef unsigned int __sanitizer___kernel_old_uid_t; typedef unsigned int __sanitizer___kernel_old_gid_t; #else