Add a TSAN build flag to CMake and configure.py

Summary:
TSAN is a useful build mode for Hermes when building with Hades on,
or the SamplingProfiler on.
Add support for this build mode to CMake builds, and the configure.py script.

Reviewed By: neildhar

Differential Revision: D23304893

fbshipit-source-id: 4bb0c800678f34c64008540f41bc515f88fbc5c9
This commit is contained in:
Riley Dulin 2020-08-24 17:54:00 -07:00 коммит произвёл Facebook GitHub Bot
Родитель 1848baf555
Коммит f71bb2c528
2 изменённых файлов: 12 добавлений и 0 удалений

Просмотреть файл

@ -135,6 +135,10 @@ set(HERMES_ENABLE_ADDRESS_SANITIZER OFF CACHE BOOL
set(HERMES_ENABLE_UNDEFINED_BEHAVIOR_SANITIZER OFF CACHE BOOL
"Enable -fsanitize=undefined")
# Enable Thread Sanitizer
set(HERMES_ENABLE_THREAD_SANITIZER OFF CACHE BOOL
"Enable -fsanitize=thread")
set(HERMES_ENABLE_FUZZING OFF CACHE BOOL
"Enable fuzzing")
@ -340,6 +344,9 @@ if (HERMES_ENABLE_UNDEFINED_BEHAVIOR_SANITIZER)
# Do not enable the vptr sanitizer, as it requires RTTI.
append("-fsanitize=undefined -fno-sanitize=vptr -fno-sanitize-recover=undefined" CMAKE_CXX_FLAGS CMAKE_C_FLAGS CMAKE_EXE_LINKER_FLAGS)
endif()
if (HERMES_ENABLE_THREAD_SANITIZER)
append("-fsanitize=thread" CMAKE_CXX_FLAGS CMAKE_C_FLAGS CMAKE_EXE_LINKER_FLAGS)
endif()
if(HERMES_FACEBOOK_BUILD)
add_definitions(-DHERMES_FACEBOOK_BUILD)
endif()

Просмотреть файл

@ -22,6 +22,8 @@ def build_dir_suffix(args):
suffices += ["asan"]
if args.enable_ubsan:
suffices += ["ubsan"]
if args.enable_tsan:
suffices += ["tsan"]
if args.distribute:
suffices += ["release"]
if args.is_32_bit:
@ -66,6 +68,7 @@ def parse_args():
parser.add_argument("--32-bit", dest="is_32_bit", action="store_true")
parser.add_argument("--enable-asan", dest="enable_asan", action="store_true")
parser.add_argument("--enable-ubsan", dest="enable_ubsan", action="store_true")
parser.add_argument("--enable-tsan", dest="enable_tsan", action="store_true")
parser.add_argument("--icu", type=str, dest="icu_root", default="")
parser.add_argument("--fbsource", type=str, dest="fbsource_dir", default="")
parser.add_argument("--opcode-stats", dest="opcode_stats", action="store_true")
@ -227,6 +230,8 @@ def main():
cmake_flags += ["-DHERMES_ENABLE_ADDRESS_SANITIZER=ON"]
if args.enable_ubsan:
cmake_flags += ["-DHERMES_ENABLE_UNDEFINED_BEHAVIOR_SANITIZER=ON"]
if args.enable_tsan:
cmake_flags += ["-DHERMES_ENABLE_THREAD_SANITIZER=ON"]
if args.fbsource_dir:
cmake_flags += ["-DFBSOURCE_DIR=" + args.fbsource_dir]
if args.wasm: