Page MenuHomePhabricator

[tsan] CMake support for TSan on OS X

Authored by kubamracek on Nov 2 2015, 7:31 AM.



Hi, this patch adds a CMake flag called COMPILER_RT_ENABLE_TSAN_OSX, which is off by default. If enabled, the build system will be building the OS X version of the TSan runtime library (called libclang_rt.tsan_osx_dynamic.dylib). I'll submit patches that fix OS X build errors shortly.

This is part of an effort to port TSan to OS X, and it's one the very first steps. Don't expect TSan on OS X to actually work or pass tests at this point.

Diff Detail

Event Timeline

kubamracek updated this revision to Diff 38917.Nov 2 2015, 7:31 AM
kubamracek retitled this revision from to [tsan] CMake support for TSan on OS X.
kubamracek updated this object.
kubamracek added reviewers: samsonov, kcc, glider, dvyukov.
glider accepted this revision.Nov 2 2015, 10:45 AM
glider edited edge metadata.

LGTM assuming this works for you.

This revision is now accepted and ready to land.Nov 2 2015, 10:45 AM
ismailp accepted this revision.Nov 2 2015, 11:25 AM
ismailp added a reviewer: ismailp.



I have a diff here. This might be currently irrelevant, but I'll post it here for future reference. To get it working with Xcode, I've done:

+      set(TSAN_ASM_SOURCES rtl/tsan_rtl_amd64.S)
+      # Xcode will try to compile this file as C ('clang -x c'), and that will fail.
+      if (${CMAKE_GENERATOR} STREQUAL "Xcode")
+        enable_language(ASM)
+      else()
+        # Pass ASM file directly to the C++ compiler.
+        set_source_files_properties(${TSAN_ASM_SOURCES} PROPERTIES
+          LANGUAGE C)
+      endif()

Did you try Xcode generator? Xcode's built-in build rules might be overriding compiler flags passed from the CMake generated Xcode project with for these S files. Because it works with Ninja generator, but fails with Xcode.

kubamracek added inline comments.Nov 3 2015, 6:15 AM

I see. I was only testing on a debug build, which doesn't use HACKY_CALL and thus the assembly file is not needed at all. Let me now commit this without using the assembly file (and #ifdef'ing it out) and we can take a look at it later.

kubamracek closed this revision.Nov 3 2015, 6:16 AM

Landed in r251915.