Skip to content

Add GHC 9.10.2 support #2983

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .ci/docker/build-and-publish-docker-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ elif [[ "$1" != "" ]]; then
exit 1
fi
UBUNTU_VERSION=jammy-20250126
GHC_VERSIONS=("9.10.1" "9.8.4" "9.6.7" "9.4.8" "9.2.8" "9.0.2" "8.10.7")
GHC_VERSIONS=("9.10.2" "9.8.4" "9.6.7" "9.4.8" "9.2.8" "9.0.2" "8.10.7")
CABAL_VERSIONS=("3.14.1.1" "3.14.1.1" "3.14.1.1" "3.14.1.1" "3.14.1.1" "3.14.1.1" "3.12.1.0")

# We want to use docker buildkit so that our layers are built in parallel. This
Expand Down
2 changes: 1 addition & 1 deletion .ci/gitlab/benchmark.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.benchmark:
image: ghcr.io/clash-lang/clash-ci:$GHC_VERSION-20250402
image: ghcr.io/clash-lang/clash-ci:$GHC_VERSION-20250719
stage: test
timeout: 2 hours
variables:
Expand Down
2 changes: 1 addition & 1 deletion .ci/gitlab/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ default:
timeout: 10 minutes
stage: build
variables:
CLASH_DOCKER_TAG: 20250402
CLASH_DOCKER_TAG: 20250719
CACHE_BUST_TOKEN: 3
# Note that we copy+paste the image name into CACHE_FALLBACK_KEY. If we don't,
# $GHC_VERSION gets inserted at verbatim, instead of resolving to some ghc version.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ jobs:

# Run steps inside the clash CI docker image
container:
image: ghcr.io/clash-lang/clash-ci:${{ matrix.ghc }}-20250402
image: ghcr.io/clash-lang/clash-ci:${{ matrix.ghc }}-20250719

env:
THREADS: 2
Expand Down
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ tests:
CI_PARENT_PIPELINE_SOURCE: $CI_PIPELINE_SOURCE
parallel:
matrix:
- GHC_VERSION: 9.10.1
- GHC_VERSION: 9.10.2
RUN_TESTS: "always"

- GHC_VERSION: 9.8.4
Expand Down
2 changes: 1 addition & 1 deletion cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ write-ghc-environment-files: always
-- index state, to go along with the cabal.project.freeze file. update the index
-- state by running `cabal update` twice and looking at the index state it
-- displays to you (as the second update will be a no-op)
index-state: 2025-02-10T14:25:49Z
index-state: 2025-07-19T09:09:36Z

-- For some reason the `clash-testsuite` executable fails to run without
-- this, as it cannot find the related library...
Expand Down
1 change: 1 addition & 0 deletions changelog/2025-07-19T13_48_58+02_00_add_9102_support
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ADDED: Support for GHC 9.10.2
4 changes: 2 additions & 2 deletions clash-ffi/clash-ffi.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ library
Clash.FFI.VPI.Reg
-- TODO: remove this once https://gitlab.haskell.org/ghc/ghc/-/merge_requests/12264#note_602406
-- is fixed
if impl(ghc < 9.8.3) || impl(ghc == 9.10.1)
if impl(ghc < 9.8.3) || impl(ghc == 9.10.1) || impl(ghc == 9.10.2)
buildable: True
else
buildable: False
Expand Down Expand Up @@ -115,7 +115,7 @@ executable ffi-interface-tests
, tasty-smallcheck
-- TODO: remove this once https://gitlab.haskell.org/ghc/ghc/-/merge_requests/12264#note_602406
-- is fixed
if impl(ghc < 9.8.3) || impl(ghc == 9.10.1)
if impl(ghc < 9.8.3) || impl(ghc == 9.10.1) || impl(ghc == 9.10.2)
buildable: True
else
buildable: False
8 changes: 5 additions & 3 deletions clash-ghc/clash-ghc.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,10 @@ common common-options
library
import: common-options
HS-Source-Dirs: src-ghc, src-bin-common
if impl(ghc >= 9.10.0)
HS-Source-Dirs: src-bin-9.10
if impl(ghc >= 9.10.2)
HS-Source-Dirs: src-bin-9.10.2
elif impl(ghc >= 9.10.0)
HS-Source-Dirs: src-bin-9.10.1
elif impl(ghc >= 9.8.0)
HS-Source-Dirs: src-bin-9.8
elif impl(ghc >= 9.6.0)
Expand Down Expand Up @@ -174,7 +176,7 @@ library
deepseq >= 1.3.0.2 && < 1.6,
time >= 1.4.0.1 && < 1.15,
ghc-boot >= 8.10.0 && < 9.11,
ghc-prim >= 0.3.1.0 && < 0.12,
ghc-prim >= 0.3.1.0 && < 0.13,
ghci >= 8.10.0 && < 9.11,
uniplate >= 1.6.12 && < 1.8,
reflection >= 2.1.2 && < 3.0,
Expand Down
85 changes: 85 additions & 0 deletions clash-ghc/src-bin-9.10.2/Clash/GHCi/Leak.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{-# LANGUAGE RecordWildCards, LambdaCase #-}
module Clash.GHCi.Leak
( LeakIndicators
, getLeakIndicators
, checkLeakIndicators
) where

import Clash.GHCi.Util
import Control.Monad
import Data.Bits
import Foreign.Ptr (ptrToIntPtr, intPtrToPtr)
import GHC
import GHC.Ptr (Ptr (..))
import GHC.Driver.Env
import GHC.Driver.Ppr
import GHC.Utils.Outputable
import GHC.Unit.Module.ModDetails
import GHC.Unit.Home.ModInfo
import GHC.Platform (target32Bit)
import GHC.Linker.Types
import Prelude
import System.Mem
import System.Mem.Weak
import GHC.Types.Unique.DFM
import Control.Exception

-- Checking for space leaks in GHCi. See #15111, and the
-- -fghci-leak-check flag.

data LeakIndicators = LeakIndicators [LeakModIndicators]

data LeakModIndicators = LeakModIndicators
{ leakMod :: Weak HomeModInfo
, leakIface :: Weak ModIface
, leakDetails :: Weak ModDetails
, leakLinkable :: [Maybe (Weak Linkable)]
}

-- | Grab weak references to some of the data structures representing
-- the currently loaded modules.
getLeakIndicators :: HscEnv -> IO LeakIndicators
getLeakIndicators hsc_env =
fmap LeakIndicators $
forM (eltsUDFM (hsc_HPT hsc_env)) $ \hmi@HomeModInfo{..} -> do
leakMod <- mkWeakPtr hmi Nothing
leakIface <- mkWeakPtr hm_iface Nothing
leakDetails <- mkWeakPtr hm_details Nothing
leakLinkable <- mkWeakLinkables hm_linkable
return $ LeakModIndicators{..}
where
mkWeakLinkables :: HomeModLinkable -> IO [Maybe (Weak Linkable)]
mkWeakLinkables (HomeModLinkable mbc mo) =
mapM (\ln -> traverse (flip mkWeakPtr Nothing <=< evaluate) ln) [mbc, mo]

-- | Look at the LeakIndicators collected by an earlier call to
-- `getLeakIndicators`, and print messasges if any of them are still
-- alive.
checkLeakIndicators :: DynFlags -> LeakIndicators -> IO ()
checkLeakIndicators dflags (LeakIndicators leakmods) = do
performGC
forM_ leakmods $ \LeakModIndicators{..} -> do
deRefWeak leakMod >>= \case
Nothing -> return ()
Just hmi ->
report ("HomeModInfo for " ++
showSDoc dflags (ppr (mi_module (hm_iface hmi)))) (Just hmi)
deRefWeak leakIface >>= \case
Nothing -> return ()
Just miface -> report ("ModIface:" ++ moduleNameString (moduleName (mi_module miface))) (Just miface)
deRefWeak leakDetails >>= report "ModDetails"
forM_ leakLinkable $ \l -> forM_ l $ \l' -> deRefWeak l' >>= report "Linkable"
where
report :: String -> Maybe a -> IO ()
report _ Nothing = return ()
report msg (Just a) = do
addr <- anyToPtr a
putStrLn ("-fghci-leak-check: " ++ msg ++ " is still alive at " ++
show (maskTagBits addr))

tagBits
| target32Bit (targetPlatform dflags) = 2
| otherwise = 3

maskTagBits :: Ptr a -> Ptr a
maskTagBits p = intPtrToPtr (ptrToIntPtr p .&. complement (shiftL 1 tagBits - 1))
Loading