diff --git a/hadrian/src/Flavour.hs b/hadrian/src/Flavour.hs
index cc2d6db407cd95610e540f73a78e4dc3e3f5ab79..5dd70580ce2193ed4a51ae7864fc22aea55eaded 100644
--- a/hadrian/src/Flavour.hs
+++ b/hadrian/src/Flavour.hs
@@ -123,16 +123,25 @@ addArgs args' fl = fl { extraArgs = extraArgs fl <> args' }
 -- from warnings.
 werror :: Flavour -> Flavour
 werror =
-  addArgs
-    ( builder Ghc
+  addArgs $ mconcat
+    [ builder Ghc
         ? notStage0
         ? mconcat
-          [ arg "-Werror",
-            flag CrossCompiling
+          [ arg "-Werror"
+          , flag CrossCompiling
               ? package unix
               ? mconcat [arg "-Wwarn=unused-imports", arg "-Wwarn=unused-top-binds"]
           ]
-    )
+    , builder Ghc
+        ? package rts
+        ? mconcat
+          [ arg "-optc-Werror"
+            -- clang complains about #pragma GCC pragmas
+          , arg "-optc-Wno-error=unknown-pragmas"
+          ]
+      -- N.B. We currently don't build the boot libraries' C sources with -Werror
+      -- as this tends to be a portability nightmare.
+    ]
 
 -- | Build C and Haskell objects with debugging information.
 enableDebugInfo :: Flavour -> Flavour
diff --git a/rts/sm/NonMovingMark.c b/rts/sm/NonMovingMark.c
index c493cd4dd96c189e6f7c5e436dc6d4b4e258928c..af2bce354db9f875d761f9385a4dcdd8abe7d60a 100644
--- a/rts/sm/NonMovingMark.c
+++ b/rts/sm/NonMovingMark.c
@@ -39,9 +39,7 @@ static void trace_PAP_payload (MarkQueue *queue,
                                StgClosure *fun,
                                StgClosure **payload,
                                StgWord size);
-#if defined(DEBUG)
-static bool is_nonmoving_weak(StgWeak *weak);
-#endif
+static bool is_nonmoving_weak(StgWeak *weak) USED_IF_DEBUG;
 
 // How many Array# entries to add to the mark queue at once?
 #define MARK_ARRAY_CHUNK_LENGTH 128
@@ -1975,7 +1973,6 @@ void nonmovingMarkWeakPtrList (struct MarkQueue_ *queue)
 
 // Determine whether a weak pointer object is on one of the nonmoving
 // collector's weak pointer lists. Used for sanity checking.
-#if defined(DEBUG)
 static bool is_nonmoving_weak(StgWeak *weak)
 {
     for (StgWeak *w = nonmoving_old_weak_ptr_list; w != NULL; w = w->link) {
@@ -1986,7 +1983,6 @@ static bool is_nonmoving_weak(StgWeak *weak)
     }
     return false;
 }
-#endif
 
 // Non-moving heap variant of `tidyWeakList`
 bool nonmovingTidyWeaks (struct MarkQueue_ *queue)