Index: lib/tsan/CMakeLists.txt =================================================================== --- lib/tsan/CMakeLists.txt +++ lib/tsan/CMakeLists.txt @@ -154,6 +154,14 @@ LANGUAGE C) elseif(arch MATCHES "powerpc64|powerpc64le") set(TSAN_ASM_SOURCES rtl/tsan_rtl_ppc64.S) + # On PPC64, when using clang with sibling-call-optimization to build + # tsan library, sibling-call (tail-call) to PrintCurrentStackSlow breaks + # distance assumption between StackTrace::GetCurrentPc() and + # BufferedStackTrace::Unwind(), so we turn off sco to work around it. + # See https://llvm.org/bugs/show_bug.cgi?id=27280#c1 + if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + set(TSAN_RTL_CFLAGS ${TSAN_RTL_CFLAGS} -mllvm -disable-ppc-sco=true) + endif () # Pass ASM file directly to the C++ compiler. set_source_files_properties(${TSAN_ASM_SOURCES} PROPERTIES LANGUAGE C)