summaryrefslogtreecommitdiff
path: root/hadrian
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2020-11-08 09:29:16 -0500
committerBen Gamari <ben@smart-cactus.org>2020-11-08 09:29:16 -0500
commit638f38c50e80a19275f3a06535a0dd8130a17a53 (patch)
treeac18855cd2f39544e4841866fbabb3f86a4d1f35 /hadrian
parentb1d2c1f3246b3740589a59bdf7648c13de47c32b (diff)
parent07e82ba52228580cfbd90ff031e657acbecc715b (diff)
downloadhaskell-638f38c50e80a19275f3a06535a0dd8130a17a53.tar.gz
Merge remote-tracking branch 'origin/wip/tsan/all'
Diffstat (limited to 'hadrian')
-rw-r--r--hadrian/hadrian.cabal3
-rw-r--r--hadrian/src/Flavour.hs11
-rwxr-xr-xhadrian/src/Settings.hs6
-rw-r--r--hadrian/src/Settings/Flavours/ThreadSanitizer.hs9
4 files changed, 26 insertions, 3 deletions
diff --git a/hadrian/hadrian.cabal b/hadrian/hadrian.cabal
index e78668e3a2..4184aadd5f 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..d2adbe356e 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,13 @@ 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"
+ , builder RunTest ? arg "--config=have_thread_sanitizer=True"
+ ]
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" })