Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle alex == 3.5.2.0 and ghc-9.8.4 fixes #286

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: haskell-actions/setup@v2
id: setup-haskell
with:
ghc-version: 9.10.1
ghc-version: 9.12.1
cabal-version: 'latest'
- name: Install build tools (macOS)
run: brew install automake
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: ghc-lib-ghc-master-ghc-9.10.1
name: ghc-lib-ghc-master-ghc-9.12.1
on:
push:
pull_request:
Expand All @@ -15,7 +15,7 @@ jobs:
- uses: haskell-actions/setup@v2
id: setup-haskell
with:
ghc-version: 9.10.1
ghc-version: 9.12.1
cabal-version: 'latest'
- name: Install build tools (macOS)
run: brew install automake
Expand Down
14 changes: 4 additions & 10 deletions CI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ data DaFlavor = DaFlavor

-- Last tested gitlab.haskell.org/ghc/ghc.git at
current :: String
current = "8b266671bcfe9ef5a25f0a78ea7dcca68b78dc32" -- 2024-12-19
current = "278a53ee698d961d97afb60be9db2d8bf60b4074" -- 2024-12-30

ghcFlavorOpt :: GhcFlavor -> String
ghcFlavorOpt = \case
Expand Down Expand Up @@ -358,19 +358,13 @@ buildDists ghcFlavor noGhcCheckout noBuilds versionSuffix = do
pkg_ghclib_parser = "ghc-lib-parser-" ++ version
ghcFlavorArg = ghcFlavorOpt ghcFlavor

#if __GLASGOW_HASKELL__ < 912
let extraCabalFlags = ""
#else
let extraCabalFlags = "--allow-newer=\"hashable:base,unordered-containers:template-haskell\" "
#endif

