diff --git a/libcxx/src/debug.cpp b/libcxx/src/debug.cpp
--- a/libcxx/src/debug.cpp
+++ b/libcxx/src/debug.cpp
@@ -62,7 +62,27 @@
 {
 
 #ifndef _LIBCPP_HAS_NO_THREADS
-typedef mutex mutex_type;
+/// Simple wrapper around std::mutex that checks the threading API is enabled before doing anything.
+class mutex_check_threading : public mutex {
+public:
+    void lock() {
+        if (!__libcpp_is_threading_api_enabled())
+            return;
+        mutex::lock();
+    }
+    bool try_lock() {
+        if (!__libcpp_is_threading_api_enabled())
+            return true;
+        return mutex::try_lock();
+    }
+    void unlock() {
+        if (!__libcpp_is_threading_api_enabled())
+            return;
+        mutex::unlock();
+    }
+};
+
+typedef mutex_check_threading mutex_type;
 typedef lock_guard<mutex_type> WLock;
 typedef lock_guard<mutex_type> RLock;