diff options
author | Ben Gamari <ben@smart-cactus.org> | 2019-12-01 11:50:44 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2020-10-24 20:59:39 -0400 |
commit | ccf2d4b091284a60acc6c16d166ea7cafade209f (patch) | |
tree | 20af66bb3ffb2e05c3e3960473b6c4da015b1241 /hadrian | |
parent | b9d4dd9cbc4f1dd40e6beaf5d8301ac9d3034fca (diff) | |
download | haskell-ccf2d4b091284a60acc6c16d166ea7cafade209f.tar.gz |
rts: Infrastructure for testing with ThreadSanitizer
Diffstat (limited to 'hadrian')
-rw-r--r-- | hadrian/hadrian.cabal | 3 | ||||
-rw-r--r-- | hadrian/src/Flavour.hs | 10 | ||||
-rwxr-xr-x | hadrian/src/Settings.hs | 6 | ||||
-rw-r--r-- | hadrian/src/Settings/Flavours/ThreadSanitizer.hs | 9 |
4 files changed, 25 insertions, 3 deletions
diff --git a/hadrian/hadrian.cabal b/hadrian/hadrian.cabal index 611cd20796..042587ebcc 100644 --- a/hadrian/hadrian.cabal +++ b/hadrian/hadrian.cabal @@ -105,13 +105,14 @@ executable hadrian , Settings.Default , Settings.Flavours.Benchmark , Settings.Flavours.Development + , Settings.Flavours.GhcInGhci , Settings.Flavours.Llvm , Settings.Flavours.Performance , Settings.Flavours.Profiled , Settings.Flavours.Quick , Settings.Flavours.QuickCross , Settings.Flavours.Quickest - , Settings.Flavours.GhcInGhci + , Settings.Flavours.ThreadSanitizer , Settings.Flavours.Validate , Settings.Packages , Settings.Parser diff --git a/hadrian/src/Flavour.hs b/hadrian/src/Flavour.hs index 56488f0b0a..0a4439827f 100644 --- a/hadrian/src/Flavour.hs +++ b/hadrian/src/Flavour.hs @@ -4,6 +4,7 @@ module Flavour -- * Flavour transformers , addArgs , splitSections, splitSectionsIf + , enableThreadSanitizer , enableDebugInfo, enableTickyGhc ) where @@ -115,3 +116,12 @@ splitSections :: Flavour -> Flavour splitSections = splitSectionsIf (/=ghc) -- Disable section splitting for the GHC library. It takes too long and -- there is little benefit. + +enableThreadSanitizer :: Flavour -> Flavour +enableThreadSanitizer = addArgs $ mconcat + [ builder (Ghc CompileHs) ? arg "-optc-fsanitize=thread" + , builder (Ghc CompileCWithGhc) ? (arg "-optc-fsanitize=thread" <> arg "-DTSAN_ENABLED") + , builder (Ghc LinkHs) ? arg "-optl-fsanitize=thread" + , builder (Cc CompileC) ? (arg "-fsanitize=thread" <> arg "-DTSAN_ENABLED") + , builder (Cabal Flags) ? arg "thread-sanitizer" + ] diff --git a/hadrian/src/Settings.hs b/hadrian/src/Settings.hs index bf4919312b..ff51c01acb 100755 --- a/hadrian/src/Settings.hs +++ b/hadrian/src/Settings.hs @@ -14,13 +14,14 @@ import UserSettings (userFlavours, userPackages, userDefaultFlavour) import {-# SOURCE #-} Settings.Default import Settings.Flavours.Benchmark import Settings.Flavours.Development +import Settings.Flavours.GhcInGhci import Settings.Flavours.Llvm import Settings.Flavours.Performance import Settings.Flavours.Profiled import Settings.Flavours.Quick import Settings.Flavours.Quickest import Settings.Flavours.QuickCross -import Settings.Flavours.GhcInGhci +import Settings.Flavours.ThreadSanitizer import Settings.Flavours.Validate import Control.Monad.Except @@ -58,7 +59,8 @@ hadrianFlavours = , quickestFlavour , quickCrossFlavour, benchmarkLlvmFlavour , performanceLlvmFlavour, profiledLlvmFlavour, quickLlvmFlavour - , ghcInGhciFlavour, validateFlavour, slowValidateFlavour ] + , ghcInGhciFlavour, validateFlavour, slowValidateFlavour + , threadSanitizerFlavour ] -- | This action looks up a flavour with the name given on the -- command line with @--flavour@, defaulting to 'userDefaultFlavour' diff --git a/hadrian/src/Settings/Flavours/ThreadSanitizer.hs b/hadrian/src/Settings/Flavours/ThreadSanitizer.hs new file mode 100644 index 0000000000..722370f5cd --- /dev/null +++ b/hadrian/src/Settings/Flavours/ThreadSanitizer.hs @@ -0,0 +1,9 @@ +module Settings.Flavours.ThreadSanitizer (threadSanitizerFlavour) where + +import Flavour +import Settings.Flavours.Validate + +threadSanitizerFlavour :: Flavour +threadSanitizerFlavour = + enableThreadSanitizer (validateFlavour + { name = "thread-sanitizer" }) |