system_ $ "cabal build " ++ extraCabalFlags ++ "exe:ghc-lib-gen"
system_ $ "cabal run " ++ extraCabalFlags ++ "exe:ghc-lib-gen -- ghc ../patches --ghc-lib-parser " ++ ghcFlavorArg ++ " " ++ cppOpts ghcFlavor
system_ $ "cabal build " ++ "exe:ghc-lib-gen"
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 " ++ extraCabalFlags ++ "exe:ghc-lib-gen -- ghc ../patches --ghc-lib " ++ ghcFlavorArg ++ " " ++ cppOpts ghcFlavor ++ " --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
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ghc-lib [![Hackage version](https://img.shields.io/hackage/v/ghc-lib.svg?label=Hackage)](https://hackage.haskell.org/package/ghc-lib) [![Stackage version](https://www.stackage.org/package/ghc-lib/badge/nightly?label=Stackage)](https://www.stackage.org/package/ghc-lib) [![Build](https://github.com/digital-asset/ghc-lib/actions/workflows/ghc-lib-ghc-HEAD-ghc-9.10.1.yml/badge.svg)](https://github.com/digital-asset/ghc-lib/actions/)
# ghc-lib [![Hackage version](https://img.shields.io/hackage/v/ghc-lib.svg?label=Hackage)](https://hackage.haskell.org/package/ghc-lib) [![Stackage version](https://www.stackage.org/package/ghc-lib/badge/nightly?label=Stackage)](https://www.stackage.org/package/ghc-lib) [![Build](https://github.com/digital-asset/ghc-lib/actions/workflows/ghc-lib-ghc-HEAD-ghc-9.12.1.yml/badge.svg)](https://github.com/digital-asset/ghc-lib/actions/)

Copyright © 2019-2023, Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
Copyright © 2019-2025, Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
SPDX-License-Identifier: (Apache-2.0 OR BSD-3-Clause)

The [GHC API](https://hackage.haskell.org/package/ghc) allows you to use the [GHC compiler](https://www.haskell.org/ghc/) as a library, so you can parse, analyze and compile Haskell code. The GHC API comes preinstalled with GHC, and is tied to that GHC version - if you are using GHC 8.6.3, you get version 8.6.3 of the API, and can't change it. The `ghc-lib` project solves that problem, letting you mix and match versions of the GHC compiler and GHC API. Why might you want that?
Expand Down
28 changes: 16 additions & 12 deletions ghc-lib-gen/src/Ghclibgen.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module Ghclibgen
applyPatchStage,
applyPatchNoMonoLocalBinds,
applyPatchCmmParseNoImplicitPrelude,
applyPatchCompilerGHCParserLexer,
applyPatchCompilerGHCUnitTypes,
applyPatchHadrianCabalProject,
applyPatchGhcInternalEventWindowsHsc,
Expand Down Expand Up @@ -141,7 +142,7 @@ ghcLibHsSrcDirs forDepends ghcFlavor lib =
GHC_9_4 -> ["ghc-lib/stage0/libraries/ghc-boot/build", "libraries/template-haskell", "libraries/ghc-boot-th", "libraries/ghc-heap", "libraries/ghci"]
GHC_9_6 -> ["libraries/template-haskell", "libraries/ghc-boot-th", "libraries/ghc-boot", "libraries/ghc-heap", "libraries/ghci"]
GHC_9_8 -> ["libraries/template-haskell", "libraries/ghc-boot-th", "libraries/ghc-boot", "libraries/ghc-heap", "libraries/ghc-platform/src", "libraries/ghc-platform"]
GHC_9_10 -> ["libraries/template-haskell", "libraries/ghc-boot-th", "libraries/ghc-boot", "libraries/ghc-heap", "libraries/ghc-platform/src", "libraries/ghc-platform", "libraries/ghci"]
GHC_9_10 -> ["libraries/template-haskell", "libraries/ghc-boot-th", "libraries/ghc-boot-th-internal", "libraries/ghc-boot", "libraries/ghc-heap", "libraries/ghc-platform/src", "libraries/ghc-platform", "libraries/ghci"]
GHC_9_12 -> ["libraries/template-haskell", "libraries/ghc-boot-th", "libraries/ghc-boot-th-internal", "libraries/ghc-boot", "libraries/ghc-heap", "libraries/ghc-platform/src", "libraries/ghc-platform", "libraries/ghci", "libraries/ghc-internal/src"]
GHC_9_14 -> ["libraries/template-haskell", "libraries/ghc-boot-th", "libraries/ghc-boot-th-internal", "libraries/ghc-boot", "", "libraries/ghc-heap", "libraries/ghc-platform/src", "libraries/ghc-platform", "libraries/ghci", "libraries/ghc-internal/src"]
in sortDiffListByLength all $ Set.fromList [dir | not forDepends, dir <- exclusions]
Expand Down Expand Up @@ -320,6 +321,9 @@ calcModuleDeps includeDirs _hsSrcDirs hsSrcIncludes ghcFlavor cabalPackageDb ghc
[ ["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],
#if __GLASGOW_HASKELL__ == 908 && __GLASGOW_HASKELL_PATCHLEVEL1__ == 4
["-hide-package os-string"], -- avoid System.OsString ambiguity with filepath-1.4.301.0
#endif
["-fno-safe-haskell" | series >= GHC_9_0], -- avoid warning: [GHC-98887] -XGeneralizedNewtypeDeriving is not allowed in Safe Haskell; ignoring -XGeneralizedNewtypeDeriving
["-DBIGNUM_NATIVE" | series > GHC_9_12],
includeDirs,
Expand Down Expand Up @@ -938,6 +942,7 @@ mangleCSymbols ghcFlavor = do
in writeFile file
. prefixSymbol genSym
. prefixSymbol initGenSym
. replace "#if !MIN_VERSION_GLASGOW_HASKELL(9,9,0,0)" "#if !MIN_VERSION_GLASGOW_HASKELL(9,8,4,0)"
=<< readFile' file
when (ghcFlavor == Ghc984) $
let file = "compiler/cbits/genSym.c"
Expand Down Expand Up @@ -1070,6 +1075,13 @@ applyPatchHadrianCabalProject _ = do
cabalProject = "hadrian" </> "cabal.project"
cabalProjectFreeze = cabalProject ++ ".freeze"

applyPatchCompilerGHCParserLexer :: GhcFlavor -> IO ()
applyPatchCompilerGHCParserLexer ghcFlavor = do
when (ghcSeries ghcFlavor >= GHC_9_12) $ do
writeFile "compiler/GHC/Parser/Lexer.x"
. replace "{-# INLINE alexScanUser #-}" ""
=<< readFile' "compiler/GHC/Parser/Lexer.x"

applyPatchCompilerGHCUnitTypes :: GhcFlavor -> IO ()
applyPatchCompilerGHCUnitTypes ghcFlavor = do
when (ghcFlavor == Ghc9101) $ do
Expand Down Expand Up @@ -1314,7 +1326,7 @@ libBinParserLibModules ghcFlavor = do

happyBounds :: GhcFlavor -> String
happyBounds ghcFlavor
| series < GHC_9_8 = "== 1.20.*"
| series < GHC_9_8 = "< 1.21"
| otherwise = "== 1.20.* || == 2.0.2 || >= 2.1.2 && < 2.2" -- c.f. m4/fptools_happy.m4
where
series = ghcSeries ghcFlavor
Expand Down Expand Up @@ -1563,20 +1575,12 @@ generatePrerequisites ghcFlavor = do
=<< readFile' "./mk/get-win32-tarballs.sh"
)

-- When there is a new GHC release it takes time for package bounds
-- to get updated.
#if __GLASGOW_HASKELL__ == 912
let hadrianExtraCabalFlags = "--allow-newer "
#else
let hadrianExtraCabalFlags = ""
#endif

system_ "bash -c ./boot"
system_ "bash -c \"./configure --enable-tarballs-autodownload\""
withCurrentDirectory "hadrian" $ do
system_ $ "cabal build " ++ hadrianExtraCabalFlags ++ "exe:hadrian --ghc-options=-j"
system_ "cabal build exe:hadrian --ghc-options=-j"
system_ . unwords . join $
[ [ "cabal run " ++ hadrianExtraCabalFlags ++ "exe:hadrian --",
[ [ "cabal run exe:hadrian --",
"--directory=..",
"--build-root=ghc-lib"
],
Expand Down
1 change: 1 addition & 0 deletions ghc-lib-gen/src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ ghclibgen (GhclibgenOpts root _patches target ghcFlavor skipInit cppOpts _resolv
applyPatchGhcPrim ghcFlavor
applyPatchDisableCompileTimeOptimizations ghcFlavor
-- These lines must come before 'generatePrerequisites':
applyPatchCompilerGHCParserLexer ghcFlavor
applyPatchAclocal ghcFlavor -- Do before ./boot && ./configure
applyPatchFptoolsAlex ghcFlavor
applyPatchFpFindCxxStdLib ghcFlavor
Expand Down
Loading