SubDirs += asan
SubDirs += interception
SubDirs += profile
+SubDirs += tsan
# FIXME: We don't currently support building an atomic library, and as it must
# be a separate library from the runtime library, we need to remove its source
--- /dev/null
+# Build for the AddressSanitizer runtime support library.
+
+file(GLOB TSAN_SOURCES "*.cc")
+
+if(CAN_TARGET_X86_64)
+ add_library(clang_rt.tsan-x86_64 STATIC ${TSAN_SOURCES})
+ set_target_properties(clang_rt.tsan-x86_64 PROPERTIES COMPILE_FLAGS "${TARGET_X86_64_CFLAGS}")
+endif()
--- /dev/null
+#===- lib/tsan/Makefile.mk ---------------------------------*- Makefile -*--===#
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+#===------------------------------------------------------------------------===#
+
+ModuleName := tsan
+SubDirs := rtl
+Sources :=
+ObjNames :=
+Dependencies :=
+
+Implementation := Generic
+
+TsanFunctions :=
--- /dev/null
+#===- lib/tsan/rtl/Makefile.mk -----------------------------*- Makefile -*--===#
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+#===------------------------------------------------------------------------===#
+
+ModuleName := tsan
+SubDirs :=
+
+Sources := $(foreach file,$(wildcard $(Dir)/*.cc),$(notdir $(file)))
+AsmSources := $(foreach file,$(wildcard $(Dir)/*.S),$(notdir $(file)))
+ObjNames := $(Sources:%.cc=%.o) $(AsmSources:%.S=%.o)
+
+Implementation := Generic
+
+# FIXME: use automatic dependencies?
+Dependencies := $(wildcard $(Dir)/*.h)
+
+# Define a convenience variable for all the tsan functions.
+TsanFunctions += $(Sources:%.cc=%) $(AsmSources:%.S=%)
Arch.asan-x86_64 := x86_64
endif
+# Configuration for TSAN runtime.
+ifeq ($(CompilerTargetArch),x86_64)
+Configs += tsan-x86_64
+Arch.tsan-x86_64 := x86_64
+endif
+
endif
###
CFLAGS.profile-x86_64 := $(CFLAGS) -m64
CFLAGS.asan-i386 := $(CFLAGS) -m32
CFLAGS.asan-x86_64 := $(CFLAGS) -m64
+CFLAGS.tsan-x86_64 := $(CFLAGS) -m64 -fPIE -fno-builtin
# Use our stub SDK as the sysroot to support more portable building. For now we
# just do this for the non-ASAN modules, because the stub SDK doesn't have
FUNCTIONS.profile-x86_64 := GCDAProfiling
FUNCTIONS.asan-i386 := $(AsanFunctions) $(InterceptionFunctions)
FUNCTIONS.asan-x86_64 := $(AsanFunctions) $(InterceptionFunctions)
+FUNCTIONS.tsan-x86_64 := $(TsanFunctions) $(InterceptionFunctions)
# Always use optimized variants.
OPTIMIZED := 1