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

cabal syntax errors with ghc-8.0 #6722

Closed
bfrk opened this issue Apr 20, 2020 · 3 comments
Closed

cabal syntax errors with ghc-8.0 #6722

bfrk opened this issue Apr 20, 2020 · 3 comments

Comments

@bfrk
Copy link

bfrk commented Apr 20, 2020

I am using cabal-3.2. Everything works fine with ghc versions from 8.8 down to 8.2. However, when I use ghc-8.0 something very strange happens: cabal no longer recognizes the cabal file syntax:

Warning: darcs.cabal: Unknown fields: autogen-modules (line 356)

It then proceeds to compile everything just fine. But in the end it fails with

setup: Error: Could not find module: Version with any suffix:
["gc","chs","hsc","x","y","ly","cpphs","hs","lhs"]

even though there is a generated Version.hs file at

dist-newstyle/build/x86_64-linux/ghc-8.0.2/darcs-2.14.2/build/autogen/Version.hs

Why does cabal-3.2 switch to a different cabal file parser depending on the ghc version?

How can I fix this?

@phadej
Copy link
Collaborator

phadej commented Apr 21, 2020

darcs uses build-type: Custom and has

custom-setup
    setup-depends: base      >= 4.9 && < 4.13,
                   Cabal     >= 1.24,

So with GHC-8.0.2 it actually uses Cabal-1.24 based ./Setup.hs. So probably caused by some mismatch between cabal-install-3.2 and Cabal-1.24 based ./Setup interactions. I suspect the issues is fixed by sdist changes I made recently (cabal-install used ./Setup sdist --list-sources to get a list of files to watch for rebuild tracking).

Yet, I cannot be sure as I fail to reproduce your issue. The released 2.14.2 doesn't have autogen-modules, and the darcs get http://darcs.net/ version doesn't build with GHC-8.0

[__1] rejecting: base-4.9.1.0/installed-4.9.1.0 (conflict: darcs => base>=4.10
&& <4.13)

@bfrk
Copy link
Author

bfrk commented Apr 21, 2020

Thanks for your input! I actually found a solution, see below.

First of all, http://darcs.net/ is our current development version where we indeed require ghc>=8.2. I am currently working with the release-2.14 branch at http://darcs.net/releases/branch-2.14 in order to support building with ghc-8.8 and 8.10.

I could not reproduced the problem with branch-2.14 either, though. This prompted me to closely inspect my current changes. I tracked down the patch that breaks the build for ghc-8.0:

  * add autogen-modules: Version and other-modules: Version
--- old-branch-2.14/darcs.cabal 2020-04-21 11:28:15.411239259 +0200
+++ new-branch-2.14/darcs.cabal 2020-04-21 11:28:15.411239259 +0200
@@ -353,6 +353,7 @@
                       Darcs.Util.URL
                       Darcs.Util.Workaround
 
+    autogen-modules:  Version
     other-modules:    Version
                       Darcs.Util.Download.Curl
 
@@ -477,6 +478,9 @@
   main-is:          darcs.hs
   hs-source-dirs:   darcs
 
+  autogen-modules:  Version
+  other-modules:    Version
+
   if flag(optimize)
     ghc-options:    -O2
   else

Without this patch I can build with ghc-8.0.2, 8.2,2, 8.4.4, and 8.6.5. But then building with ghc >= 8.8 fails:

setup: Error: Could not find module: Version with any suffix:
["gc","chs","hsc","x","y","ly","cpphs","hs","lhs","hsig","lhsig"]. If the
module is autogenerated it should be added to 'autogen-modules'.

I now found that this failure is caused by adding the autogen-modules and other-modules to the darcs executable section. I did this because of the warning:

<no location info>: warning: [-Wmissing-home-modules]
    These modules are needed for compilation but not listed in your .cabal file's other-modules: 
        Version

It turns out that when I ignore this warning and add the autogen-modules: Version /only/ to the library section, then despite lots of cabal warnings everything seems to work with all ghc versions starting with ghc-8.0 up to ghc-8.10.1.

@phadej
Copy link
Collaborator

phadej commented Apr 21, 2020

Yes. This issue will be solved in next cabal major release (3.4), and in fact doesn't affect the installation, only local development.

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

No branches or pull requests

2 participants