From f31baa743fb7b3cfb7445b946155e0ed62706d36 Mon Sep 17 00:00:00 2001 From: Martijn Bastiaan Date: Thu, 8 Feb 2024 17:35:40 +0100 Subject: [PATCH] Drop support for GHC 8.6 and 8.8 --- .ci/docker/build-and-publish-docker-image.sh | 4 +- .ci/stack-8.6.yaml | 34 - .ci/stack-8.8.yaml | 29 - .github/workflows/ci.yml | 11 +- .gitlab-ci.yml | 6 +- README.md | 4 +- ...1_14_33+01_00_drop_support_for_ghc86_ghc88 | 1 + clash-ghc/clash-ghc.cabal | 17 +- clash-ghc/src-bin-861/Clash/GHCi/Leak.hs | 61 - clash-ghc/src-bin-861/Clash/GHCi/UI.hs | 4015 ---------------- clash-ghc/src-bin-861/Clash/GHCi/UI/Info.hs | 368 -- clash-ghc/src-bin-861/Clash/GHCi/UI/Monad.hs | 474 -- clash-ghc/src-bin-861/Clash/GHCi/UI/Tags.hs | 216 - clash-ghc/src-bin-861/Clash/Main.hs | 1041 ----- clash-ghc/src-bin-881/Clash/GHCi/Leak.hs | 77 - clash-ghc/src-bin-881/Clash/GHCi/UI.hs | 4133 ----------------- clash-ghc/src-bin-881/Clash/GHCi/UI/Info.hs | 378 -- clash-ghc/src-bin-881/Clash/GHCi/UI/Monad.hs | 536 --- clash-ghc/src-bin-881/Clash/GHCi/UI/Tags.hs | 217 - clash-ghc/src-bin-881/Clash/GHCi/Util.hs | 17 - clash-ghc/src-bin-881/Clash/Main.hs | 1061 ----- clash-ghc/src-ghc/Clash/GHC/GHC2Core.hs | 50 +- clash-ghc/src-ghc/Clash/GHC/LoadModules.hs | 7 - .../src/Clash/Hedgehog/Core/Monad.hs | 3 - clash-lib/clash-lib.cabal | 2 +- clash-lib/src/Clash/Core/HasType.hs | 2 - clash-lib/src/Clash/Core/Literal.hs | 2 - clash-lib/src/Clash/Core/Pretty.hs | 2 - clash-lib/src/Clash/Core/Type.hs | 13 - clash-lib/src/Clash/Core/TysPrim.hs | 12 - clash-lib/src/Clash/Netlist.hs | 2 - clash-lib/src/Clash/Netlist/Util.hs | 3 - .../Clash/Normalize/Transformations/DEC.hs | 4 +- clash-lib/src/Clash/Primitives/GHC/Int.hs | 2 - clash-lib/src/Clash/Primitives/GHC/Word.hs | 2 - .../src/Clash/Class/AutoReg/Internal.hs | 4 - 36 files changed, 18 insertions(+), 12792 deletions(-) delete mode 100644 .ci/stack-8.6.yaml delete mode 100644 .ci/stack-8.8.yaml create mode 100644 changelog/2024-02-11T11_14_33+01_00_drop_support_for_ghc86_ghc88 delete mode 100644 clash-ghc/src-bin-861/Clash/GHCi/Leak.hs delete mode 100644 clash-ghc/src-bin-861/Clash/GHCi/UI.hs delete mode 100644 clash-ghc/src-bin-861/Clash/GHCi/UI/Info.hs delete mode 100644 clash-ghc/src-bin-861/Clash/GHCi/UI/Monad.hs delete mode 100644 clash-ghc/src-bin-861/Clash/GHCi/UI/Tags.hs delete mode 100644 clash-ghc/src-bin-861/Clash/Main.hs delete mode 100644 clash-ghc/src-bin-881/Clash/GHCi/Leak.hs delete mode 100644 clash-ghc/src-bin-881/Clash/GHCi/UI.hs delete mode 100644 clash-ghc/src-bin-881/Clash/GHCi/UI/Info.hs delete mode 100644 clash-ghc/src-bin-881/Clash/GHCi/UI/Monad.hs delete mode 100644 clash-ghc/src-bin-881/Clash/GHCi/UI/Tags.hs delete mode 100644 clash-ghc/src-bin-881/Clash/GHCi/Util.hs delete mode 100644 clash-ghc/src-bin-881/Clash/Main.hs diff --git a/.ci/docker/build-and-publish-docker-image.sh b/.ci/docker/build-and-publish-docker-image.sh index 87c2618d1b..4dd64b0938 100755 --- a/.ci/docker/build-and-publish-docker-image.sh +++ b/.ci/docker/build-and-publish-docker-image.sh @@ -14,8 +14,8 @@ elif [[ "$1" != "" ]]; then exit 1 fi -GHC_VERSIONS=( "9.6.2" "9.4.6" "9.2.8" "9.0.2" "8.10.7" "8.8.4" "8.6.5") -CABAL_VERSIONS=("3.10.1.0" "3.8.1.0" "3.6.2.0" "3.4.0.0" "3.2.0.0" "3.2.0.0" "3.0.0.0") +GHC_VERSIONS=( "9.6.2" "9.4.6" "9.2.8" "9.0.2" "8.10.7") +CABAL_VERSIONS=("3.10.1.0" "3.8.1.0" "3.6.2.0" "3.4.0.0" "3.2.0.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. diff --git a/.ci/stack-8.6.yaml b/.ci/stack-8.6.yaml deleted file mode 100644 index 9bff45bf12..0000000000 --- a/.ci/stack-8.6.yaml +++ /dev/null @@ -1,34 +0,0 @@ -resolver: lts-14.27 - -ghc-options: - "$locals": -Wall -Wcompat - -packages: -- clash-prelude -- clash-prelude-hedgehog -- clash-lib -- clash-lib-hedgehog -- clash-ghc -- clash-cores -- tests - -extra-deps: -- arrows-0.4.4.2@sha256:a260222b766da922657e302aa7c0409451913e1e503798a47a213a61ba382460,1235 -- fakedata-1.0.2@sha256:37c93be9a81acbc9109e2c0b300a793d9c1f5ead1d34330d869d76568191f428,24593 -- ghc-typelits-extra-0.4.3@sha256:ffffa19b699b1c0f6f4d6c8c8ecff825ff0862fee4c9f05dfcc984583f11df54,5031 -- ghc-typelits-knownnat-0.7.6@sha256:04a4ea3dc82db12ea866417102345e5b806c3afef634c5136ee667a172496554,4834 -- ghc-typelits-natnormalise-0.7.6@sha256:42f87e22c46907fc4d7db3f73ca324cdb32ae9b10c558ebd7a7b4de9f33da8ac,3639 -- hedgehog-1.0.5@sha256:a14356de69470b7e3966a65cd887c15b168d76ec7892c45cf0e23fea788fdbdc,4533 -- hedgehog-fakedata-0.0.1.4@sha256:bd826430f9fd17d4f226c917328c429add0ff410a88384d2fef2d4374382cf95,1361 -- mmorph-1.1.5@sha256:9487ce601cbc3403c844c23a6fddb48f6b69a0097b77493670a45fc7a442fb20,1036 -- Stream-0.4.7.2@sha256:ed78165aa34c4e23dc53c9072f8715d414a585037f2145ea0eb2b38300354c53,1009 -- fakedata-parser-0.1.0.0@sha256:6de870a2c21624aa4516f7ee28fc0076b3b19f3c32d23c969f8f0d7de47c606a,1362 -- string-random-0.1.4.2@sha256:d34c614b63dbf928af428c1f2be033463c9bddfb286f3002657ef13336a2de32,2172 -- lazysmallcheck-0.6@sha256:dac7a1e4877681f1260309e863e896674dd6efc1159897b7945893e693f2a6bc,1696 -- regex-tdfa-1.3.1.2@sha256:9bafdeace4742f553d22a3da008081ac09009b3b52d38a53ad76795dfd3f180a,6572 -- regex-base-0.94.0.2@sha256:4ff4425c710cddf440dfbac6cd52310bb6b23e17902390ff71c9fc7eaafc4fcc,2643 -- string-interpolate-0.3.1.2@sha256:4d0987f453c66040aa8e482fe28a7d3cdc9d8df01b698bc92f42a592cfb337db,4268 -- prettyprinter-interp-0.2.0.0@sha256:45299b61bd6c27d594c1a72b5a8dd5734e791a59828725e4f4e420f3cc37232b,2016 -- infinite-list-0.1@sha256:4de250517ce75e128c766fbc1f23b5a778ea964e695e47f8e83e0f3b293091bf,2383 -- tasty-1.5@sha256:c62c96da1e9d65bf61ce583e9f7085eed1daeb62a45f3106ca252bf9ef87025b,2763 -- attoparsec-aeson-2.1.0.0@sha256:fa83aba43bfa58490de8f274d19b9d58b6403a207b12cac5f93922102b084c52,1154 diff --git a/.ci/stack-8.8.yaml b/.ci/stack-8.8.yaml deleted file mode 100644 index 821630b930..0000000000 --- a/.ci/stack-8.8.yaml +++ /dev/null @@ -1,29 +0,0 @@ -resolver: lts-16.31 - -ghc-options: - "$locals": -Wall -Wcompat - -packages: -- clash-prelude -- clash-prelude-hedgehog -- clash-lib -- clash-lib-hedgehog -- clash-ghc -- clash-cores -- tests - -extra-deps: -- arrows-0.4.4.2@sha256:a260222b766da922657e302aa7c0409451913e1e503798a47a213a61ba382460,1235 -- fakedata-1.0.2@sha256:37c93be9a81acbc9109e2c0b300a793d9c1f5ead1d34330d869d76568191f428,24593 -- hedgehog-fakedata-0.0.1.4@sha256:bd826430f9fd17d4f226c917328c429add0ff410a88384d2fef2d4374382cf95,1361 -- mmorph-1.1.5@sha256:9487ce601cbc3403c844c23a6fddb48f6b69a0097b77493670a45fc7a442fb20,1036 -- Stream-0.4.7.2@sha256:ed78165aa34c4e23dc53c9072f8715d414a585037f2145ea0eb2b38300354c53,1009 -- fakedata-parser-0.1.0.0@sha256:6de870a2c21624aa4516f7ee28fc0076b3b19f3c32d23c969f8f0d7de47c606a,1362 -- string-random-0.1.4.2@sha256:d34c614b63dbf928af428c1f2be033463c9bddfb286f3002657ef13336a2de32,2172 -- lazysmallcheck-0.6@sha256:dac7a1e4877681f1260309e863e896674dd6efc1159897b7945893e693f2a6bc,1696 -- docopt-0.7.0.7@sha256:a3d2eac54cd77d8c0b306ff96fb57be55542f143d81766aa1ae51458ad790dbe,3655 -- string-interpolate-0.3.1.2@sha256:4d0987f453c66040aa8e482fe28a7d3cdc9d8df01b698bc92f42a592cfb337db,4268 -- prettyprinter-interp-0.2.0.0@sha256:45299b61bd6c27d594c1a72b5a8dd5734e791a59828725e4f4e420f3cc37232b,2016 -- infinite-list-0.1@sha256:4de250517ce75e128c766fbc1f23b5a778ea964e695e47f8e83e0f3b293091bf,2383 -- tasty-1.5@sha256:c62c96da1e9d65bf61ce583e9f7085eed1daeb62a45f3106ca252bf9ef87025b,2763 -- attoparsec-aeson-2.1.0.0@sha256:fa83aba43bfa58490de8f274d19b9d58b6403a207b12cac5f93922102b084c52,1154 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a2c0ee35fc..a08ab2a0f0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,17 +21,12 @@ jobs: fail-fast: false matrix: os: ["macOS", "windows"] - ghc: ["8.6", "8.8", "8.10", "9.0", "9.2", "9.4"] + ghc: ["8.10", "9.0", "9.2", "9.4"] exclude: # Some tests fail with a mysterious -11 error code. - os: macOS ghc: 8.10 - # Windows gets non-deterministically gets stuck in infinite loops - # or segfaults while running the testcase. - - os: windows - ghc: 8.8 - # GHC 9.0 fails to compile clash-cores due to a template haskell # failure - os: windows @@ -115,11 +110,11 @@ jobs: strategy: fail-fast: false matrix: - ghc: [ "8.6.5", "9.0.2", "9.6.2" ] + ghc: [ "8.10.7", "9.0.2", "9.6.2" ] include: - multiple_hidden: yes - - ghc: 8.6.5 + - ghc: 8.10.7 multiple_hidden: no workaround_ghc_mmap_crash: yes diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6799e23965..fd77d55f9e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -49,11 +49,7 @@ tests: WORKAROUND_GHC_MMAP_CRASH: "yes" RUN_TESTS: "always" - - GHC_VERSION: [8.10.7, 8.8.4] - WORKAROUND_GHC_MMAP_CRASH: "yes" - RUN_TESTS: "nightly" - - - GHC_VERSION: 8.6.5 + - GHC_VERSION: [8.10.7] WORKAROUND_GHC_MMAP_CRASH: "yes" MULTIPLE_HIDDEN: "no" RUN_TESTS: "always" diff --git a/README.md b/README.md index cf87134c49..23be55ea91 100644 --- a/README.md +++ b/README.md @@ -65,8 +65,8 @@ Note that release branches might contain non-released patches. ## GHC compatibility | | Linux | Windows | macOS | Clash (released) | Clash (development version) |------|-------|---------|-------|------------------|-------------------------- -| 8.6 | ✔️ | ✔️ | ✔️ | 1.0 - 1.6 | ✔️ -| 8.8 | ✔️ | ❌ | ✔️ | 1.0 - 1.6 | ✔️ +| 8.6 | ✔️ | ✔️ | ✔️ | 1.0 - 1.6 | ❌ ️ +| 8.8 | ✔️ | ❌ | ✔️ | 1.0 - 1.6 | ❌ ️ | 8.10 | ✔️ | ✔️ | ❌ | 1.2 - 1.6 | ✔️ | 9.0 | ✔️ | ✔️² | ✔️ | 1.4 - 1.6 | ✔️ | 9.2 | ⚠️¹ | ⚠️¹ | ⚠️¹ | | ⚠️¹️ diff --git a/changelog/2024-02-11T11_14_33+01_00_drop_support_for_ghc86_ghc88 b/changelog/2024-02-11T11_14_33+01_00_drop_support_for_ghc86_ghc88 new file mode 100644 index 0000000000..c0c809b1e0 --- /dev/null +++ b/changelog/2024-02-11T11_14_33+01_00_drop_support_for_ghc86_ghc88 @@ -0,0 +1 @@ +REMOVED: Clash no longer supports GHC 8.6 and GHC 8.8 diff --git a/clash-ghc/clash-ghc.cabal b/clash-ghc/clash-ghc.cabal index d05ebaded6..2c1c027f6a 100644 --- a/clash-ghc/clash-ghc.cabal +++ b/clash-ghc/clash-ghc.cabal @@ -133,10 +133,6 @@ library HS-Source-Dirs: src-bin-9.0 elif impl(ghc >= 8.10.0) HS-Source-Dirs: src-bin-8.10 - elif impl(ghc >= 8.8.0) - HS-Source-Dirs: src-bin-881 - elif impl(ghc >= 8.6.0) - HS-Source-Dirs: src-bin-861 GHC-Options: -Wall -Wcompat if impl(ghc >= 8.10.0) @@ -176,9 +172,9 @@ library ghc-typelits-natnormalise >= 0.6 && < 0.8, deepseq >= 1.3.0.2 && < 1.6, time >= 1.4.0.1 && < 1.14, - ghc-boot >= 8.6.0 && < 9.9, + ghc-boot >= 8.10.0 && < 9.9, ghc-prim >= 0.3.1.0 && < 0.12, - ghci >= 8.6.0 && < 9.9, + ghci >= 8.10.0 && < 9.9, uniplate >= 1.6.12 && < 1.8, reflection >= 2.1.2 && < 3.0, primitive >= 0.5.0.1 && < 1.0, @@ -187,15 +183,12 @@ library utf8-string >= 1.0.0.0 && < 1.1.0.0, vector >= 0.11 && < 1.0 - if os(windows) - -- 8.8 is broken on Windows - it randomly segfaults - Build-Depends: ghc >= 8.6.0 && < 8.8.0 || >= 8.10.0 && < 9.9 - elif os(darwin) + if os(darwin) -- 8.10 is broken on macOS - it exits tests with status code -11 - Build-Depends: ghc >= 8.6.0 && < 8.10.0 || >= 9.0.0 && < 9.9 + Build-Depends: ghc >= 9.0.0 && < 9.9 else -- Unix - Build-Depends: ghc >= 8.6.0 && < 9.9 + Build-Depends: ghc >= 8.10.0 && < 9.9 if impl(ghc >= 8.10.0) Build-Depends: exceptions >= 0.10.4 && < 0.11, diff --git a/clash-ghc/src-bin-861/Clash/GHCi/Leak.hs b/clash-ghc/src-bin-861/Clash/GHCi/Leak.hs deleted file mode 100644 index c7a7226276..0000000000 --- a/clash-ghc/src-bin-861/Clash/GHCi/Leak.hs +++ /dev/null @@ -1,61 +0,0 @@ -{-# LANGUAGE LambdaCase #-} -{-# LANGUAGE RecordWildCards #-} - -module Clash.GHCi.Leak - ( LeakIndicators - , getLeakIndicators - , checkLeakIndicators - ) where - -import Control.Monad -import GHC -import Outputable -import HscTypes -import UniqDFM -import System.Mem -import System.Mem.Weak - --- 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 HscEnv{..} = - fmap LeakIndicators $ - forM (eltsUDFM hsc_HPT) $ \hmi@HomeModInfo{..} -> do - leakMod <- mkWeakPtr hmi Nothing - leakIface <- mkWeakPtr hm_iface Nothing - leakDetails <- mkWeakPtr hm_details Nothing - leakLinkable <- mapM (`mkWeakPtr` Nothing) hm_linkable - return $ LeakModIndicators{..} - --- | 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 >>= report "ModIface" - deRefWeak leakDetails >>= report "ModDetails" - forM_ leakLinkable $ \l -> deRefWeak l >>= report "Linkable" - where - report :: String -> Maybe a -> IO () - report _ Nothing = return () - report msg (Just _) = - putStrLn ("-fghci-leak-check: " ++ msg ++ " is still alive!") diff --git a/clash-ghc/src-bin-861/Clash/GHCi/UI.hs b/clash-ghc/src-bin-861/Clash/GHCi/UI.hs deleted file mode 100644 index 72d9649139..0000000000 --- a/clash-ghc/src-bin-861/Clash/GHCi/UI.hs +++ /dev/null @@ -1,4015 +0,0 @@ -{-# OPTIONS_GHC -Wno-name-shadowing #-} -{-# LANGUAGE CPP #-} -{-# LANGUAGE LambdaCase #-} -{-# LANGUAGE MultiWayIf #-} -{-# LANGUAGE NondecreasingIndentation #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE RecordWildCards #-} - -{-# OPTIONS -fno-cse #-} --- -fno-cse is needed for GLOBAL_VAR's to behave properly - ------------------------------------------------------------------------------ --- --- GHC Interactive User Interface --- --- (c) The GHC Team 2005-2006 --- ------------------------------------------------------------------------------ - -module Clash.GHCi.UI ( - interactiveUI, - GhciSettings(..), - defaultGhciSettings, - ghciCommands, - ghciWelcomeMsg, - makeHDL - ) where - -#include "HsVersions.h" - --- GHCi -import qualified Clash.GHCi.UI.Monad as GhciMonad ( args, runStmt, runDecls ) -import Clash.GHCi.UI.Monad hiding ( args, runStmt, runDecls ) -import Clash.GHCi.UI.Tags -import Clash.GHCi.UI.Info -import Debugger - --- The GHC interface -import GHCi -import GHCi.RemoteTypes -import GHCi.BreakArray -import DynFlags -import ErrUtils hiding (traceCmd) -import Finder -import GhcMonad ( modifySession ) -import qualified GHC -import GHC ( LoadHowMuch(..), Target(..), TargetId(..), InteractiveImport(..), - TyThing(..), Phase, BreakIndex, Resume, SingleStep, Ghc, - GetDocsFailure(..), - getModuleGraph, handleSourceError ) -import HsImpExp -import HsSyn -import HscTypes ( tyThingParent_maybe, handleFlagWarnings, getSafeMode, hsc_IC, - setInteractivePrintName, hsc_dflags, msObjFilePath ) -import Module -import Name -import Packages ( trusted, getPackageDetails, getInstalledPackageDetails, - listVisibleModuleNames, pprFlag ) -import IfaceSyn ( showToHeader ) -import PprTyThing -import PrelNames -import RdrName ( getGRE_NameQualifier_maybes, getRdrName ) -import SrcLoc -import qualified Lexer - -import StringBuffer -import Outputable hiding ( printForUser, printForUserPartWay ) - -import DynamicLoading ( initializePlugins ) - --- Other random utilities -import BasicTypes hiding ( isTopLevel ) -import Digraph -import Encoding -import FastString -import Linker -import Maybes ( orElse, expectJust ) -import NameSet -import Panic hiding ( showException ) -import Util -import qualified GHC.LanguageExtensions as LangExt - --- Haskell Libraries -import System.Console.Haskeline as Haskeline - -import Control.Applicative hiding (empty) -import Control.DeepSeq (deepseq) -import Control.Monad as Monad -import Control.Monad.IO.Class -import Control.Monad.Trans.Class -import Control.Monad.Trans.Except - -import Data.Array -import qualified Data.ByteString.Char8 as BS -import Data.Char -import Data.Function -import Data.IORef ( IORef, modifyIORef, newIORef, readIORef, writeIORef ) -import Data.List ( find, group, intercalate, intersperse, isPrefixOf, nub, - partition, sort, sortBy ) -import Data.Proxy -import qualified Data.Set as S -import Data.Maybe -import Data.Map (Map) -import qualified Data.Map as M -import Data.Time.LocalTime ( getZonedTime ) -import Data.Time.Format ( formatTime, defaultTimeLocale ) -import Data.Version ( showVersion ) -import Prelude hiding ((<>)) - -import Exception hiding (catch) -import Foreign hiding (void) -import GHC.Stack hiding (SrcLoc(..)) - -import System.Directory -import System.Environment -import System.Exit ( exitWith, ExitCode(..) ) -import System.FilePath -import System.Info -import System.IO -import System.IO.Error -import System.IO.Unsafe ( unsafePerformIO ) -import System.Process -import Text.Printf -import Text.Read ( readMaybe ) -import Text.Read.Lex (isSymbolChar) - -import Unsafe.Coerce - -#if !defined(mingw32_HOST_OS) -import System.Posix hiding ( getEnv ) -#else -import qualified System.Win32 -#endif - -import GHC.IO.Exception ( IOErrorType(InvalidArgument) ) -import GHC.IO.Handle ( hFlushAll ) -import GHC.TopHandler ( topHandler ) - -import Clash.GHCi.Leak - --- clash additions -import Clash.Backend (Backend(initBackend, hdlKind, primDirs)) -import Clash.Backend.SystemVerilog (SystemVerilogState) -import Clash.Backend.VHDL (VHDLState) -import Clash.Backend.Verilog (VerilogState) -import qualified Clash.Driver -import Clash.Driver.Types (ClashOpts(..), ClashEnv(..), ClashDesign(..)) - -import Clash.GHC.PartialEval -import Clash.GHC.Evaluator - -import Clash.GHC.GenerateBindings -import Clash.GHC.NetlistTypes -import Clash.GHCi.Common -import Clash.Util (clashLibVersion, reportTimeDiff) -import qualified Data.Time.Clock as Clock -import qualified Paths_clash_ghc - ------------------------------------------------------------------------------ - -data GhciSettings = GhciSettings { - availableCommands :: [Command], - shortHelpText :: String, - fullHelpText :: String, - defPrompt :: PromptFunction, - defPromptCont :: PromptFunction - } - -defaultGhciSettings :: IORef ClashOpts -> GhciSettings -defaultGhciSettings opts = - GhciSettings { - availableCommands = ghciCommands opts, - shortHelpText = defShortHelpText, - defPrompt = default_prompt, - defPromptCont = default_prompt_cont, - fullHelpText = defFullHelpText - } - -ghciWelcomeMsg :: String -ghciWelcomeMsg = "Clashi, version " ++ Data.Version.showVersion Paths_clash_ghc.version ++ - " (using clash-lib, version " ++ Data.Version.showVersion clashLibVersion ++ - "):\nhttps://clash-lang.org/ :? for help" - -ghciCommands :: IORef ClashOpts -> [Command] -ghciCommands opts = map mkCmd [ - -- Hugs users are accustomed to :e, so make sure it doesn't overlap - ("?", keepGoing help, noCompletion), - ("add", keepGoingPaths addModule, completeFilename), - ("abandon", keepGoing abandonCmd, noCompletion), - ("break", keepGoing breakCmd, completeIdentifier), - ("back", keepGoing backCmd, noCompletion), - ("browse", keepGoing' (browseCmd False), completeModule), - ("browse!", keepGoing' (browseCmd True), completeModule), - ("cd", keepGoing' changeDirectory, completeFilename), - ("check", keepGoing' checkModule, completeHomeModule), - ("continue", keepGoing continueCmd, noCompletion), - ("cmd", keepGoing cmdCmd, completeExpression), - ("ctags", keepGoing createCTagsWithLineNumbersCmd, completeFilename), - ("ctags!", keepGoing createCTagsWithRegExesCmd, completeFilename), - ("def", keepGoing (defineMacro False), completeExpression), - ("def!", keepGoing (defineMacro True), completeExpression), - ("delete", keepGoing deleteCmd, noCompletion), - ("doc", keepGoing' docCmd, completeIdentifier), - ("edit", keepGoing' editFile, completeFilename), - ("etags", keepGoing createETagsFileCmd, completeFilename), - ("force", keepGoing forceCmd, completeExpression), - ("forward", keepGoing forwardCmd, noCompletion), - ("help", keepGoing help, noCompletion), - ("history", keepGoing historyCmd, noCompletion), - ("info", keepGoing' (info False), completeIdentifier), - ("info!", keepGoing' (info True), completeIdentifier), - ("issafe", keepGoing' isSafeCmd, completeModule), - ("kind", keepGoing' (kindOfType False), completeIdentifier), - ("kind!", keepGoing' (kindOfType True), completeIdentifier), - ("load", keepGoingPaths loadModule_, completeHomeModuleOrFile), - ("load!", keepGoingPaths loadModuleDefer, completeHomeModuleOrFile), - ("list", keepGoing' listCmd, noCompletion), - ("module", keepGoing moduleCmd, completeSetModule), - ("main", keepGoing runMain, completeFilename), - ("print", keepGoing printCmd, completeExpression), - ("quit", quit, noCompletion), - ("reload", keepGoing' reloadModule, noCompletion), - ("reload!", keepGoing' reloadModuleDefer, noCompletion), - ("run", keepGoing runRun, completeFilename), - ("script", keepGoing' scriptCmd, completeFilename), - ("set", keepGoing setCmd, completeSetOptions), - ("seti", keepGoing setiCmd, completeSeti), - ("show", keepGoing showCmd, completeShowOptions), - ("showi", keepGoing showiCmd, completeShowiOptions), - ("sprint", keepGoing sprintCmd, completeExpression), - ("step", keepGoing stepCmd, completeIdentifier), - ("steplocal", keepGoing stepLocalCmd, completeIdentifier), - ("stepmodule",keepGoing stepModuleCmd, completeIdentifier), - ("type", keepGoing' typeOfExpr, completeExpression), - ("trace", keepGoing traceCmd, completeExpression), - ("unadd", keepGoingPaths unAddModule, completeFilename), - ("undef", keepGoing undefineMacro, completeMacro), - ("unset", keepGoing unsetOptions, completeSetOptions), - ("where", keepGoing whereCmd, noCompletion), - ("vhdl", keepGoingPaths (makeVHDL opts), completeHomeModuleOrFile), - ("verilog", keepGoingPaths (makeVerilog opts), completeHomeModuleOrFile), - ("systemverilog", keepGoingPaths (makeSystemVerilog opts), completeHomeModuleOrFile) - ] ++ map mkCmdHidden [ -- hidden commands - ("all-types", keepGoing' allTypesCmd), - ("complete", keepGoing completeCmd), - ("loc-at", keepGoing' locAtCmd), - ("type-at", keepGoing' typeAtCmd), - ("uses", keepGoing' usesCmd) - ] - where - mkCmd (n,a,c) = Command { cmdName = n - , cmdAction = a - , cmdHidden = False - , cmdCompletionFunc = c - } - - mkCmdHidden (n,a) = Command { cmdName = n - , cmdAction = a - , cmdHidden = True - , cmdCompletionFunc = noCompletion - } - --- We initialize readline (in the interactiveUI function) to use --- word_break_chars as the default set of completion word break characters. --- This can be overridden for a particular command (for example, filename --- expansion shouldn't consider '/' to be a word break) by setting the third --- entry in the Command tuple above. --- --- NOTE: in order for us to override the default correctly, any custom entry --- must be a SUBSET of word_break_chars. -word_break_chars :: String -word_break_chars = spaces ++ specials ++ symbols - -symbols, specials, spaces :: String -symbols = "!#$%&*+/<=>?@\\^|-~" -specials = "(),;[]`{}" -spaces = " \t\n" - -flagWordBreakChars :: String -flagWordBreakChars = " \t\n" - - -keepGoing :: (String -> GHCi ()) -> (String -> InputT GHCi Bool) -keepGoing a str = keepGoing' (lift . a) str - -keepGoing' :: Monad m => (String -> m ()) -> String -> m Bool -keepGoing' a str = a str >> return False - -keepGoingPaths :: ([FilePath] -> InputT GHCi ()) -> (String -> InputT GHCi Bool) -keepGoingPaths a str - = do case toArgs str of - Left err -> liftIO $ hPutStrLn stderr err - Right args -> a args - return False - -defShortHelpText :: String -defShortHelpText = "use :? for help.\n" - -defFullHelpText :: String -defFullHelpText = - " Commands available from the prompt:\n" ++ - "\n" ++ - " evaluate/run \n" ++ - " : repeat last command\n" ++ - " :{\\n ..lines.. \\n:}\\n multiline command\n" ++ - " :add [*] ... add module(s) to the current target set\n" ++ - " :browse[!] [[*]] display the names defined by module \n" ++ - " (!: more details; *: all top-level names)\n" ++ - " :cd change directory to \n" ++ - " :cmd run the commands returned by ::IO String\n" ++ - " :complete [] list completions for partial input string\n" ++ - " :ctags[!] [] create tags file for Vi (default: \"tags\")\n" ++ - " (!: use regex instead of line number)\n" ++ - " :def define command : (later defined command has\n" ++ - " precedence, :: is always a builtin command)\n" ++ - " :doc display docs for the given name (experimental)\n" ++ - " :edit edit file\n" ++ - " :edit edit last module\n" ++ - " :etags [] create tags file for Emacs (default: \"TAGS\")\n" ++ - " :help, :? display this list of commands\n" ++ - " :info[!] [ ...] display information about the given names\n" ++ - " (!: do not filter instances)\n" ++ - " :issafe [] display safe haskell information of module \n" ++ - " :kind[!] show the kind of \n" ++ - " (!: also print the normalised type)\n" ++ - " :load[!] [*] ... load module(s) and their dependents\n" ++ - " (!: defer type errors)\n" ++ - " :main [ ...] run the main function with the given arguments\n" ++ - " :module [+/-] [*] ... set the context for expression evaluation\n" ++ - " :quit exit GHCi\n" ++ - " :reload[!] reload the current module set\n" ++ - " (!: defer type errors)\n" ++ - " :run function [ ...] run the function with the given arguments\n" ++ - " :script run the script \n" ++ - " :type show the type of \n" ++ - " :type +d show the type of , defaulting type variables\n" ++ - " :type +v show the type of , with its specified tyvars\n" ++ - " :unadd ... remove module(s) from the current target set\n" ++ - " :undef undefine user-defined command :\n" ++ - " :! run the shell command \n" ++ - " :vhdl synthesize currently loaded module to vhdl\n" ++ - " :vhdl [] synthesize specified modules/files to vhdl\n" ++ - " :verilog synthesize currently loaded module to verilog\n" ++ - " :verilog [] synthesize specified modules/files to verilog\n" ++ - " :systemverilog synthesize currently loaded module to systemverilog\n" ++ - " :systemverilog [] synthesize specified modules/files to systemverilog\n" ++ - "\n" ++ - " -- Commands for debugging:\n" ++ - "\n" ++ - " :abandon at a breakpoint, abandon current computation\n" ++ - " :back [] go back in the history N steps (after :trace)\n" ++ - " :break [] [] set a breakpoint at the specified location\n" ++ - " :break set a breakpoint on the specified function\n" ++ - " :continue resume after a breakpoint\n" ++ - " :delete delete the specified breakpoint\n" ++ - " :delete * delete all breakpoints\n" ++ - " :force print , forcing unevaluated parts\n" ++ - " :forward [] go forward in the history N step s(after :back)\n" ++ - " :history [] after :trace, show the execution history\n" ++ - " :list show the source code around current breakpoint\n" ++ - " :list show the source code for \n" ++ - " :list [] show the source code around line number \n" ++ - " :print [ ...] show a value without forcing its computation\n" ++ - " :sprint [ ...] simplified version of :print\n" ++ - " :step single-step after stopping at a breakpoint\n"++ - " :step single-step into \n"++ - " :steplocal single-step within the current top-level binding\n"++ - " :stepmodule single-step restricted to the current module\n"++ - " :trace trace after stopping at a breakpoint\n"++ - " :trace evaluate with tracing on (see :history)\n"++ - - "\n" ++ - " -- Commands for changing settings:\n" ++ - "\n" ++ - " :set