This is an archive of the discontinued LLVM Phabricator instance.

[tsan] Add TSan unit test support for OS X
ClosedPublic

Authored by kubamracek on Nov 10 2015, 10:37 AM.

Details

Summary

This patch enables building and running TSan unit tests on OS X. There are several changes:

  • Move the detection of OSX_SYSROOT_FLAG to config-ix.cmake so it becomes a global-scope variable.
  • Add building a static version of the runtime and link it with the unit tests.
  • Modify tsan_test_util_linux.cc to be Darwin-compatible and add it into the OS X build. In a subsequent commit, I'll rename the file to tsan_test_util_posix.cc.
  • Use symbolize=false:abort_on_error=0 as default TSAN_OPTIONS to speed up the unit tests significantly.
  • In tsan_clock_test.cc, replace CLOCK_MONOTONIC with gettimeofday, which is available on OS X.

Diff Detail

Repository
rL LLVM

Event Timeline

kubamracek retitled this revision from to [tsan] Add TSan unit test support for OS X.
kubamracek updated this object.
kubamracek added reviewers: dvyukov, kcc, samsonov, glider.
dvyukov accepted this revision.Nov 11 2015, 1:48 AM
dvyukov edited edge metadata.

LGTM with a nit

lib/tsan/tests/rtl/tsan_test_util_linux.cc
143 ↗(On Diff #39828)

Tests can rely on the fact that this is an actual mutex that provides actual synchronization. You turn it into no-op. It's probably not super important (as no tests fail and we do not add any more of these tests), but I think it is better to define Spin to Normal on mac:

enum Type {
  Normal,
  RW,

#ifndef APPLE

Spin

#else

// because ...
Spin = Normal

#endif

};

This way it is still a mutex from point of view of both execution and tsan.

This revision is now accepted and ready to land.Nov 11 2015, 1:48 AM
This revision was automatically updated to reflect the committed changes.