[Git][ghc/ghc][master] 2 commits: Disable optimisation when building Cabal lib for stage0

Marge Bot gitlab at gitlab.haskell.org
Sun Jun 16 03:32:42 UTC 2019



 Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
20b4d5ec by Ben Gamari at 2019-06-16T03:32:38Z
Disable optimisation when building Cabal lib for stage0

This disables optimisation when building Cabal for Hadrian and
stage0 `ghc-cabal`. Cabal is performance critical in neither case nor
will any performance difference here be visible to the end-user.

See #16817.

- - - - -
76b7f619 by Ben Gamari at 2019-06-16T03:32:38Z
Disable optimisation when building Cabal in development flavours

This updates the make and Hadrian build flavours targetting developers
to disable optimisation when building the Cabal library. Cabal tends to
tickle some very bad compiler performance cases (e.g. #16577) so
disabling optimisation here makes a sizeable impact on overall build
time.

See #16817.

- - - - -


6 changed files:

- hadrian/cabal.project
- hadrian/src/Settings/Flavours/Development.hs
- mk/flavours/devel1.mk
- mk/flavours/devel2.mk
- mk/flavours/validate.mk
- utils/ghc-cabal/ghc.mk


Changes:

=====================================
hadrian/cabal.project
=====================================
@@ -1,2 +1,8 @@
 packages: ./
           ../libraries/Cabal/Cabal/
+
+-- N.B. Compile with -O0 since this is not a performance-critical executable
+-- and the Cabal takes nearly twice as long to build with -O1. See #16817.
+package Cabal
+  optimization: False
+


=====================================
hadrian/src/Settings/Flavours/Development.hs
=====================================
@@ -2,6 +2,7 @@ module Settings.Flavours.Development (developmentFlavour) where
 
 import Expression
 import Flavour
+import Packages
 import {-# SOURCE #-} Settings.Default
 
 -- Please update doc/flavours.md when changing this file.
@@ -17,7 +18,10 @@ developmentArgs :: Stage -> Args
 developmentArgs ghcStage = do
     stage <- getStage
     sourceArgs SourceArgs
-        { hsDefault  = pure ["-O", "-H64m"]
+        { hsDefault  = mconcat [ pure ["-O", "-H64m"],
+                                 -- Disable optimization when building Cabal;
+                                 -- this saves many minutes of build time.
+                                 package cabal ? pure ["-O0"]]
         , hsLibrary  = notStage0 ? arg "-dcore-lint"
         , hsCompiler = mconcat [stage0 ? arg "-O2",
                                 succ stage == ghcStage ? pure ["-O0", "-DDEBUG"]]


=====================================
mk/flavours/devel1.mk
=====================================
@@ -10,3 +10,7 @@ BUILD_SPHINX_PDF   = NO
 BUILD_MAN          = NO
 
 LAX_DEPENDENCIES   = YES
+
+# Reduce optimisation when building Cabal; this makes a significant difference
+# in overall build time. See #16817.
+libraries/Cabal_dist-install_HC_OPTS += -O0


=====================================
mk/flavours/devel2.mk
=====================================
@@ -10,3 +10,7 @@ BUILD_SPHINX_PDF   = NO
 BUILD_MAN          = NO
 
 LAX_DEPENDENCIES   = YES
+
+# Reduce optimisation when building Cabal; this makes a significant difference
+# in overall build time. See #16817.
+libraries/Cabal_dist-install_HC_OPTS += -O0


=====================================
mk/flavours/validate.mk
=====================================
@@ -27,6 +27,10 @@ endif
 
 WERROR             = -Werror
 
+# Reduce optimisation when building Cabal; this makes a significant difference
+# in overall build time. See #16817.
+libraries/Cabal_dist-install_HC_OPTS += -O0
+
 # DO NOT EDIT THIS FILE! Instead, create a file mk/validate.mk, whose settings
 # will override these. See also mk/custom-settings.mk.
 #
@@ -36,6 +40,7 @@ WERROR             = -Werror
 #
 #
 # Note [validate build settings]
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 #
 # Using GhcStage2HcOpts=-O (rather than -O0) here bringes my validate down from
 # 22mins to 16 mins. Compiling stage2 takes longer, but we gain a faster


=====================================
utils/ghc-cabal/ghc.mk
=====================================
@@ -52,10 +52,13 @@ $(ghc-cabal_DIST_BINARY): $(wildcard libraries/Cabal/Cabal/Distribution/*/*/*.hs
 $(ghc-cabal_DIST_BINARY): $(wildcard libraries/Cabal/Cabal/Distribution/*/*.hs)
 $(ghc-cabal_DIST_BINARY): $(wildcard libraries/Cabal/Cabal/Distribution/*.hs)
 
+# N.B. Compile with -O0 since this is not a performance-critical executable
+# and the Cabal takes nearly twice as long to build with -O1. See #16817.
 $(ghc-cabal_DIST_BINARY): $(CABAL_LEXER_DEP) utils/ghc-cabal/Main.hs $(TOUCH_DEP) | $$(dir $$@)/. bootstrapping/.
 	"$(GHC)" $(SRC_HC_OPTS) \
 	       $(addprefix -optc, $(SRC_CC_OPTS) $(CONF_CC_OPTS_STAGE0)) \
 	       $(addprefix -optl, $(SRC_LD_OPTS) $(CONF_GCC_LINKER_OPTS_STAGE0)) \
+				 -O0 \
 	       -hide-all-packages \
 	       $(addprefix -package , $(CABAL_BUILD_DEPS)) \
 	       --make utils/ghc-cabal/Main.hs -o $@ \



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/compare/5da6c86f7b1304af3c314b3f9c0b007d6508c427...76b7f619385ac5d126dd186ff3bfe4cdad9349e7

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/compare/5da6c86f7b1304af3c314b3f9c0b007d6508c427...76b7f619385ac5d126dd186ff3bfe4cdad9349e7
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20190615/524eafcd/attachment-0001.html>


More information about the ghc-commits mailing list