From ee4dd712e5278b30c7face9269814f2a1d76aa30 Mon Sep 17 00:00:00 2001 From: Shayne Fletcher Date: Wed, 24 Jul 2024 11:45:09 -0400 Subject: [PATCH 1/2] simplify ghc -M, add new tests --- .github/workflows/ghc-lib-da-ghc-8.4.3.yml | 34 ++-- .../ghc-lib-ghc-9.0.2-ghc-8.10.7.yml | 39 +++++ .../ghc-lib-ghc-9.10.1-ghc-9.8.2.yml | 21 +-- .../workflows/ghc-lib-ghc-9.4.8-ghc-9.0.2.yml | 39 +++++ .../workflows/ghc-lib-ghc-9.8.2-ghc-9.6.5.yml | 21 +-- .../ghc-lib-ghc-master-ghc-9.10.1.yml | 22 +-- CI.hs | 128 +++----------- ghc-lib-gen.cabal | 6 +- ghc-lib-gen/ghc-lib-parser/ghc-8.10/Main.hs | 24 +-- ghc-lib-gen/ghc-lib-parser/ghc-8.8/Main.hs | 28 +-- ghc-lib-gen/ghc-lib-parser/ghc-9.0/Main.hs | 24 +-- ghc-lib-gen/ghc-lib-parser/ghc-9.10/Main.hs | 38 ++--- ghc-lib-gen/ghc-lib-parser/ghc-9.12/Main.hs | 38 ++--- ghc-lib-gen/ghc-lib-parser/ghc-9.2/Main.hs | 22 +-- ghc-lib-gen/ghc-lib-parser/ghc-9.4/Main.hs | 30 ++-- ghc-lib-gen/ghc-lib-parser/ghc-9.6/Main.hs | 28 +-- ghc-lib-gen/ghc-lib-parser/ghc-9.8/Main.hs | 38 ++--- ghc-lib-gen/src/Ghclibgen.hs | 160 ++++++++---------- 18 files changed, 330 insertions(+), 410 deletions(-) create mode 100644 .github/workflows/ghc-lib-ghc-9.0.2-ghc-8.10.7.yml create mode 100644 .github/workflows/ghc-lib-ghc-9.4.8-ghc-9.0.2.yml diff --git a/.github/workflows/ghc-lib-da-ghc-8.4.3.yml b/.github/workflows/ghc-lib-da-ghc-8.4.3.yml index 634d300a..52af15f8 100644 --- a/.github/workflows/ghc-lib-da-ghc-8.4.3.yml +++ b/.github/workflows/ghc-lib-da-ghc-8.4.3.yml @@ -5,43 +5,35 @@ on: jobs: runhaskell: name: ${{ matrix.os }} - runs-on: ${{ matrix.os }}-latest + runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: - os: [ubuntu, windows] + os: [ubuntu-latest, macos-13, windows-latest] steps: - uses: actions/checkout@v4 + - uses: haskell-actions/setup@v2 + id: setup-haskell + with: + ghc-version: 8.4.3 + cabal-version: 'latest' + - name: Install build tools (macOS) + run: brew install automake + if: matrix.os == 'macos-13' - name: Configure msys2 (windows) shell: bash run: |- echo "MSYSTEM=CLANG64" >> $GITHUB_ENV echo "/c/mingw64/usr/bin" >> $GITHUB_PATH echo "/c/msys64/usr/bin" >> $GITHUB_PATH - if: matrix.os == 'windows' - - name: Install ghcup (windows) - shell: bash - run: |- - curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | BOOTSTRAP_HASKELL_NONINTERACTIVE=1 BOOTSTRAP_HASKELL_GHC_VERSION=8.4.3 BOOTSTRAP_HASKELL_CABAL_VERSION=latest BOOTSTRAP_HASKELL_INSTALL_NO_STACK=1 BOOTSTRAP_HASKELL_INSTALL_NO_STACK_HOOK=1 BOOTSTRAP_HASKELL_ADJUST_BASHRC=N sh - echo "/c/ghcup/bin" >> $GITHUB_PATH - echo "/c/ghcup/ghc/8.4.3/bin" >> $GITHUB_PATH - echo "/c/cabal/bin" >> $GITHUB_PATH - if: matrix.os == 'windows' - - name: Install ghcup (unix) - shell: bash - run: |- - curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | BOOTSTRAP_HASKELL_NONINTERACTIVE=1 BOOTSTRAP_HASKELL_GHC_VERSION=8.4.3 BOOTSTRAP_HASKELL_CABAL_VERSION=latest BOOTSTRAP_HASKELL_INSTALL_NO_STACK=1 BOOTSTRAP_HASKELL_INSTALL_NO_STACK_HOOK=1 BOOTSTRAP_HASKELL_ADJUST_BASHRC=N sh - echo "$HOME/.ghcup/bin" >> $GITHUB_PATH - echo "$HOME/.ghcup/ghc/8.4.3/bin" >> $GITHUB_PATH - echo "$HOME/.cabal/bin" >> $GITHUB_PATH - if: matrix.os == 'ubuntu' || matrix.os == 'macos' + if: matrix.os == 'windows-latest' - name: Run CI.hs (windows) shell: C:\msys64\usr\bin\bash.exe --noprofile --norc -e -o pipefail '{0}' run: |- pacman -S autoconf automake-wrapper make patch python tar mintty --noconfirm cabal run exe:ghc-lib-build-tool -- --da - if: matrix.os == 'windows' + if: matrix.os == 'windows-latest' - name: Run CI.hs (unix) shell: bash run: cabal run exe:ghc-lib-build-tool -- --da - if: matrix.os == 'ubuntu' || matrix.os == 'macos' + if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-13' diff --git a/.github/workflows/ghc-lib-ghc-9.0.2-ghc-8.10.7.yml b/.github/workflows/ghc-lib-ghc-9.0.2-ghc-8.10.7.yml new file mode 100644 index 00000000..f6b807dd --- /dev/null +++ b/.github/workflows/ghc-lib-ghc-9.0.2-ghc-8.10.7.yml @@ -0,0 +1,39 @@ +name: ghc-lib-ghc-9.0.2-ghc-8.10.7 +on: + push: + pull_request: +jobs: + runhaskell: + name: ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-13, windows-latest] + steps: + - uses: actions/checkout@v4 + - uses: haskell-actions/setup@v2 + id: setup-haskell + with: + ghc-version: 8.10.7 + cabal-version: 'latest' + - name: Install build tools (macOS) + run: brew install automake + if: matrix.os == 'macos-13' + - name: Configure msys2 (windows) + shell: bash + run: |- + echo "MSYSTEM=CLANG64" >> $GITHUB_ENV + echo "/c/mingw64/usr/bin" >> $GITHUB_PATH + echo "/c/msys64/usr/bin" >> $GITHUB_PATH + if: matrix.os == 'windows-latest' + - name: Run CI.hs (windows) + shell: C:\msys64\usr\bin\bash.exe --noprofile --norc -e -o pipefail '{0}' + run: |- + pacman -S autoconf automake-wrapper make patch python tar mintty --noconfirm + cabal run exe:ghc-lib-build-tool --constraint=any."happy==1.19.12" --constraint="any.alex==3.2.7.3" -- --ghc-flavor ghc-9.0.2 + if: matrix.os == 'windows-latest' + - name: Run CI.hs (unix) + shell: bash + run: cabal run exe:ghc-lib-build-tool --constraint="any.happy==1.19.12" --constraint="any.alex==3.2.7.3" -- --ghc-flavor ghc-9.0.2 + if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-13' diff --git a/.github/workflows/ghc-lib-ghc-9.10.1-ghc-9.8.2.yml b/.github/workflows/ghc-lib-ghc-9.10.1-ghc-9.8.2.yml index 4a1a49a8..aeca98b9 100644 --- a/.github/workflows/ghc-lib-ghc-9.10.1-ghc-9.8.2.yml +++ b/.github/workflows/ghc-lib-ghc-9.10.1-ghc-9.8.2.yml @@ -12,6 +12,11 @@ jobs: os: [ubuntu, macos, windows] steps: - uses: actions/checkout@v4 + - uses: haskell-actions/setup@v2 + id: setup-haskell + with: + ghc-version: 9.8.2 + cabal-version: 'latest' - name: Install build tools (macOS) run: brew install automake if: matrix.os == 'macos' @@ -22,22 +27,6 @@ jobs: echo "/c/mingw64/usr/bin" >> $GITHUB_PATH echo "/c/msys64/usr/bin" >> $GITHUB_PATH if: matrix.os == 'windows' - - name: Install ghcup (windows) - shell: bash - run: |- - curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | BOOTSTRAP_HASKELL_NONINTERACTIVE=1 BOOTSTRAP_HASKELL_GHC_VERSION=9.8.2 BOOTSTRAP_HASKELL_CABAL_VERSION=latest BOOTSTRAP_HASKELL_INSTALL_NO_STACK=1 BOOTSTRAP_HASKELL_INSTALL_NO_STACK_HOOK=1 BOOTSTRAP_HASKELL_ADJUST_BASHRC=N sh - echo "/c/ghcup/bin" >> $GITHUB_PATH - echo "/c/ghcup/ghc/9.8.2/bin" >> $GITHUB_PATH - echo "/c/cabal/bin" >> $GITHUB_PATH - if: matrix.os == 'windows' - - name: Install ghcup (unix) - shell: bash - run: |- - curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | BOOTSTRAP_HASKELL_NONINTERACTIVE=1 BOOTSTRAP_HASKELL_GHC_VERSION=9.8.2 BOOTSTRAP_HASKELL_CABAL_VERSION=latest BOOTSTRAP_HASKELL_INSTALL_NO_STACK=1 BOOTSTRAP_HASKELL_INSTALL_NO_STACK_HOOK=1 BOOTSTRAP_HASKELL_ADJUST_BASHRC=N sh - echo "$HOME/.ghcup/bin" >> $GITHUB_PATH - echo "$HOME/.ghcup/ghc/9.8.2/bin" >> $GITHUB_PATH - echo "$HOME/.cabal/bin" >> $GITHUB_PATH - if: matrix.os == 'ubuntu' || matrix.os == 'macos' - name: Run CI.hs (windows) shell: C:\msys64\usr\bin\bash.exe --noprofile --norc -e -o pipefail '{0}' run: |- diff --git a/.github/workflows/ghc-lib-ghc-9.4.8-ghc-9.0.2.yml b/.github/workflows/ghc-lib-ghc-9.4.8-ghc-9.0.2.yml new file mode 100644 index 00000000..c21376d1 --- /dev/null +++ b/.github/workflows/ghc-lib-ghc-9.4.8-ghc-9.0.2.yml @@ -0,0 +1,39 @@ +name: ghc-lib-ghc-9.4.8-ghc-9.0.2 +on: + push: + pull_request: +jobs: + runhaskell: + name: ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-13, windows-latest] + steps: + - uses: actions/checkout@v4 + - uses: haskell-actions/setup@v2 + id: setup-haskell + with: + ghc-version: 9.0.2 + cabal-version: 'latest' + - name: Install build tools (macOS) + run: brew install automake + if: matrix.os == 'macos-13' + - name: Configure msys2 (windows) + shell: bash + run: |- + echo "MSYSTEM=CLANG64" >> $GITHUB_ENV + echo "/c/mingw64/usr/bin" >> $GITHUB_PATH + echo "/c/msys64/usr/bin" >> $GITHUB_PATH + if: matrix.os == 'windows-latest' + - name: Run CI.hs (windows) + shell: C:\msys64\usr\bin\bash.exe --noprofile --norc -e -o pipefail '{0}' + run: |- + pacman -S autoconf automake-wrapper make patch python tar mintty --noconfirm + cabal run exe:ghc-lib-build-tool -- --ghc-flavor ghc-9.4.8 + if: matrix.os == 'windows-latest' + - name: Run CI.hs (unix) + shell: bash + run: cabal run exe:ghc-lib-build-tool -- --ghc-flavor ghc-9.4.8 + if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-13' diff --git a/.github/workflows/ghc-lib-ghc-9.8.2-ghc-9.6.5.yml b/.github/workflows/ghc-lib-ghc-9.8.2-ghc-9.6.5.yml index 5bf86747..dd91b77a 100644 --- a/.github/workflows/ghc-lib-ghc-9.8.2-ghc-9.6.5.yml +++ b/.github/workflows/ghc-lib-ghc-9.8.2-ghc-9.6.5.yml @@ -12,6 +12,11 @@ jobs: os: [ubuntu, macos, windows] steps: - uses: actions/checkout@v4 + - uses: haskell-actions/setup@v2 + id: setup-haskell + with: + ghc-version: 9.6.5 + cabal-version: 'latest' - name: Install build tools (macOS) run: brew install automake if: matrix.os == 'macos' @@ -22,22 +27,6 @@ jobs: echo "/c/mingw64/usr/bin" >> $GITHUB_PATH echo "/c/msys64/usr/bin" >> $GITHUB_PATH if: matrix.os == 'windows' - - name: Install ghcup (windows) - shell: bash - run: |- - curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | BOOTSTRAP_HASKELL_NONINTERACTIVE=1 BOOTSTRAP_HASKELL_GHC_VERSION=9.6.5 BOOTSTRAP_HASKELL_CABAL_VERSION=latest BOOTSTRAP_HASKELL_INSTALL_NO_STACK=1 BOOTSTRAP_HASKELL_INSTALL_NO_STACK_HOOK=1 BOOTSTRAP_HASKELL_ADJUST_BASHRC=N sh - echo "/c/ghcup/bin" >> $GITHUB_PATH - echo "/c/ghcup/ghc/9.6.5/bin" >> $GITHUB_PATH - echo "/c/cabal/bin" >> $GITHUB_PATH - if: matrix.os == 'windows' - - name: Install ghcup (unix) - shell: bash - run: |- - curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | BOOTSTRAP_HASKELL_NONINTERACTIVE=1 BOOTSTRAP_HASKELL_GHC_VERSION=9.6.5 BOOTSTRAP_HASKELL_CABAL_VERSION=latest BOOTSTRAP_HASKELL_INSTALL_NO_STACK=1 BOOTSTRAP_HASKELL_INSTALL_NO_STACK_HOOK=1 BOOTSTRAP_HASKELL_ADJUST_BASHRC=N sh - echo "$HOME/.ghcup/bin" >> $GITHUB_PATH - echo "$HOME/.ghcup/ghc/9.6.5/bin" >> $GITHUB_PATH - echo "$HOME/.cabal/bin" >> $GITHUB_PATH - if: matrix.os == 'ubuntu' || matrix.os == 'macos' - name: Run CI.hs (windows) shell: C:\msys64\usr\bin\bash.exe --noprofile --norc -e -o pipefail '{0}' run: |- diff --git a/.github/workflows/ghc-lib-ghc-master-ghc-9.10.1.yml b/.github/workflows/ghc-lib-ghc-master-ghc-9.10.1.yml index 9f9888cd..e8031c28 100644 --- a/.github/workflows/ghc-lib-ghc-master-ghc-9.10.1.yml +++ b/.github/workflows/ghc-lib-ghc-master-ghc-9.10.1.yml @@ -12,6 +12,11 @@ jobs: os: [ubuntu, macos, windows] steps: - uses: actions/checkout@v4 + - uses: haskell-actions/setup@v2 + id: setup-haskell + with: + ghc-version: 9.10.1 + cabal-version: 'latest' - name: Install build tools (macOS) run: brew install automake if: matrix.os == 'macos' @@ -22,23 +27,6 @@ jobs: echo "/c/mingw64/usr/bin" >> $GITHUB_PATH echo "/c/msys64/usr/bin" >> $GITHUB_PATH if: matrix.os == 'windows' - - name: Install ghcup (windows) - shell: bash - run: |- - curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | BOOTSTRAP_HASKELL_NONINTERACTIVE=1 BOOTSTRAP_HASKELL_GHC_VERSION=9.10.1 BOOTSTRAP_HASKELL_CABAL_VERSION=latest BOOTSTRAP_HASKELL_INSTALL_NO_STACK=1 BOOTSTRAP_HASKELL_INSTALL_NO_STACK_HOOK=1 BOOTSTRAP_HASKELL_ADJUST_BASHRC=N sh - echo "/c/ghcup/bin" >> $GITHUB_PATH - echo "/c/ghcup/ghc/9.10.1/bin" >> $GITHUB_PATH - echo "/c/cabal/bin" >> $GITHUB_PATH - if: matrix.os == 'windows' - - name: Install ghcup (unix) - shell: bash - run: |- - curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | BOOTSTRAP_HASKELL_NONINTERACTIVE=1 BOOTSTRAP_HASKELL_GHC_VERSION=9.10.1 BOOTSTRAP_HASKELL_CABAL_VERSION=latest BOOTSTRAP_HASKELL_INSTALL_NO_STACK=1 BOOTSTRAP_HASKELL_INSTALL_NO_STACK_HOOK=1 BOOTSTRAP_HASKELL_ADJUST_BASHRC=N sh - ls "$HOME"/.ghcup/bin - echo "$HOME/.ghcup/bin" >> $GITHUB_PATH - echo "$HOME/.ghcup/ghc/9.10.1/bin" >> $GITHUB_PATH - echo "$HOME/.cabal/bin" >> $GITHUB_PATH - if: matrix.os == 'ubuntu' || matrix.os == 'macos' - name: Run CI.hs (windows) shell: C:\msys64\usr\bin\bash.exe --noprofile --norc -e -o pipefail '{0}' run: |- diff --git a/CI.hs b/CI.hs index 278f48ba..1f00b7ad 100755 --- a/CI.hs +++ b/CI.hs @@ -7,23 +7,19 @@ {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE CPP #-} import Control.Monad.Extra +import Data.Foldable +import Data.List.Extra +import Data.Time.Calendar +import Data.Time.Clock +import GHC.Stack +import qualified Options.Applicative as Opts import System.Directory +import System.Exit import System.FilePath import System.IO.Extra -import System.Info.Extra +import System.IO.Unsafe import System.Process.Extra import System.Time.Extra -import System.Info (os, arch) -import System.Exit -import System.Environment -import Data.Maybe -import Data.List.Extra -import Data.Time.Clock -import Data.Time.Calendar -import qualified Options.Applicative as Opts -import Data.Foldable -import GHC.Stack -import System.IO.Unsafe main :: IO () main = do @@ -33,26 +29,17 @@ main = do <> Opts.progDesc "Build ghc-lib and ghc-lib-parser tarballs." <> Opts.header "CI - CI script for ghc-lib" ) - Options { ghcFlavor, noGhcCheckout, noBuilds, stackOptions, versionSuffix } <- Opts.execParser opts - version <- buildDists ghcFlavor noGhcCheckout noBuilds stackOptions versionSuffix + Options { ghcFlavor, noGhcCheckout, noBuilds, versionSuffix } <- Opts.execParser opts + version <- buildDists ghcFlavor noGhcCheckout noBuilds versionSuffix putStrLn version data Options = Options { ghcFlavor :: GhcFlavor , noGhcCheckout :: Bool , noBuilds :: Bool - , stackOptions :: StackOptions , versionSuffix :: Maybe String } deriving (Show) -data StackOptions = StackOptions - { stackYaml :: Maybe String -- Optional config file - , resolver :: Maybe String -- If 'Just _', override stack.yaml. - , verbosity :: Maybe String -- If provided, pass '--verbosity=xxx' to 'stack build'. Valid values are "silent", "error", "warn", "info" or "debug". - , cabalVerbose :: Bool -- If enabled, pass '--cabal-verbose' to 'stack build'. - , ghcOptions :: Maybe String -- If 'Just _', pass '--ghc-options="xxx"' to 'stack build' (for ghc verbose, try 'v3'). - } deriving (Show) - data GhcFlavor = Da DaFlavor | GhcMaster String | Ghc9101 @@ -78,18 +65,6 @@ data DaFlavor = DaFlavor current :: String current = "12d3b66cedd3c80e7c1e030238c92d26631cab8d" -- 2024-07-17 --- Command line argument generators. - -stackYamlOpt :: Maybe FilePath -> String -stackYamlOpt = \case - Just stackYaml -> "--stack-yaml " ++ stackYaml - Nothing -> "" - -stackResolverOpt :: Maybe String -> String -stackResolverOpt = \case - Just resolver -> "--resolver " ++ resolver - Nothing -> "" - ghcFlavorOpt :: GhcFlavor -> String ghcFlavorOpt = \case Ghc9101 -> "--ghc-flavor ghc-9.10.1" @@ -138,19 +113,6 @@ cppOpts :: GhcFlavor -> String cppOpts (Da DaFlavor {cpp}) = unwords $ concat [["--cpp", v] | v <- cpp] cppOpts _ = "" -stackVerbosityOpt :: Maybe String -> String -stackVerbosityOpt = \case - Just verbosity -> "--verbosity=" ++ verbosity - Nothing -> "" - -cabalVerboseOpt :: Bool -> String -cabalVerboseOpt True = "--cabal-verbose"; cabalVerboseOpt False = "" - -ghcOptionsOpt :: Maybe String -> String -ghcOptionsOpt = \case - Just options -> "--ghc-options=\"" ++ options ++ "\"" - Nothing -> "" - genDateSuffix :: IO String genDateSuffix = do UTCTime day _ <- getCurrentTime @@ -184,6 +146,7 @@ genVersionStr flavor suffix = Ghc942 -> "9.4.2" Ghc941 -> "9.4.1" Ghc928 -> "9.2.8" + Ghc927 -> "9.2.7" Ghc926 -> "9.2.6" Ghc925 -> "9.2.5" Ghc924 -> "9.2.4" @@ -221,7 +184,6 @@ parseOptions = Options ( Opts.long "no-builds" <> Opts.help "If enabled, don't build & test packages & examples" ) - <*> parseStackOptions <*> Opts.optional ( Opts.strOption ( Opts.long "version-suffix" @@ -305,38 +267,8 @@ parseOptions = Options <> Opts.showDefault <> Opts.value "https://github.com/digital-asset/ghc.git") -parseStackOptions :: Opts.Parser StackOptions -parseStackOptions = StackOptions - <$> Opts.optional ( Opts.strOption - ( Opts.long "stack-yaml" - <> Opts.help "If specified, pass '--stack-yaml=xxx' to stack" - )) - <*> Opts.optional ( Opts.strOption - ( Opts.long "resolver" - <> Opts.help "If specified, pass '--resolver=xxx' to stack" - )) - <*> Opts.optional ( Opts.strOption - ( Opts.long "verbosity" - <> Opts.help "If specified, pass '--verbosity=xxx' to stack" - )) - <*> Opts.switch - ( Opts.long "cabal-verbose" - <> Opts.help "If specified, pass '--cabal-verbose' to stack" - ) - <*> Opts.optional ( Opts.strOption - ( Opts.long "ghc-options" - <> Opts.help "If specified, pass '--ghc-options=\"xxx\"' to stack" - )) - -buildDists :: GhcFlavor -> Bool -> Bool -> StackOptions -> Maybe String -> IO String -buildDists - ghcFlavor - noGhcCheckout - noBuilds - StackOptions {stackYaml, resolver, verbosity, cabalVerbose, ghcOptions} - versionSuffix - = - do +buildDists :: GhcFlavor -> Bool -> Bool -> Maybe String -> IO String +buildDists ghcFlavor noGhcCheckout noBuilds versionSuffix = do filesInDot <- getDirectoryContents "." let lockFiles = filter (isExtensionOf ".lock") filesInDot tarBalls = filter (isExtensionOf ".tar.gz") filesInDot @@ -366,12 +298,12 @@ buildDists ghcFlavorArg = ghcFlavorOpt ghcFlavor system_ "cabal build exe:ghc-lib-gen" - system_ $ "cabal run exe:ghc-lib-gen -- ghc ../patches --ghc-lib-parser " ++ ghcFlavorArg ++ " " ++ cppOpts ghcFlavor ++ " " ++ stackResolverOpt resolver + system_ $ "cabal run exe:ghc-lib-gen -- ghc ../patches --ghc-lib-parser " ++ ghcFlavorArg ++ " " ++ cppOpts ghcFlavor patchVersion version "ghc/ghc-lib-parser.cabal" mkTarball pkg_ghclib_parser renameDirectory pkg_ghclib_parser "ghc-lib-parser" removeFile "ghc/ghc-lib-parser.cabal" - system_ $ "cabal run exe:ghc-lib-gen -- ghc ../patches --ghc-lib " ++ ghcFlavorArg ++ " " ++ cppOpts ghcFlavor ++ " " ++ stackResolverOpt resolver ++ " " ++ "--skip-init" + system_ $ "cabal run exe:ghc-lib-gen -- ghc ../patches --ghc-lib " ++ ghcFlavorArg ++ " " ++ cppOpts ghcFlavor ++ " --skip-init" patchVersion version "ghc/ghc-lib.cabal" patchConstraints version "ghc/ghc-lib.cabal" mkTarball pkg_ghclib @@ -409,8 +341,7 @@ buildDists when noBuilds exitSuccess - writeFile "cabal.project" ( - unlines $ + writeFile "cabal.project" ( unlines $ [ "packages: " , " ghc-lib-parser/ghc-lib-parser.cabal" , " ghc-lib/ghc-lib.cabal" @@ -420,8 +351,9 @@ buildDists ] ++ [ "constraints: ghc-lib-test-mini-compile +daml-unit-ids" | Da {} <- [ghcFlavor] ] ) - miniHlintCmdFile <- writeCabalCmdFile "ghc-lib-test-mini-hlint" - miniCompileCmdFile <- writeCabalCmdFile "ghc-lib-test-mini-compile" + + writeCabalCmdFile "ghc-lib-test-mini-hlint" + writeCabalCmdFile "ghc-lib-test-mini-compile" cmd "cabal build --ghc-options=-j all" @@ -435,31 +367,11 @@ buildDists where - writeCabalCmdFile :: String -> IO FilePath + writeCabalCmdFile :: String -> IO () writeCabalCmdFile exe = do let filename = exe cmd = "cabal run exe:" ++ exe ++ " --project-dir ../.. -- " writeFile filename cmd - pure filename - - ghcOptionsWithHaddock :: Maybe String -> String - ghcOptionsWithHaddock = ghcOptionsOpt - - prelude :: (String, String) -> String -#if __GLASGOW_HASKELL__ == 902 && __GLASGOW_HASKELL_PATCHLEVEL1__ == 2 - prelude ("darwin", _) = "C_INCLUDE_PATH=`xcrun --show-sdk-path`/usr/include/ffi" -#endif - prelude _ = "" - - stack :: String -> IO () - stack action = cmd $ prelude (os, arch) ++ " stack " ++ - concatMap (<> " ") - [ stackYamlOpt stackYaml - , stackResolverOpt resolver - , stackVerbosityOpt verbosity - , cabalVerboseOpt cabalVerbose - ] ++ - action cmd :: String -> IO () cmd x = do diff --git a/ghc-lib-gen.cabal b/ghc-lib-gen.cabal index 30d7e3f3..5640b96d 100644 --- a/ghc-lib-gen.cabal +++ b/ghc-lib-gen.cabal @@ -21,9 +21,9 @@ flag semaphore-compat common base default-language: Haskell2010 ghc-options: - -Wall -Wincomplete-record-updates - -Wredundant-constraints -Widentities - -Wno-simplifiable-class-constraints + ghc-options: + -Wall -Wincomplete-record-updates -Wredundant-constraints -Widentities + -Wunused-imports -Wno-name-shadowing build-depends: base >= 4.10 && < 5 common lib diff --git a/ghc-lib-gen/ghc-lib-parser/ghc-8.10/Main.hs b/ghc-lib-gen/ghc-lib-parser/ghc-8.10/Main.hs index 18802ecf..28449bef 100644 --- a/ghc-lib-gen/ghc-lib-parser/ghc-8.10/Main.hs +++ b/ghc-lib-gen/ghc-lib-parser/ghc-8.10/Main.hs @@ -1,20 +1,20 @@ -import GHC.Hs +import ApiAnnotation import Config import DynFlags -import StringBuffer -import Fingerprint +import ErrUtils import FastString +import Fingerprint +import GHC.Hs +import GHC.Hs.Dump +import GHC.Platform +import HeaderInfo +import HscTypes +import Lexer +import Module import Outputable +import Panic import Parser -import Lexer import RdrName -import ErrUtils import SrcLoc -import Panic -import HscTypes -import HeaderInfo -import ApiAnnotation +import StringBuffer import ToolSettings -import GHC.Platform -import GHC.Hs.Dump -import Module diff --git a/ghc-lib-gen/ghc-lib-parser/ghc-8.8/Main.hs b/ghc-lib-gen/ghc-lib-parser/ghc-8.8/Main.hs index 9a517826..e724a6f1 100644 --- a/ghc-lib-gen/ghc-lib-parser/ghc-8.8/Main.hs +++ b/ghc-lib-gen/ghc-lib-parser/ghc-8.8/Main.hs @@ -1,20 +1,20 @@ -import HsSyn -import DynFlags +import ApiAnnotation +import Bag import Config +import DynFlags +import ErrUtils +import FastString +import Fingerprint import HeaderInfo -import Parser +import HsDumpAst +import HsSyn +import HscTypes import Lexer -import RdrName -import Fingerprint +import Module import Outputable -import SrcLoc import Panic -import ErrUtils -import HscTypes -import ApiAnnotation -import FastString -import StringBuffer -import Bag +import Parser import Platform -import HsDumpAst -import Module +import RdrName +import SrcLoc +import StringBuffer diff --git a/ghc-lib-gen/ghc-lib-parser/ghc-9.0/Main.hs b/ghc-lib-gen/ghc-lib-parser/ghc-9.0/Main.hs index 5f0aea9e..ca6597cf 100644 --- a/ghc-lib-gen/ghc-lib-parser/ghc-9.0/Main.hs +++ b/ghc-lib-gen/ghc-lib-parser/ghc-9.0/Main.hs @@ -1,20 +1,20 @@ +import GHC.Data.FastString +import GHC.Data.StringBuffer import GHC.Driver.Session import GHC.Driver.Types +import GHC.Hs +import GHC.Hs.Dump import GHC.Parser -import GHC.Parser.Lexer -import GHC.Parser.Header import GHC.Parser.Annotation -import GHC.Hs +import GHC.Parser.Header +import GHC.Parser.Lexer +import GHC.Platform +import GHC.Settings +import GHC.Settings.Config import GHC.Types.Name.Reader import GHC.Types.SrcLoc -import GHC.Utils.Panic -import GHC.Data.StringBuffer -import GHC.Data.FastString +import GHC.Unit.Module import GHC.Utils.Error -import GHC.Utils.Outputable import GHC.Utils.Fingerprint -import GHC.Settings -import GHC.Settings.Config -import GHC.Platform -import GHC.Unit.Module -import GHC.Hs.Dump +import GHC.Utils.Outputable +import GHC.Utils.Panic diff --git a/ghc-lib-gen/ghc-lib-parser/ghc-9.10/Main.hs b/ghc-lib-gen/ghc-lib-parser/ghc-9.10/Main.hs index e697e27f..2f974888 100644 --- a/ghc-lib-gen/ghc-lib-parser/ghc-9.10/Main.hs +++ b/ghc-lib-gen/ghc-lib-parser/ghc-9.10/Main.hs @@ -1,29 +1,29 @@ +import GHC.Data.FastString +import GHC.Data.StringBuffer +import GHC.Driver.Config import GHC.Driver.Config.Diagnostic -import GHC.Utils.Logger +import GHC.Driver.Config.Parser import GHC.Driver.Errors import GHC.Driver.Errors.Types -import GHC.Types.Error -import GHC.Driver.Config.Parser import GHC.Driver.Ppr -import GHC.Driver.Config -import GHC.Hs -import GHC.Settings.Config import GHC.Driver.Session -import GHC.Data.StringBuffer -import GHC.Utils.Fingerprint +import GHC.Hs +import GHC.Hs.Dump +import GHC.Parser +import GHC.Parser.Annotation +import GHC.Parser.Errors.Ppr +import GHC.Parser.Header import GHC.Parser.Lexer +import GHC.Platform +import GHC.Settings +import GHC.Settings.Config +import GHC.Types.Error import GHC.Types.Name.Reader +import GHC.Types.SourceError +import GHC.Types.SrcLoc +import GHC.Unit.Types import GHC.Utils.Error -import GHC.Parser -import GHC.Data.FastString +import GHC.Utils.Fingerprint +import GHC.Utils.Logger import GHC.Utils.Outputable -import GHC.Parser.Errors.Ppr -import GHC.Types.SrcLoc import GHC.Utils.Panic -import GHC.Types.SourceError -import GHC.Settings -import GHC.Platform -import GHC.Parser.Header -import GHC.Parser.Annotation -import GHC.Hs.Dump -import GHC.Unit.Types diff --git a/ghc-lib-gen/ghc-lib-parser/ghc-9.12/Main.hs b/ghc-lib-gen/ghc-lib-parser/ghc-9.12/Main.hs index e697e27f..2f974888 100644 --- a/ghc-lib-gen/ghc-lib-parser/ghc-9.12/Main.hs +++ b/ghc-lib-gen/ghc-lib-parser/ghc-9.12/Main.hs @@ -1,29 +1,29 @@ +import GHC.Data.FastString +import GHC.Data.StringBuffer +import GHC.Driver.Config import GHC.Driver.Config.Diagnostic -import GHC.Utils.Logger +import GHC.Driver.Config.Parser import GHC.Driver.Errors import GHC.Driver.Errors.Types -import GHC.Types.Error -import GHC.Driver.Config.Parser import GHC.Driver.Ppr -import GHC.Driver.Config -import GHC.Hs -import GHC.Settings.Config import GHC.Driver.Session -import GHC.Data.StringBuffer -import GHC.Utils.Fingerprint +import GHC.Hs +import GHC.Hs.Dump +import GHC.Parser +import GHC.Parser.Annotation +import GHC.Parser.Errors.Ppr +import GHC.Parser.Header import GHC.Parser.Lexer +import GHC.Platform +import GHC.Settings +import GHC.Settings.Config +import GHC.Types.Error import GHC.Types.Name.Reader +import GHC.Types.SourceError +import GHC.Types.SrcLoc +import GHC.Unit.Types import GHC.Utils.Error -import GHC.Parser -import GHC.Data.FastString +import GHC.Utils.Fingerprint +import GHC.Utils.Logger import GHC.Utils.Outputable -import GHC.Parser.Errors.Ppr -import GHC.Types.SrcLoc import GHC.Utils.Panic -import GHC.Types.SourceError -import GHC.Settings -import GHC.Platform -import GHC.Parser.Header -import GHC.Parser.Annotation -import GHC.Hs.Dump -import GHC.Unit.Types diff --git a/ghc-lib-gen/ghc-lib-parser/ghc-9.2/Main.hs b/ghc-lib-gen/ghc-lib-parser/ghc-9.2/Main.hs index e70e242c..ca06ebcc 100644 --- a/ghc-lib-gen/ghc-lib-parser/ghc-9.2/Main.hs +++ b/ghc-lib-gen/ghc-lib-parser/ghc-9.2/Main.hs @@ -1,23 +1,23 @@ -import GHC.Driver.Ppr +import GHC.Data.FastString +import GHC.Data.StringBuffer import GHC.Driver.Config +import GHC.Driver.Ppr import GHC.Driver.Session +import GHC.Hs +import GHC.Hs.Dump import GHC.Parser -import GHC.Parser.Lexer +import GHC.Parser.Annotation import GHC.Parser.Errors.Ppr import GHC.Parser.Header -import GHC.Parser.Annotation -import GHC.Hs +import GHC.Parser.Lexer +import GHC.Platform import GHC.Settings import GHC.Settings.Config -import GHC.Data.StringBuffer -import GHC.Data.FastString import GHC.Types.Name.Reader import GHC.Types.SourceError import GHC.Types.SrcLoc -import GHC.Utils.Panic +import GHC.Unit.Types +import GHC.Utils.Error import GHC.Utils.Fingerprint import GHC.Utils.Outputable -import GHC.Utils.Error -import GHC.Platform -import GHC.Hs.Dump -import GHC.Unit.Types +import GHC.Utils.Panic diff --git a/ghc-lib-gen/ghc-lib-parser/ghc-9.4/Main.hs b/ghc-lib-gen/ghc-lib-parser/ghc-9.4/Main.hs index c213b745..2f974888 100644 --- a/ghc-lib-gen/ghc-lib-parser/ghc-9.4/Main.hs +++ b/ghc-lib-gen/ghc-lib-parser/ghc-9.4/Main.hs @@ -1,3 +1,5 @@ +import GHC.Data.FastString +import GHC.Data.StringBuffer import GHC.Driver.Config import GHC.Driver.Config.Diagnostic import GHC.Driver.Config.Parser @@ -5,25 +7,23 @@ import GHC.Driver.Errors import GHC.Driver.Errors.Types import GHC.Driver.Ppr import GHC.Driver.Session +import GHC.Hs +import GHC.Hs.Dump import GHC.Parser -import GHC.Parser.Lexer +import GHC.Parser.Annotation import GHC.Parser.Errors.Ppr import GHC.Parser.Header -import GHC.Parser.Annotation -import GHC.Utils.Logger -import GHC.Utils.Outputable -import GHC.Utils.Error -import GHC.Utils.Fingerprint -import GHC.Hs -import GHC.Types.SrcLoc +import GHC.Parser.Lexer +import GHC.Platform +import GHC.Settings +import GHC.Settings.Config import GHC.Types.Error import GHC.Types.Name.Reader import GHC.Types.SourceError -import GHC.Utils.Panic -import GHC.Settings -import GHC.Settings.Config -import GHC.Data.StringBuffer -import GHC.Data.FastString -import GHC.Platform -import GHC.Hs.Dump +import GHC.Types.SrcLoc import GHC.Unit.Types +import GHC.Utils.Error +import GHC.Utils.Fingerprint +import GHC.Utils.Logger +import GHC.Utils.Outputable +import GHC.Utils.Panic diff --git a/ghc-lib-gen/ghc-lib-parser/ghc-9.6/Main.hs b/ghc-lib-gen/ghc-lib-parser/ghc-9.6/Main.hs index 95bfd0a2..2f974888 100644 --- a/ghc-lib-gen/ghc-lib-parser/ghc-9.6/Main.hs +++ b/ghc-lib-gen/ghc-lib-parser/ghc-9.6/Main.hs @@ -1,3 +1,5 @@ +import GHC.Data.FastString +import GHC.Data.StringBuffer import GHC.Driver.Config import GHC.Driver.Config.Diagnostic import GHC.Driver.Config.Parser @@ -5,25 +7,23 @@ import GHC.Driver.Errors import GHC.Driver.Errors.Types import GHC.Driver.Ppr import GHC.Driver.Session +import GHC.Hs +import GHC.Hs.Dump import GHC.Parser -import GHC.Parser.Lexer +import GHC.Parser.Annotation import GHC.Parser.Errors.Ppr import GHC.Parser.Header -import GHC.Parser.Annotation -import GHC.Utils.Logger -import GHC.Utils.Outputable -import GHC.Utils.Error -import GHC.Utils.Fingerprint -import GHC.Hs +import GHC.Parser.Lexer +import GHC.Platform +import GHC.Settings +import GHC.Settings.Config import GHC.Types.Error import GHC.Types.Name.Reader import GHC.Types.SourceError import GHC.Types.SrcLoc -import GHC.Utils.Panic -import GHC.Settings -import GHC.Settings.Config -import GHC.Data.StringBuffer -import GHC.Data.FastString -import GHC.Platform -import GHC.Hs.Dump import GHC.Unit.Types +import GHC.Utils.Error +import GHC.Utils.Fingerprint +import GHC.Utils.Logger +import GHC.Utils.Outputable +import GHC.Utils.Panic diff --git a/ghc-lib-gen/ghc-lib-parser/ghc-9.8/Main.hs b/ghc-lib-gen/ghc-lib-parser/ghc-9.8/Main.hs index e697e27f..2f974888 100644 --- a/ghc-lib-gen/ghc-lib-parser/ghc-9.8/Main.hs +++ b/ghc-lib-gen/ghc-lib-parser/ghc-9.8/Main.hs @@ -1,29 +1,29 @@ +import GHC.Data.FastString +import GHC.Data.StringBuffer +import GHC.Driver.Config import GHC.Driver.Config.Diagnostic -import GHC.Utils.Logger +import GHC.Driver.Config.Parser import GHC.Driver.Errors import GHC.Driver.Errors.Types -import GHC.Types.Error -import GHC.Driver.Config.Parser import GHC.Driver.Ppr -import GHC.Driver.Config -import GHC.Hs -import GHC.Settings.Config import GHC.Driver.Session -import GHC.Data.StringBuffer -import GHC.Utils.Fingerprint +import GHC.Hs +import GHC.Hs.Dump +import GHC.Parser +import GHC.Parser.Annotation +import GHC.Parser.Errors.Ppr +import GHC.Parser.Header import GHC.Parser.Lexer +import GHC.Platform +import GHC.Settings +import GHC.Settings.Config +import GHC.Types.Error import GHC.Types.Name.Reader +import GHC.Types.SourceError +import GHC.Types.SrcLoc +import GHC.Unit.Types import GHC.Utils.Error -import GHC.Parser -import GHC.Data.FastString +import GHC.Utils.Fingerprint +import GHC.Utils.Logger import GHC.Utils.Outputable -import GHC.Parser.Errors.Ppr -import GHC.Types.SrcLoc import GHC.Utils.Panic -import GHC.Types.SourceError -import GHC.Settings -import GHC.Platform -import GHC.Parser.Header -import GHC.Parser.Annotation -import GHC.Hs.Dump -import GHC.Unit.Types diff --git a/ghc-lib-gen/src/Ghclibgen.hs b/ghc-lib-gen/src/Ghclibgen.hs index 7ddd8982..b1cddf34 100644 --- a/ghc-lib-gen/src/Ghclibgen.hs +++ b/ghc-lib-gen/src/Ghclibgen.hs @@ -56,6 +56,7 @@ import Data.List.Extra hiding (find) import Data.Char import Data.Maybe import Data.Ord +import qualified Data.Map as Map import qualified Data.Set as Set import qualified Data.List.NonEmpty @@ -283,84 +284,64 @@ ghcLibExtraFiles ghcFlavor = placeholderModulesDir :: FilePath placeholderModulesDir = "placeholder_modules" +getGhcInfo :: IO [(String, String)] +getGhcInfo = do + xs <- systemOutput_ "ghc --info" + case reads xs of + [(info, _)] -> return info + _ -> error "failed to read output from `ghc info --info`" + ghcNumericVersion :: IO String ghcNumericVersion = do - systemOutput_ "bash -c \"echo -n $(ghc --numeric-version)\"" + ghcInfo <- getGhcInfo + let ghcInfoMap = Map.fromList ghcInfo + pure $ fromJust $ Map.lookup "Project version" ghcInfoMap cabalPackageDb :: String -> IO String cabalPackageDb ghcNumericVersion = do - cabalStoreDir <- - if not isWindows then - systemOutput_ "bash -c \"cabal path --store-dir\"" - else - systemOutput_ "bash -c \"echo -n $(cygpath -u $(cabal path --store-dir))\"" - ghcDir <- systemOutput_ $ "bash -c \"echo -n $(ls " ++ cabalStoreDir ++ " | grep " ++ ghcNumericVersion ++ ")\"" + cabalStoreDir <- replace "\\" "\\\\" <$> systemOutput_ "cabal path --store-dir" + ghcInfo <- getGhcInfo + let ghcInfoMap = Map.fromList ghcInfo + let ghcDir = + case Map.lookup "Project Unit Id" ghcInfoMap of + Just projectUnitId -> projectUnitId -- e.g. ghc-9.10.1-2e29 + Nothing -> "ghc-" ++ ghcNumericVersion pure $ cabalStoreDir ++ "/" ++ ghcDir ++ "/package.db" -ghcPackagePath :: String -> String -> IO String -ghcPackagePath cabalPackageDb ghcNumericVersion = - pure $ "GHC_PACKAGE_PATH=" ++ cabalPackageDb ++ - (if not isWindows then - ":" - else - ":/c/ghcup/ghc/" ++ ghcNumericVersion ++ "/lib/package.conf.d" - ) - -semaphoreCompatBootExists :: IO Bool -semaphoreCompatBootExists = - (== ExitSuccess) . fst <$> systemOutput "bash -c \"ghc-pkg list | grep semaphore-compat\"" - setupModuleDepsPlaceholders :: GhcFlavor -> IO () setupModuleDepsPlaceholders _ = do - forM_ [ - "compiler/" - , "libraries/ghc-heap/" - , "libraries/ghc-internal/" - , "libraries/ghci/" - ] $ \path -> - whenM (doesDirectoryExist path) $ - genPlaceholderModules path - forM_ [ - "compiler/" - , "libraries/ghc-internal/src/" - ] $ \path -> - whenM (doesDirectoryExist path) $ do - files <- filter ((`elem` [".hs-boot"]) . takeExtension) <$> listFilesRecursive path - forM_ files $ \file -> do - let p = fromJust (stripPrefix path file) - new_p = placeholderModulesDir p - dir = System.FilePath.takeDirectory new_p - createDirectoryIfMissing True dir - copyFile file new_p - -calcModuleDeps :: [FilePath] -> [FilePath] -> [FilePath] -> GhcFlavor -> String -> Bool -> String -> String -calcModuleDeps includeDirs _hsSrcDirs hsSrcIncludes ghcFlavor ghcPackagePath semaphoreCompatBootExists ghcMakeModeOutputFile = do - let series = ghcSeries ghcFlavor - rootModulePath = placeholderModulesDir "Main.hs" - cmd = unwords $ - [ "ghc" ] ++ - [ "-optP -DGHCI" | series < GHC_8_10 ] ++ - [ "-optP -DSTAGE=2" | series < GHC_8_10 ] ++ - [ "-optP -DGHC_IN_GHCI" | series < GHC_9_2 ] ++ - [ "-dep-suffix ''" - , "-dep-makefile " ++ ghcMakeModeOutputFile - , "-M" - ] ++ - includeDirs ++ - [ "-ignore-package ghc" - , "-ignore-package ghci" - , "-package base" - ] ++ - [ "-package exceptions" | series == GHC_9_0 ] ++ - [ "-package semaphore-compat" | series >= GHC_9_8 ] ++ - hsSrcIncludes ++ - [ rootModulePath ] - cmd' = - if series < GHC_9_8 || semaphoreCompatBootExists then - cmd - else - "bash -c \"" ++ ghcPackagePath ++ " " ++ cmd ++ "\"" - in cmd' + forM_ + [ "compiler/", + "libraries/ghc-heap/", + "libraries/ghc-internal/", + "libraries/ghci/" + ] + $ \path -> + whenM (doesDirectoryExist path) $ + genPlaceholderModules path + forM_ + [ "compiler/", + "libraries/ghc-internal/src/" + ] + $ \path -> + whenM (doesDirectoryExist path) $ do + files <- filter ((`elem` [".hs-boot"]) . takeExtension) <$> listFilesRecursive path + forM_ files $ \file -> do + let p = fromJust (stripPrefix path file) + new_p = placeholderModulesDir p + dir = System.FilePath.takeDirectory new_p + createDirectoryIfMissing True dir + copyFile file new_p + +calcModuleDeps :: [FilePath] -> [FilePath] -> [FilePath] -> GhcFlavor -> FilePath -> String -> String +calcModuleDeps includeDirs _hsSrcDirs hsSrcIncludes ghcFlavor cabalPackageDb ghcMakeModeOutputFile = + unwords $ + ["ghc -M -dep-suffix '' -dep-makefile " ++ ghcMakeModeOutputFile] ++ + ["-clear-package-db -global-package-db -user-package-db -package-db " ++ cabalPackageDb] ++ ["-package semaphore-compat" | series >= GHC_9_8] ++ + includeDirs ++ hsSrcIncludes ++ + [placeholderModulesDir "Main.hs"] + where + series = ghcSeries ghcFlavor readGhcMakeModeOutputFile :: FilePath -> [FilePath] -> IO [String] readGhcMakeModeOutputFile file hsSrcDirs = do @@ -368,29 +349,24 @@ readGhcMakeModeOutputFile file hsSrcDirs = do -- The idea here is harvest from lines like -- 'compiler/prelude/PrelRules.o : compiler/prelude/PrelRules.hs', -- just the module name e.g. in this example, 'PrelRules'. - -- Strip comment lines. + -- Strip comment lines. let depends = filter (not . isPrefixOf "#") (lines buf) -- Restrict to Haskell source file lines. moduleLines = filter (isSuffixOf ".hs") depends -- Strip each line up-to and including ':'. modulePaths = map (trim . snd) (mapMaybe (stripInfix ":") moduleLines) -- Remove leading source directories from what's left. - strippedModulePaths = foldl - (\acc p -> map (replace (p ++ "/") "") acc) - modulePaths - hsSrcDirs + strippedModulePaths = + foldl + (\acc p -> map (replace (p ++ "/") "") acc) + modulePaths + hsSrcDirs -- Lastly, manipulate text like 'GHC/Exts/Heap/Constants.hs' -- into 'GHC.Exts.Heap.Constants'. - modules = [ replace "/" "." . dropSuffix ".hs" $ m | m <- strippedModulePaths, m /= "Main.hs" ] + modules = [replace "/" "." . dropSuffix ".hs" $ m | m <- strippedModulePaths, m /= "Main.hs"] return $ nubSort modules -ghcPackagePath' :: IO String -ghcPackagePath' = do - ghcNumericVersion <- ghcNumericVersion - cabalPackageDb <- cabalPackageDb ghcNumericVersion - ghcPackagePath cabalPackageDb ghcNumericVersion - calcParserModules :: GhcFlavor -> IO [String] calcParserModules ghcFlavor = do let rootModulePath = placeholderModulesDir "Main.hs" @@ -398,12 +374,11 @@ calcParserModules ghcFlavor = do mainFile = "../ghc-lib-gen/ghc-lib-parser" show series "Main.hs" copyFile mainFile rootModulePath lib <- mapM readCabalFile (cabalFileLibraries ghcFlavor) - ghcPackagePath <- ghcPackagePath' - semaphoreCompatBootExists <- semaphoreCompatBootExists - let includeDirs = map ("-I" ++ ) (ghcLibParserIncludeDirs ghcFlavor) + cabalPackageDb <- cabalPackageDb =<< ghcNumericVersion + let includeDirs = map ("-I" ++) (ghcLibParserIncludeDirs ghcFlavor) hsSrcDirs = placeholderModulesDir : ghcLibParserHsSrcDirs True ghcFlavor lib - hsSrcIncludes = map ("-i" ++ ) hsSrcDirs - cmd' = calcModuleDeps includeDirs hsSrcDirs hsSrcIncludes ghcFlavor ghcPackagePath semaphoreCompatBootExists ".parser-depends" + hsSrcIncludes = map ("-i" ++) hsSrcDirs + cmd' = calcModuleDeps includeDirs hsSrcDirs hsSrcIncludes ghcFlavor cabalPackageDb ".parser-depends" putStrLn "# Generating 'ghc/.parser-depends'..." putStrLn $ "\n\n# Running: " ++ cmd' system_ cmd' @@ -416,12 +391,11 @@ calcLibModules ghcFlavor = do mainFile = "../ghc-lib-gen/ghc-lib" show series "Main.hs" copyFile mainFile rootModulePath lib <- mapM readCabalFile (cabalFileLibraries ghcFlavor) - ghcPackagePath <- ghcPackagePath' - semaphoreCompatBootExists <- semaphoreCompatBootExists - let includeDirs = map ("-I" ++ ) (ghcLibIncludeDirs ghcFlavor) + cabalPackageDb <- cabalPackageDb =<< ghcNumericVersion + let includeDirs = map ("-I" ++) (ghcLibIncludeDirs ghcFlavor) hsSrcDirs = placeholderModulesDir : ghcLibHsSrcDirs True ghcFlavor lib - hsSrcIncludes = map ("-i" ++ ) hsSrcDirs - cmd' = calcModuleDeps includeDirs hsSrcDirs hsSrcIncludes ghcFlavor ghcPackagePath semaphoreCompatBootExists ".lib-depends" + hsSrcIncludes = map ("-i" ++) hsSrcDirs + cmd' = calcModuleDeps includeDirs hsSrcDirs hsSrcIncludes ghcFlavor cabalPackageDb ".lib-depends" putStrLn "# Generating 'ghc/.lib-depends'..." putStrLn $ "\n\n# Running: " ++ cmd' system_ cmd' @@ -1379,14 +1353,12 @@ generateCppOpts :: GhcFlavor -> [String] -> String generateCppOpts ghcFlavor customCppOpts = unwords $ [ ghcStageDef ghcFlavor - , ghciDef ghcFlavor , ghcInGhciDef ghcFlavor , bootstrapTh ghcFlavor ] ++ customCppOpts where - ghciDef, ghcInGhciDef, ghcStageDef :: GhcFlavor -> String - ghciDef ghcFlavor = if ghcSeries ghcFlavor > GHC_8_10 then "" else "-DGHCI" + ghcInGhciDef, ghcStageDef :: GhcFlavor -> String ghcInGhciDef = \case f | ghcSeries f >= GHC_9_2 -> ""; _ -> "-DGHC_IN_GHCI" ghcStageDef = \case f | ghcSeries f >= GHC_8_10 -> ""; _ -> "-DSTAGE=2" bootstrapTh = \case f | ghcSeries f <= GHC_9_10 -> ""; _ -> "-DBOOTSTRAP_TH" From 37813bb0b86c04675618c8293c15d985a4c33f01 Mon Sep 17 00:00:00 2001 From: Shayne Fletcher Date: Thu, 25 Jul 2024 13:10:00 -0400 Subject: [PATCH 2/2] Update ghc-lib-gen.cabal Co-authored-by: Samuel Williams --- ghc-lib-gen.cabal | 1 - 1 file changed, 1 deletion(-) diff --git a/ghc-lib-gen.cabal b/ghc-lib-gen.cabal index 5640b96d..590b7ac5 100644 --- a/ghc-lib-gen.cabal +++ b/ghc-lib-gen.cabal @@ -20,7 +20,6 @@ flag semaphore-compat common base default-language: Haskell2010 - ghc-options: ghc-options: -Wall -Wincomplete-record-updates -Wredundant-constraints -Widentities -Wunused-imports -Wno-name-shadowing