Skip to content

Commit

Permalink
Support GHC 9.8 and 9.10
Browse files Browse the repository at this point in the history
GHC 9.8 and 9.10 give a lot of Haddock warnings. We used to check the
Haddock for all GHC versions, but this is overkill. Just check it on GHC
9.6 only.

Haddock for GHC 9.8 and up generate more information about type family
instances. However, this also leads to "could not find link destinations
for" warnings that are somehow related to these type family instances. I
suspect a bug in Haddock rather than something we can fix.

We used to first invoke `cabal build` and then
`cabal build --enable-documentation`. But this rebuilds all
dependencies, effectively doubling running time.

The `allow-newer` on `circuit-notation` is superfluous.
  • Loading branch information
DigitalBrains1 committed Jan 28, 2025
1 parent aafdee7 commit 6b49557
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 25 deletions.
8 changes: 8 additions & 0 deletions .ci/apply_settings.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

if [[ "$check_haddock" != @(true|false) ]]; then
echo "check_haddock: Expected true or false, got \"$check_haddock\"" >&2
exit 1
fi
sed <.ci/cabal.project.local.in >cabal.project.local "
s/__CHECK_HADDOCK__/$check_haddock/"
13 changes: 0 additions & 13 deletions .ci/build_docs.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
#!/bin/bash
set -xeou pipefail

# Build dependencies first, so they don't end up in logs
cabal v2-build \
--constraint=clash-prelude==$clash_version \
--enable-documentation \
--allow-newer=circuit-notation:ghc \
clash-protocols

# circuit-notation currently _compiles on 8.10, but isn't usable. The only
# other GHC version it supports is 8.6.5, but this GHC bundles a Haddock that
# cannot generate documentation for clash-prelude. Hence, we build docs with
# 8.10 and relax circuit-notation's ghc bounds
cabal v2-haddock \
--constraint=clash-prelude==$clash_version \
--enable-documentation \
--allow-newer=circuit-notation:ghc \
clash-protocols \
|& tee haddock_log

Expand Down
3 changes: 3 additions & 0 deletions .ci/cabal.project.local → .ci/cabal.project.local.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
package *
documentation: __CHECK_HADDOCK__

package clash-protocols
ghc-options: -Werror
1 change: 0 additions & 1 deletion .ci/test_cabal.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/bin/bash
set -xeou pipefail

cabal v2-build all --constraint=clash-prelude==$clash_version -fci
cabal v2-run unittests --constraint=clash-prelude==$clash_version -fci --enable-tests
cabal v2-run doctests --constraint=clash-prelude==$clash_version -fci --enable-tests
cabal v2-sdist clash-protocols
16 changes: 12 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,30 @@ jobs:
.ci/test_stack.sh
cabal:
name: Cabal tests - ghc ${{ matrix.ghc }} / clash ${{ matrix.clash }}
name: Cabal tests - ghc ${{ matrix.ghc }} / clash ${{ matrix.clash }} / doc ${{ matrix.check_haddock }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
clash:
- "1.8.1"
- "1.8.2"
cabal:
- "3.10"
ghc:
- "9.0.2"
- "9.2.8"
- "9.4.8"
- "9.6.4"
- "9.8.4"
- "9.10.1"
check_haddock:
- "false"
include:
- ghc: "9.6.4"
check_haddock: "true"

env:
check_haddock: ${{ matrix.check_haddock }}
clash_version: ${{ matrix.clash }}

steps:
Expand All @@ -79,7 +86,7 @@ jobs:

- name: Use CI specific settings
run: |
cp .ci/cabal.project.local .
.ci/apply_settings.sh
- name: Setup CI
run: |
Expand All @@ -105,6 +112,7 @@ jobs:
.ci/test_cabal.sh
- name: Documentation
if: ${{ matrix.check_haddock }}
run: |
.ci/build_docs.sh
Expand Down
2 changes: 1 addition & 1 deletion cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ package clash-prelude
source-repository-package
type: git
location: https://github.com/cchalmers/circuit-notation.git
tag: 19b386c4aa3ff690758ae089c7754303f3500cc9
tag: 564769c52aa05b90f81bbc898b7af7087d96613d

package clash-protocols-base
-- Reduces compile times by ~20%
Expand Down
2 changes: 1 addition & 1 deletion clash-protocols-base/clash-protocols-base.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ library
, circuit-notation
, deepseq
, extra
, ghc >= 8.7 && < 9.7
, ghc >= 8.7 && < 9.11
, hashable
, tagged
, template-haskell
Expand Down
2 changes: 1 addition & 1 deletion clash-protocols/clash-protocols.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ library
, data-default ^>= 0.7.1.1
, deepseq
, extra
, ghc >= 8.7 && < 9.7
, ghc >= 8.7 && < 9.11
, hashable
, hedgehog >= 1.0.2
, lifted-async
Expand Down
8 changes: 6 additions & 2 deletions clash-protocols/src/Protocols/Df.hs
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,13 @@ import Prelude hiding (
import qualified Data.Bifunctor as B
import Data.Bool (bool)
import qualified Data.Coerce as Coerce
#if MIN_VERSION_base(4,19,0)
import qualified Data.Functor as Functor (unzip)
#else
import qualified Data.List.NonEmpty as Functor (unzip)
#endif
import Data.Kind (Type)
import Data.List ((\\))
import qualified Data.List.NonEmpty
import qualified Data.Maybe as Maybe
import Data.Proxy
import qualified Prelude as P
Expand Down Expand Up @@ -862,7 +866,7 @@ roundrobinCollect Parallel =
nacks = C.repeat (Ack False)
acks = Maybe.fromMaybe nacks ((\i -> C.replace i ack nacks) <$> iM)
dat1 = Maybe.fromMaybe NoData dat0
(iM, dat0) = Data.List.NonEmpty.unzip dats1
(iM, dat0) = Functor.unzip dats1
dats1 = C.fold @(n C.- 1) (<|>) (C.zipWith goDat C.indicesI dats0)

goDat i dat
Expand Down
2 changes: 0 additions & 2 deletions clash-protocols/src/Protocols/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
{-# LANGUAGE TypeFamilyDependencies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -fconstraint-solver-iterations=20 #-}
#if !MIN_VERSION_clash_prelude(1, 8, 2)
{-# OPTIONS_GHC -fno-warn-orphans #-}
#endif

-- TODO: Hide internal documentation
-- {-# OPTIONS_HADDOCK hide #-}
Expand Down

0 comments on commit 6b49557

Please sign in to comment.