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 5ff5e709..744a0861 100644 --- a/.github/workflows/ghc-lib-da-ghc-8.4.3.yml +++ b/.github/workflows/ghc-lib-da-ghc-8.4.3.yml @@ -4,11 +4,11 @@ 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 @@ -16,20 +16,23 @@ jobs: 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' + 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..a3d14f77 --- /dev/null +++ b/.github/workflows/ghc-lib-ghc-9.0.2-ghc-8.10.7.yml @@ -0,0 +1,38 @@ +name: ghc-lib-ghc-9.0.2-ghc-8.10.7 +on: + push: +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.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..6c0546ed --- /dev/null +++ b/.github/workflows/ghc-lib-ghc-9.4.8-ghc-9.0.2.yml @@ -0,0 +1,38 @@ +name: ghc-lib-ghc-9.4.8-ghc-9.0.2 +on: + push: +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/CI.hs b/CI.hs index 278f48ba..851ef5e9 100755 --- a/CI.hs +++ b/CI.hs @@ -184,6 +184,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" diff --git a/ghc-lib-gen.cabal b/ghc-lib-gen.cabal index 30d7e3f3..62ca8041 100644 --- a/ghc-lib-gen.cabal +++ b/ghc-lib-gen.cabal @@ -1,6 +1,6 @@ cabal-version: 3.4 name: ghc-lib-gen -version: 0.1.0.0 +version: 9.8.2.20240722.0 synopsis: Cabal file generator for GHC as a library description: Generate a cabal file for a subset of GHC for use as a library. homepage:https://github.com/digital-asset/ghc-lib @@ -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/src/Ghclibgen.hs b/ghc-lib-gen/src/Ghclibgen.hs index 025c9ac4..ae6e72ba 100644 --- a/ghc-lib-gen/src/Ghclibgen.hs +++ b/ghc-lib-gen/src/Ghclibgen.hs @@ -297,16 +297,9 @@ ghcNumericVersion = do let ghcInfoMap = Map.fromList ghcInfo pure $ fromJust $ Map.lookup "Project version" ghcInfoMap -cygpath :: FilePath -> IO FilePath -cygpath p = systemOutput_ $ "bash -c 'echo -n $(cygpath -u \"" ++ p ++ "\")'" - cabalPackageDb :: String -> IO String cabalPackageDb ghcNumericVersion = do - cabalStoreDir <- - if not isWindows then - systemOutput_ "cabal path --store-dir" - else - cygpath . replace "\\" "\\\\" =<< systemOutput_ "cabal path --store-dir" + cabalStoreDir <- replace "\\" "\\\\" <$> systemOutput_ "cabal path --store-dir" ghcInfo <- getGhcInfo let ghcInfoMap = Map.fromList ghcInfo let ghcDir = @@ -315,29 +308,6 @@ cabalPackageDb ghcNumericVersion = do Nothing -> "ghc-" ++ ghcNumericVersion pure $ cabalStoreDir ++ "/" ++ ghcDir ++ "/package.db" -ghcPackageDb :: String -> IO String -ghcPackageDb _ghcNumericVersion = do - ghcInfo <- getGhcInfo - let ghcInfoMap = Map.fromList ghcInfo - let packageDb = replace "\\" "\\\\" $ fromJust $ Map.lookup "Global Package DB" ghcInfoMap - if not isWindows then - pure packageDb - else - cygpath packageDb - -ghcPackagePath :: String -> String -> String -> IO String -ghcPackagePath ghcPackageDb cabalPackageDb ghcNumericVersion = - pure $ "GHC_PACKAGE_PATH=" ++ cabalPackageDb ++ - (if not isWindows then - ":" - else - ":" ++ ghcPackageDb - ) - -semaphoreCompatBootExists :: IO Bool -semaphoreCompatBootExists = - (== ExitSuccess) . fst <$> systemOutput "bash -c \"ghc-pkg list | grep semaphore-compat\"" - setupModuleDepsPlaceholders :: GhcFlavor -> IO () setupModuleDepsPlaceholders _ = do forM_ [ @@ -361,34 +331,13 @@ setupModuleDepsPlaceholders _ = do 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' +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 @@ -413,13 +362,6 @@ readGhcMakeModeOutputFile file hsSrcDirs = do return $ nubSort modules -ghcPackagePath' :: IO String -ghcPackagePath' = do - ghcNumericVersion <- ghcNumericVersion - ghcPackageDb <- ghcPackageDb ghcNumericVersion - cabalPackageDb <- cabalPackageDb ghcNumericVersion - ghcPackagePath ghcPackageDb cabalPackageDb ghcNumericVersion - calcParserModules :: GhcFlavor -> IO [String] calcParserModules ghcFlavor = do let rootModulePath = placeholderModulesDir "Main.hs" @@ -427,12 +369,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 + 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" + cmd' = calcModuleDeps includeDirs hsSrcDirs hsSrcIncludes ghcFlavor cabalPackageDb ".parser-depends" putStrLn "# Generating 'ghc/.parser-depends'..." putStrLn $ "\n\n# Running: " ++ cmd' system_ cmd' @@ -445,12 +386,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 + 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" + cmd' = calcModuleDeps includeDirs hsSrcDirs hsSrcIncludes ghcFlavor cabalPackageDb ".lib-depends" putStrLn "# Generating 'ghc/.lib-depends'..." putStrLn $ "\n\n# Running: " ++ cmd' system_ cmd' @@ -1408,14 +1348,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"