Index: compiler-rt/trunk/cmake/config-ix.cmake =================================================================== --- compiler-rt/trunk/cmake/config-ix.cmake +++ compiler-rt/trunk/cmake/config-ix.cmake @@ -600,7 +600,7 @@ endif() if (COMPILER_RT_HAS_SANITIZER_COMMON AND XRAY_SUPPORTED_ARCH AND - OS_NAME MATCHES "Darwin|Linux|FreeBSD|NetBSD") + OS_NAME MATCHES "Darwin|Linux|FreeBSD|NetBSD|OpenBSD") set(COMPILER_RT_HAS_XRAY TRUE) else() set(COMPILER_RT_HAS_XRAY FALSE) Index: compiler-rt/trunk/lib/xray/xray_x86_64.cc =================================================================== --- compiler-rt/trunk/lib/xray/xray_x86_64.cc +++ compiler-rt/trunk/lib/xray/xray_x86_64.cc @@ -3,8 +3,12 @@ #include "xray_defs.h" #include "xray_interface_internal.h" -#if SANITIZER_FREEBSD || SANITIZER_NETBSD +#if SANITIZER_FREEBSD || SANITIZER_NETBSD || SANITIZER_OPENBSD #include +#if SANITIZER_OPENBSD +#include +#include +#endif #include #endif @@ -77,13 +81,18 @@ } return TSCFrequency == -1 ? 0 : static_cast(TSCFrequency); } -#elif SANITIZER_FREEBSD || SANITIZER_NETBSD +#elif SANITIZER_FREEBSD || SANITIZER_NETBSD || SANITIZER_OPENBSD uint64_t getTSCFrequency() XRAY_NEVER_INSTRUMENT { long long TSCFrequency = -1; size_t tscfreqsz = sizeof(TSCFrequency); +#if SANITIZER_OPENBSD + int Mib[2] = { CTL_MACHDEP, CPU_TSCFREQ }; + if (sysctl(Mib, 2, &TSCFrequency, &tscfreqsz, NULL, 0) != -1) { +#else if (sysctlbyname("machdep.tsc_freq", &TSCFrequency, &tscfreqsz, NULL, 0) != -1) { +#endif return static_cast(TSCFrequency); } else { Report("Unable to determine CPU frequency for TSC accounting.\n");