Skip to content
This repository has been archived by the owner on Aug 2, 2020. It is now read-only.

Commit

Permalink
Work around the "can't use Natural in base" problem on a per-flavour …
Browse files Browse the repository at this point in the history
…basis (#676)

* Work around the "can't use natural in base" problem on a per-flavour basis

The only flavours that need the workaround are the ones that build
GHC/{Natural, Num}.hs with -O0, namely 'quick', 'quickest' and 'prof'.
This patches defines the necessary arguments in one place and uses them
in all the aforementionned flavour definitions.

This will allow us to have both quick/quickest/prof builds that come through
as well as an efficient compiler when we want it (with e.g perf), which wasn't
the case before my series of patches for this problem.

* address @snowleopard's feedback
  • Loading branch information
alpmestan authored and snowleopard committed Sep 5, 2018
1 parent 921dbbd commit 1bbc4b3
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 4 deletions.
1 change: 1 addition & 0 deletions hadrian.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ executable hadrian
, Settings.Builders.RunTest
, Settings.Builders.Xelatex
, Settings.Default
, Settings.Flavours.Common
, Settings.Flavours.Development
, Settings.Flavours.Performance
, Settings.Flavours.Profiled
Expand Down
11 changes: 11 additions & 0 deletions src/Settings/Flavours/Common.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Settings.Flavours.Common where

import Expression

-- See https://ghc.haskell.org/trac/ghc/ticket/15286 and
-- https://phabricator.haskell.org/D4880
naturalInBaseFixArgs :: Args
naturalInBaseFixArgs = mconcat
[ input "//Natural.hs" ? pure ["-fno-omit-interface-pragmas"]
, input "//Num.hs" ? pure ["-fno-ignore-interface-pragmas"]
]
6 changes: 5 additions & 1 deletion src/Settings/Flavours/Profiled.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module Settings.Flavours.Profiled (profiledFlavour) where
import Expression
import Flavour
import {-# SOURCE #-} Settings.Default
import Settings.Flavours.Common (naturalInBaseFixArgs)

-- Please update doc/flavours.md when changing this file.
profiledFlavour :: Flavour
Expand All @@ -13,7 +14,10 @@ profiledFlavour = defaultFlavour

profiledArgs :: Args
profiledArgs = sourceArgs SourceArgs
{ hsDefault = pure ["-O0", "-H64m"]
{ hsDefault = mconcat
[ pure ["-O0", "-H64m"]
, naturalInBaseFixArgs
]
, hsLibrary = notStage0 ? arg "-O"
, hsCompiler = arg "-O"
, hsGhc = arg "-O" }
6 changes: 5 additions & 1 deletion src/Settings/Flavours/Quick.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Expression
import Flavour
import Oracles.Flag
import {-# SOURCE #-} Settings.Default
import Settings.Flavours.Common (naturalInBaseFixArgs)

-- Please update doc/flavours.md when changing this file.
quickFlavour :: Flavour
Expand All @@ -16,7 +17,10 @@ quickFlavour = defaultFlavour

quickArgs :: Args
quickArgs = sourceArgs SourceArgs
{ hsDefault = pure ["-O0", "-H64m"]
{ hsDefault = mconcat $
[ pure ["-O0", "-H64m"]
, naturalInBaseFixArgs
]
, hsLibrary = notStage0 ? arg "-O"
, hsCompiler = stage0 ? arg "-O"
, hsGhc = stage0 ? arg "-O" }
6 changes: 5 additions & 1 deletion src/Settings/Flavours/QuickCross.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Expression
import Flavour
import Oracles.Flag
import {-# SOURCE #-} Settings.Default
import Settings.Flavours.Common

-- Please update doc/flavours.md when changing this file.
quickCrossFlavour :: Flavour
Expand All @@ -16,7 +17,10 @@ quickCrossFlavour = defaultFlavour

quickCrossArgs :: Args
quickCrossArgs = sourceArgs SourceArgs
{ hsDefault = pure ["-O0", "-H64m"]
{ hsDefault = mconcat $
[ pure ["-O0", "-H64m"]
, naturalInBaseFixArgs
]
, hsLibrary = notStage0 ? mconcat [ arg "-O", arg "-fllvm" ]
, hsCompiler = stage0 ? arg "-O"
, hsGhc = mconcat
Expand Down
6 changes: 5 additions & 1 deletion src/Settings/Flavours/Quickest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module Settings.Flavours.Quickest (quickestFlavour) where
import Expression
import Flavour
import {-# SOURCE #-} Settings.Default
import Settings.Flavours.Common (naturalInBaseFixArgs)

-- Please update doc/flavours.md when changing this file.
quickestFlavour :: Flavour
Expand All @@ -14,7 +15,10 @@ quickestFlavour = defaultFlavour

quickestArgs :: Args
quickestArgs = sourceArgs SourceArgs
{ hsDefault = pure ["-O0", "-H64m"]
{ hsDefault = mconcat $
[ pure ["-O0", "-H64m"]
, naturalInBaseFixArgs
]
, hsLibrary = mempty
, hsCompiler = stage0 ? arg "-O"
, hsGhc = stage0 ? arg "-O" }
Expand Down

0 comments on commit 1bbc4b3

Please sign in to comment.