summaryrefslogtreecommitdiff
path: root/hadrian/src/Flavour.hs
diff options
context:
space:
mode:
Diffstat (limited to 'hadrian/src/Flavour.hs')
-rw-r--r--hadrian/src/Flavour.hs10
1 files changed, 10 insertions, 0 deletions
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"
+ ]