Skip to content

Commit d47f87c

Browse files
handle alex == 3.5.2.0, more ghc-9.8.4 fixes and ghc-9.12.1 as a build compiler (#577)
* alex < 3.5.2.0 * ghc-9.8.4 fixes * exclude hs-src-dirs * add ghc-9.12.1 to CI * unblock alex-3.5.2.0 * fix warning
1 parent 4aa72b9 commit d47f87c

File tree

6 files changed

+26
-27
lines changed

6 files changed

+26
-27
lines changed

.github/workflows/ghc-lib-ghc-HEAD-ghc-9.10.1.yml renamed to .github/workflows/ghc-lib-ghc-HEAD-ghc-9.12.1.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- uses: haskell-actions/setup@v2
1616
id: setup-haskell
1717
with:
18-
ghc-version: 9.10.1
18+
ghc-version: 9.12.1
1919
cabal-version: 'latest'
2020
- name: Install build tools (macOS)
2121
run: brew install automake

.github/workflows/ghc-lib-ghc-master-ghc-9.10.1.yml renamed to .github/workflows/ghc-lib-ghc-master-ghc-9.12.1.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: ghc-lib-ghc-master-ghc-9.10.1
1+
name: ghc-lib-ghc-master-ghc-9.12.1
22
on:
33
push:
44
pull_request:
@@ -15,7 +15,7 @@ jobs:
1515
- uses: haskell-actions/setup@v2
1616
id: setup-haskell
1717
with:
18-
ghc-version: 9.10.1
18+
ghc-version: 9.12.1
1919
cabal-version: 'latest'
2020
- name: Install build tools (macOS)
2121
run: brew install automake

CI.hs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ data DaFlavor = DaFlavor
100100

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

105105
ghcFlavorOpt :: GhcFlavor -> String
106106
ghcFlavorOpt = \case
@@ -358,19 +358,13 @@ buildDists ghcFlavor noGhcCheckout noBuilds versionSuffix = do
358358
pkg_ghclib_parser = "ghc-lib-parser-" ++ version
359359
ghcFlavorArg = ghcFlavorOpt ghcFlavor
360360

361-
#if __GLASGOW_HASKELL__ < 912
362-
let extraCabalFlags = ""
363-
#else
364-
let extraCabalFlags = "--allow-newer=\"hashable:base,unordered-containers:template-haskell\" "
365-
#endif
366-
367-
system_ $ "cabal build " ++ extraCabalFlags ++ "exe:ghc-lib-gen"
368-
system_ $ "cabal run " ++ extraCabalFlags ++ "exe:ghc-lib-gen -- ghc ../patches --ghc-lib-parser " ++ ghcFlavorArg ++ " " ++ cppOpts ghcFlavor
361+
system_ $ "cabal build " ++ "exe:ghc-lib-gen"
362+
system_ $ "cabal run " ++ "exe:ghc-lib-gen -- ghc ../patches --ghc-lib-parser " ++ ghcFlavorArg ++ " " ++ cppOpts ghcFlavor
369363
patchVersion version "ghc/ghc-lib-parser.cabal"
370364
mkTarball pkg_ghclib_parser
371365
renameDirectory pkg_ghclib_parser "ghc-lib-parser"
372366
removeFile "ghc/ghc-lib-parser.cabal"
373-
system_ $ "cabal run " ++ extraCabalFlags ++ "exe:ghc-lib-gen -- ghc ../patches --ghc-lib " ++ ghcFlavorArg ++ " " ++ cppOpts ghcFlavor ++ " --skip-init"
367+
system_ $ "cabal run " ++ "exe:ghc-lib-gen -- ghc ../patches --ghc-lib " ++ ghcFlavorArg ++ " " ++ cppOpts ghcFlavor ++ " --skip-init"
374368
patchVersion version "ghc/ghc-lib.cabal"
375369
patchConstraints version "ghc/ghc-lib.cabal"
376370
mkTarball pkg_ghclib

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# 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/)
1+
# 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/)
22

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

66
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?

ghc-lib-gen/src/Ghclibgen.hs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ module Ghclibgen
2727
applyPatchStage,
2828
applyPatchNoMonoLocalBinds,
2929
applyPatchCmmParseNoImplicitPrelude,
30+
applyPatchCompilerGHCParserLexer,
3031
applyPatchCompilerGHCUnitTypes,
3132
applyPatchHadrianCabalProject,
3233
applyPatchGhcInternalEventWindowsHsc,
@@ -141,7 +142,7 @@ ghcLibHsSrcDirs forDepends ghcFlavor lib =
141142
GHC_9_4 -> ["ghc-lib/stage0/libraries/ghc-boot/build", "libraries/template-haskell", "libraries/ghc-boot-th", "libraries/ghc-heap", "libraries/ghci"]
142143
GHC_9_6 -> ["libraries/template-haskell", "libraries/ghc-boot-th", "libraries/ghc-boot", "libraries/ghc-heap", "libraries/ghci"]
143144
GHC_9_8 -> ["libraries/template-haskell", "libraries/ghc-boot-th", "libraries/ghc-boot", "libraries/ghc-heap", "libraries/ghc-platform/src", "libraries/ghc-platform"]
144-
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"]
145+
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"]
145146
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"]
146147
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"]
147148
in sortDiffListByLength all $ Set.fromList [dir | not forDepends, dir <- exclusions]
@@ -320,6 +321,9 @@ calcModuleDeps includeDirs _hsSrcDirs hsSrcIncludes ghcFlavor cabalPackageDb ghc
320321
[ ["ghc -M -dep-suffix '' -dep-makefile " ++ ghcMakeModeOutputFile],
321322
["-clear-package-db -global-package-db -user-package-db -package-db " ++ cabalPackageDb],
322323
["-package semaphore-compat" | series >= GHC_9_8],
324+
#if __GLASGOW_HASKELL__ == 908 && __GLASGOW_HASKELL_PATCHLEVEL1__ == 4
325+
["-hide-package os-string"], -- avoid System.OsString ambiguity with filepath-1.4.301.0
326+
#endif
323327
["-fno-safe-haskell" | series >= GHC_9_0], -- avoid warning: [GHC-98887] -XGeneralizedNewtypeDeriving is not allowed in Safe Haskell; ignoring -XGeneralizedNewtypeDeriving
324328
["-DBIGNUM_NATIVE" | series > GHC_9_12],
325329
includeDirs,
@@ -938,6 +942,7 @@ mangleCSymbols ghcFlavor = do
938942
in writeFile file
939943
. prefixSymbol genSym
940944
. prefixSymbol initGenSym
945+
. replace "#if !MIN_VERSION_GLASGOW_HASKELL(9,9,0,0)" "#if !MIN_VERSION_GLASGOW_HASKELL(9,8,4,0)"
941946
=<< readFile' file
942947
when (ghcFlavor == Ghc984) $
943948
let file = "compiler/cbits/genSym.c"
@@ -1070,6 +1075,13 @@ applyPatchHadrianCabalProject _ = do
10701075
cabalProject = "hadrian" </> "cabal.project"
10711076
cabalProjectFreeze = cabalProject ++ ".freeze"
10721077

1078+
applyPatchCompilerGHCParserLexer :: GhcFlavor -> IO ()
1079+
applyPatchCompilerGHCParserLexer ghcFlavor = do
1080+
when (ghcSeries ghcFlavor >= GHC_9_12) $ do
1081+
writeFile "compiler/GHC/Parser/Lexer.x"
1082+
. replace "{-# INLINE alexScanUser #-}" ""
1083+
=<< readFile' "compiler/GHC/Parser/Lexer.x"
1084+
10731085
applyPatchCompilerGHCUnitTypes :: GhcFlavor -> IO ()
10741086
applyPatchCompilerGHCUnitTypes ghcFlavor = do
10751087
when (ghcFlavor == Ghc9101) $ do
@@ -1314,7 +1326,7 @@ libBinParserLibModules ghcFlavor = do
13141326

13151327
happyBounds :: GhcFlavor -> String
13161328
happyBounds ghcFlavor
1317-
| series < GHC_9_8 = "== 1.20.*"
1329+
| series < GHC_9_8 = "< 1.21"
13181330
| otherwise = "== 1.20.* || == 2.0.2 || >= 2.1.2 && < 2.2" -- c.f. m4/fptools_happy.m4
13191331
where
13201332
series = ghcSeries ghcFlavor
@@ -1563,20 +1575,12 @@ generatePrerequisites ghcFlavor = do
15631575
=<< readFile' "./mk/get-win32-tarballs.sh"
15641576
)
15651577

1566-
-- When there is a new GHC release it takes time for package bounds
1567-
-- to get updated.
1568-
#if __GLASGOW_HASKELL__ == 912
1569-
let hadrianExtraCabalFlags = "--allow-newer "
1570-
#else
1571-
let hadrianExtraCabalFlags = ""
1572-
#endif
1573-
15741578
system_ "bash -c ./boot"
15751579
system_ "bash -c \"./configure --enable-tarballs-autodownload\""
15761580
withCurrentDirectory "hadrian" $ do
1577-
system_ $ "cabal build " ++ hadrianExtraCabalFlags ++ "exe:hadrian --ghc-options=-j"
1581+
system_ "cabal build exe:hadrian --ghc-options=-j"
15781582
system_ . unwords . join $
1579-
[ [ "cabal run " ++ hadrianExtraCabalFlags ++ "exe:hadrian --",
1583+
[ [ "cabal run exe:hadrian --",
15801584
"--directory=..",
15811585
"--build-root=ghc-lib"
15821586
],

ghc-lib-gen/src/Main.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ ghclibgen (GhclibgenOpts root _patches target ghcFlavor skipInit cppOpts _resolv
5353
applyPatchGhcPrim ghcFlavor
5454
applyPatchDisableCompileTimeOptimizations ghcFlavor
5555
-- These lines must come before 'generatePrerequisites':
56+
applyPatchCompilerGHCParserLexer ghcFlavor
5657
applyPatchAclocal ghcFlavor -- Do before ./boot && ./configure
5758
applyPatchFptoolsAlex ghcFlavor
5859
applyPatchFpFindCxxStdLib ghcFlavor

0 commit comments

Comments
 (0)