Various GCC 3.6 and clang build fixes.

Remove #error in common_test.h that fires with clang build and replace with
runtime error.
Fix bit rot caused by not compiling with Wthread-safety.
Fix clang build issues in compiler relating to missing header file definitions
in object files.
Other minor build and tidying issues.

Change-Id: Ife829ab0664581936155be524de46e6181c750b0
diff --git a/src/thread.cc b/src/thread.cc
index 8487078..66b1cfa 100644
--- a/src/thread.cc
+++ b/src/thread.cc
@@ -839,7 +839,8 @@
   int frame_count;
 };
 
-static bool ShouldShowNativeStack(const Thread* thread) {
+static bool ShouldShowNativeStack(const Thread* thread)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
   ThreadState state = thread->GetState();
 
   // In native code somewhere in the VM (one of the kWaitingFor* states)? That's interesting.
@@ -923,6 +924,7 @@
   CHECK(is_started_);
   is_started_ = false;
   CHECK_PTHREAD_CALL(pthread_key_delete, (Thread::pthread_key_self_), "self key");
+  MutexLock mu(Thread::Current(), *Locks::thread_suspend_count_lock_);
   if (resume_cond_ != NULL) {
     delete resume_cond_;
     resume_cond_ = NULL;