diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2022-05-24 10:59:57 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-05-30 13:44:50 -0400 |
commit | cac8c7bb098002ddce0ef7c1e4429940d22d8cc2 (patch) | |
tree | 547f1dba2414774d0c2fd6d2c5e5e838d22e00ad | |
parent | 6656f0165a30fc2a22208532ba384fc8e2f11b46 (diff) | |
download | haskell-cac8c7bb098002ddce0ef7c1e4429940d22d8cc2.tar.gz |
hadrian: Fix building from source-dist without alex/happy
This fixes two bugs which were adding dependencies on alex/happy when
building from a source dist.
* When we try to pass `--with-alex` and `--with-happy` to cabal when
configuring but the builders are not set. This is fixed by making them
optional.
* When we configure, cabal requires alex/happy because of the
build-tool-depends fields. These are now made optional with a cabal
flag (build-tool-depends) for compiler/hpc-bin/genprimopcode.
Fixes #21627
-rw-r--r-- | compiler/ghc.cabal.in | 9 | ||||
-rw-r--r-- | hadrian/src/Builder.hs | 4 | ||||
-rw-r--r-- | hadrian/src/Settings/Packages.hs | 9 | ||||
-rw-r--r-- | utils/genprimopcode/genprimopcode.cabal | 7 | ||||
-rw-r--r-- | utils/hpc/hpc-bin.cabal | 7 |
5 files changed, 33 insertions, 3 deletions
diff --git a/compiler/ghc.cabal.in b/compiler/ghc.cabal.in index 9e61e0e2a2..74d95cdc65 100644 --- a/compiler/ghc.cabal.in +++ b/compiler/ghc.cabal.in @@ -56,6 +56,12 @@ Flag dynamic-system-linker Default: True Manual: True +-- hadrian disables this flag because the user may be building from a source +-- distribution where the parser has already been generated. +Flag build-tool-depends + Description: Use build-tool-depends + Default: True + Library Default-Language: Haskell2010 Exposed: False @@ -67,7 +73,8 @@ Library FunTypes.h ghc-llvm-version.h - build-tool-depends: alex:alex >= 3.2.6, happy:happy >= 1.20.0, genprimopcode:genprimopcode, deriveConstants:deriveConstants + if flag(build-tool-depends) + build-tool-depends: alex:alex >= 3.2.6, happy:happy >= 1.20.0, genprimopcode:genprimopcode, deriveConstants:deriveConstants Build-Depends: base >= 4.11 && < 4.17, deepseq >= 1.4 && < 1.5, diff --git a/hadrian/src/Builder.hs b/hadrian/src/Builder.hs index 160eb44f7a..b80ac59f8d 100644 --- a/hadrian/src/Builder.hs +++ b/hadrian/src/Builder.hs @@ -390,6 +390,10 @@ instance H.Builder Builder where isOptional :: Builder -> Bool isOptional = \case Objdump -> True + -- alex and happy are not required when building source distributions + -- and ./configure will complain if they are not available when building in-tree + Happy -> True + Alex -> True _ -> False -- | Determine the location of a system 'Builder'. diff --git a/hadrian/src/Settings/Packages.hs b/hadrian/src/Settings/Packages.hs index 85fd0812f6..871e7235f8 100644 --- a/hadrian/src/Settings/Packages.hs +++ b/hadrian/src/Settings/Packages.hs @@ -73,6 +73,7 @@ packageArgs = do , builder (Cabal Flags) ? mconcat [ andM [expr ghcWithInterpreter, notStage0] `cabalFlag` "internal-interpreter" , notM cross `cabalFlag` "terminfo" + , arg "-build-tool-depends" ] , builder (Haddock BuildPackage) ? arg ("--optghc=-I" ++ path) ] @@ -202,6 +203,14 @@ packageArgs = do , package runGhc ? builder Ghc ? input "**/Main.hs" ? (\version -> ["-cpp", "-DVERSION=" ++ show version]) <$> getSetting ProjectVersion + + --------------------------------- genprimopcode ------------------------ + , package genprimopcode + ? builder (Cabal Flags) ? arg "-build-tool-depends" + + --------------------------------- hpcBin ---------------------------------- + , package hpcBin + ? builder (Cabal Flags) ? arg "-build-tool-depends" ] ghcBignumArgs :: Args diff --git a/utils/genprimopcode/genprimopcode.cabal b/utils/genprimopcode/genprimopcode.cabal index 2dc581dc49..2b92735c2f 100644 --- a/utils/genprimopcode/genprimopcode.cabal +++ b/utils/genprimopcode/genprimopcode.cabal @@ -17,6 +17,10 @@ Category: Development build-type: Simple cabal-version: 2.0 +Flag build-tool-depends + Description: Use build-tool-depends + Default: True + Executable genprimopcode Default-Language: Haskell2010 Main-Is: Main.hs @@ -26,4 +30,5 @@ Executable genprimopcode Syntax Build-Depends: base >= 4 && < 5, array - build-tool-depends: alex:alex >= 3.2.6, happy:happy >= 1.20.0 + if flag(build-tool-depends) + build-tool-depends: alex:alex >= 3.2.6, happy:happy >= 1.20.0 diff --git a/utils/hpc/hpc-bin.cabal b/utils/hpc/hpc-bin.cabal index 6e344de856..62601cdb07 100644 --- a/utils/hpc/hpc-bin.cabal +++ b/utils/hpc/hpc-bin.cabal @@ -12,6 +12,10 @@ Category: Development build-type: Simple cabal-version: 2.0 +Flag build-tool-depends + Description: Use build-tool-depends + Default: True + Executable hpc Default-Language: Haskell2010 Main-Is: Main.hs @@ -36,4 +40,5 @@ Executable hpc array >= 0.1 && < 0.6, hpc >= 0.6.1 && < 0.7 - build-tool-depends: happy:happy >= 1.20.0 + if flag(build-tool-depends) + build-tool-depends: happy:happy >= 1.20.0 |