Skip to content
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

clash-lib doctest errors with GHC 9.4 on Debian #2609

Open
swt2c opened this issue Nov 17, 2023 · 5 comments
Open

clash-lib doctest errors with GHC 9.4 on Debian #2609

swt2c opened this issue Nov 17, 2023 · 5 comments
Labels

Comments

@swt2c
Copy link
Contributor

swt2c commented Nov 17, 2023

I'm trying to build clash-lib 1.8.1 on Debian with GHC 9.4.7. The build phase completes successfully, but when running the doctests test suite, I'm running into the below errors. There are lots more of them, all related to MIN_VERSION_ghc. Any ideas what might be going wrong?

Running 2 test suites...
Test suite doctests: RUNNING...

/<<PKGBUILDDIR>>/src/Clash/Backend.hs:24:0: error:
     error: missing binary operator before token "("
       24 | #if MIN_VERSION_ghc(9,0,0)
          | 
   |
24 | #if MIN_VERSION_ghc(9,0,0)
   | ^

/<<PKGBUILDDIR>>/src/Clash/Core/EqSolver.hs:21:0: error:
     error: missing binary operator before token "("
       21 | #if MIN_VERSION_ghc(9,0,0)
          | 
   |
21 | #if MIN_VERSION_ghc(9,0,0)
@christiaanb
Copy link
Member

I can replicate by:

cabal get clash-lib-1.8.1
cd clash-lib-1.8.1
cabal test

using:

> cabal --version
cabal-install version 3.8.1.0
compiled using version 3.8.1.0 of the Cabal library 
> ghc --version
The Glorious Glasgow Haskell Compilation System, version 9.4.7
> uname -a
Linux glanerbrug 6.6.1-1-default #1 SMP PREEMPT_DYNAMIC Thu Nov  9 05:27:56 UTC 2023 (1fcc265) x86_64 x86_64 x86_64 GNU/Linux

@christiaanb
Copy link
Member

As a work-around we have to do:

cabal get clash-lib-1.8.1
cd clash-lib-1.8.1
cabal build --enable-tests --write-ghc-environment-files=always
cabal test

So the problem is that the created doctest binary depends on the existence of a .ghc.environment.xyz file to get a package database. Perhaps we can find a way to "hardcode" a package database into the generated test binary? @martijnbastiaan any ideas on that?

@martijnbastiaan
Copy link
Member

This is martijnbastiaan/doctest-parallel#22.

I don't know of a way to get it from TemplateHaskell. I'm more inclined to look at Cabal's new code-generators feature (see this comment too).

@swt2c
Copy link
Contributor Author

swt2c commented Nov 18, 2023

As a work-around we have to do:

cabal get clash-lib-1.8.1
cd clash-lib-1.8.1
cabal build --enable-tests --write-ghc-environment-files=always
cabal test

There isn't a way to use this workaround when doing a Setup.hs build, is there?

@Vekhir
Copy link
Contributor

Vekhir commented Nov 30, 2023

I got the same issue on GHC 9.2.
@swt2c In case you are still searching for a workaround, the Arch package manually creates that file like this: https://gitlab.archlinux.org/archlinux/packaging/packages/haskell-doctest-parallel/-/blob/main/PKGBUILD?ref_type=heads#L38-44
Note that you have to manually adjust the GHC version (it's 9.0.2 on Arch) and potentially need to install expac (or replace that call with the version manually).

We are also reliant on a Setup.hs build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants