Skip to content
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
4 changes: 2 additions & 2 deletions .ci/docker/build-and-publish-docker-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ 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")
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")
GHC_VERSIONS=("9.12.2" "9.10.1" "9.8.4" "9.6.7" "9.4.8" "9.2.8" "9.0.2" "8.10.7")
CABAL_VERSIONS=("3.14.2.0" "3.14.2.0" "3.14.2.0" "3.14.2.0" "3.14.2.0" "3.14.2.0" "3.14.2.0" "3.12.1.0")

# We want to use docker buildkit so that our layers are built in parallel. This
# is ignored completely on versions of docker which don't support buildkit.
Expand Down
4 changes: 2 additions & 2 deletions .ci/gitlab/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ default:
timeout: 10 minutes
stage: build
variables:
CLASH_DOCKER_TAG: 20250402
CACHE_BUST_TOKEN: 3
CLASH_DOCKER_TAG: 20250419
CACHE_BUST_TOKEN: 4
# 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.
CACHE_FALLBACK_KEY: $CI_JOB_NAME-master-ghcr.io/clash-lang/clash-ci:$GHC_VERSION-$CLASH_DOCKER_TAG-$CACHE_BUST_TOKEN-3-non_protected
Expand Down
10 changes: 8 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,18 @@ tests:
CI_PARENT_PIPELINE_SOURCE: $CI_PIPELINE_SOURCE
parallel:
matrix:
- GHC_VERSION: 9.10.1
- GHC_VERSION: 9.12.2
RUN_TESTS: "always"
# TODO: remove this when https://gitlab.haskell.org/ghc/ghc/-/merge_requests/12264#note_602406
# has landed in stable release
SKIP_CLASH_FFI_EXAMPLE: "yes"

- GHC_VERSION: 9.10.1
RUN_TESTS: "nightly"

- GHC_VERSION: 9.8.4
# TODO: remove this when https://gitlab.haskell.org/ghc/ghc/-/merge_requests/12264#note_602406
# is fixed
# has landed in stable release
SKIP_CLASH_FFI_EXAMPLE: "yes"
RUN_TESTS: "always"

Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ Note that release branches might contain non-released patches.
| 9.6 | &#x2714;&#xfe0f;<sup>3</sup> | &#x2714;&#xfe0f;<sup>3,4</sup> | &#x2714;&#xfe0f;<sup>3</sup> | 1.8 | &#x2714;&#xfe0f;
| 9.8 | &#x2714;&#xfe0f; | &#x2714;&#xfe0f;<sup>4</sup> | &#x2714;&#xfe0f; | 1.8 | ️&#x2714;&#xfe0f;
| 9.10 | &#x2714;&#xfe0f; | &#x2714;&#xfe0f;<sup>4</sup> | &#x2714;&#xfe0f; | 1.8 | ️&#x2714;&#xfe0f;
| 9.12 | &#x2714;&#xfe0f; | &#x2714;&#xfe0f;<sup>4,5</sup> | &#x2714;&#xfe0f;<sup>5</sup> | 1.8.3 | ️&#x2714;&#xfe0f;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I'm concerned, I'd just put "1.8" there, not the minor. The minor version isn't all that important, and so far we've only indicated the major version. I feel it's kinda implied you pick the latest minor unless there's a strong reason not to.

I also feel a check mark for something we haven't actually tested (Windows and macOS) is a bit too optimistic.
I'm inclined to keep stuff we haven't tested crossed out. If you think crossed out is too negative, maybe we need to add a question mark emoji to indicate "might or might not work, why don't you try".



<sup>1</sup> GHC 9.2 contains a regression, rendering Clash error messages indecipherable. This change was reverted in 9.4.
Expand All @@ -85,7 +86,9 @@ Note that release branches might contain non-released patches.

<sup>3</sup> Clash starts extremely slowly when compiled with 9.4.8 up to and including 9.6.2. Consider downgrading to 9.4.7 or upgrading to 9.6.3 and up.

<sup>4</sup> Clash starts extremely slowly on Windows with GHC 9.6 through 9.10, consider downgrading to 9.4.7
<sup>4</sup> Clash starts extremely slowly on Windows with GHC 9.6 through 9.12, consider downgrading to 9.4.7

<sup>5</sup> We're waiting for Stackage to publish a nightly based on GHC 9.12 in order to get CI working on Windows and macOS.

## Cabal
To use Cabal you need both Cabal and GHC installed on your system. We recommend using [ghcup](https://www.haskell.org/ghcup/). For more information, see [https://www.haskell.org/downloads/](https://www.haskell.org/downloads/).
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-04-19T07:34:07Z

-- 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-04-20T23_25_06+02_00_add_ghc912_support
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ADD: Added GHC 9.12 support
17 changes: 14 additions & 3 deletions clash-cosim/src/Clash/CoSim/Types.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleContexts #-}

{-|
Expand All @@ -11,7 +13,10 @@ be housed in Simulator.hs, but FFI code crashes Template Haskell.
-}
module Clash.CoSim.Types where

import Data.Data (Data, Typeable)
import Data.Data (Data)
#if __GLASGOW_HASKELL__ <= 910
import Data.Data (Typeable)
#endif

import Clash.Prelude (BitPack, BitSize, KnownNat)
import Clash.XException (NFDataX)
Expand All @@ -28,7 +33,10 @@ data CoSimSettings = CoSimSettings
-- ^ Include files while running simulator
, enableStdout :: Bool
-- ^ Print verbose output to stdout
} deriving (Show, Typeable, Data)
} deriving (Show, Data)
#if __GLASGOW_HASKELL__ <= 910
deriving Typeable
#endif

-- | Default simulator settings use Icarus, have a period of 20 and all other
-- options disabled.
Expand All @@ -53,4 +61,7 @@ data CoSimulator = Icarus
-- ^ https://github.com/steveicarus/iverilog
| ModelSim
-- ^ https://www.mentor.com/products/fv/modelsim/
deriving (Show, Eq, Typeable, Data)
deriving (Show, Eq, Data)
#if __GLASGOW_HASKELL__ <= 910
deriving Typeable
#endif
18 changes: 10 additions & 8 deletions clash-ghc/clash-ghc.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ common common-options
library
import: common-options
HS-Source-Dirs: src-ghc, src-bin-common
if impl(ghc >= 9.10.0)
if impl(ghc >= 9.12.0)
HS-Source-Dirs: src-bin-9.12
elif impl(ghc >= 9.10.0)
HS-Source-Dirs: src-bin-9.10
elif impl(ghc >= 9.8.0)
HS-Source-Dirs: src-bin-9.8
Expand Down Expand Up @@ -151,7 +153,7 @@ library
base >= 4.11 && < 5,
bytestring >= 0.9 && < 0.13,
Cabal,
containers >= 0.5.4.0 && < 0.8,
containers >= 0.5.4.0 && < 0.9,
data-binary-ieee754 >= 0.4.4 && < 0.6,
directory >= 1.2 && < 1.4,
extra >= 1.6 && < 1.9,
Expand All @@ -173,23 +175,23 @@ library
ghc-typelits-natnormalise >= 0.6 && < 0.8,
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,
ghci >= 8.10.0 && < 9.11,
ghc-boot >= 8.10.0 && < 9.13,
ghc-prim >= 0.3.1.0 && < 0.14,
ghci >= 8.10.0 && < 9.13,
uniplate >= 1.6.12 && < 1.8,
reflection >= 2.1.2 && < 3.0,
primitive >= 0.5.0.1 && < 1.0,
string-interpolate ^>= 0.3,
template-haskell >= 2.8.0.0 && < 2.23,
template-haskell >= 2.8.0.0 && < 2.24,
utf8-string >= 1.0.0.0 && < 1.1.0.0,
vector >= 0.11 && < 1.0

if os(darwin)
-- 8.10 is broken on macOS - it exits tests with status code -11
Build-Depends: ghc >= 9.0.0 && < 9.11
Build-Depends: ghc >= 9.0.0 && < 9.13
else
-- Unix
Build-Depends: ghc >= 8.10.0 && < 9.11
Build-Depends: ghc >= 8.10.0 && < 9.13

if impl(ghc >= 8.10.0)
Build-Depends: exceptions >= 0.10.4 && < 0.11,
Expand Down
85 changes: 85 additions & 0 deletions clash-ghc/src-bin-9.12/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