diff --git a/hadrian/src/Rules/Library.hs b/hadrian/src/Rules/Library.hs
index 8f95ec28c2ba639b1e65a3aec1f42cc4a9b764c5..135c560505363ac70cf635170620c004d4a47573 100644
--- a/hadrian/src/Rules/Library.hs
+++ b/hadrian/src/Rules/Library.hs
@@ -24,10 +24,11 @@ import Oracles.Flag
 
 libraryRules :: Rules ()
 libraryRules = do
+    soMutex <- newResource "so-mutex" 1
     root <- buildRootRules
-    root -/- "**/libHS*-*.dylib"       %> buildDynamicLib root "dylib"
-    root -/- "**/libHS*-*.so"          %> buildDynamicLib root "so"
-    root -/- "**/libHS*-*.dll"         %> buildDynamicLib root "dll"
+    root -/- "**/libHS*-*.dylib"       %> buildDynamicLib [(soMutex, 1)] root "dylib"
+    root -/- "**/libHS*-*.so"          %> buildDynamicLib [(soMutex, 1)] root "so"
+    root -/- "**/libHS*-*.dll"         %> buildDynamicLib [(soMutex, 1)] root "dll"
     root -/- "**/*.a"                  %> buildStaticLib  root
     root -/- "**/stamp-*"              %> buildPackage root
     priority 2 $ do
@@ -85,8 +86,8 @@ registerDynamicLib root suffix dynlibpath = do
 -- | Build a dynamic library ('LibDyn') under the given build root, with the
 -- given suffix (@.so@ or @.dylib@, @.dll@), where the complete path of the
 -- archive to build is given as the third argument.
-buildDynamicLib :: FilePath -> String -> FilePath -> Action ()
-buildDynamicLib root suffix dynlibpath = do
+buildDynamicLib :: [(Resource, Int)] -> FilePath -> String -> FilePath -> Action ()
+buildDynamicLib rs root suffix dynlibpath = do
     dynlib@(BuildPath _ stage _ (LibDyn pkgname _ _  way _))
       <- parsePath (parseBuildLibDyn root suffix) "<dyn lib parser>" dynlibpath
     let context = libDynContext dynlib
@@ -94,7 +95,7 @@ buildDynamicLib root suffix dynlibpath = do
     deps <- contextDependencies context
     registerPackages deps
     objs <- libraryObjects context
-    build $ target context (Ghc LinkHs $ Context.stage context) objs [dynlibpath]
+    buildWithResources rs $ target context (Ghc LinkHs $ Context.stage context) objs [dynlibpath]
     putSuccess $
       renderLibrary
         (quote pkgname ++ " (" ++ show stage ++ ", way " ++ show way ++ ").")