ekmett / linear

Low-dimensional linear algebra primitives for Haskell.
http://hackage.haskell.org/package/linear
Other
200 stars 50 forks source link

Can’t build doctests using stack #89

Closed jtojnar closed 9 years ago

jtojnar commented 9 years ago
linear-1.20.1: test (suite: doctests)
Progress: 1/2
<command-line>:8:0:
     fatal error: cabal_macros.h: No such file or directory
compilation terminated.
doctests: doctests: phase `C pre-processor' failed (exitcode = 1)
Test suite failure for package linear-1.20.1
    doctests:  exited with: ExitFailure 1
Logs printed to console

It seems to start working when I remove the optP arguments but I am not sure if this is a correct way to fix this.I can’t test it with cabal sandbox due to "version of Cabal has changed" bug.

diff --git a/.ghci b/.ghci
index 231eb17..1295d5a 100644
--- a/.ghci
+++ b/.ghci
@@ -1 +1 @@
-:set -isrc -idist/build/autogen -optP-include -optPdist/build/autogen/cabal_macros.h
+:set -isrc -idist/build/autogen
diff --git a/linear.cabal b/linear.cabal
index bad5e48..298683f 100644
--- a/linear.cabal
+++ b/linear.cabal
@@ -98,7 +98,7 @@ test-suite doctests
   build-depends:
     base,
     directory >= 1.0 && < 1.3,
-    doctest   >= 0.8 && < 0.10,
+    doctest   >= 0.8 && < 0.11,
     filepath  >= 1.3 && < 1.5,
     lens,
     simple-reflect >= 0.3.1
diff --git a/tests/doctests.hs b/tests/doctests.hs
index 6ceefc5..551d1f7 100644
--- a/tests/doctests.hs
+++ b/tests/doctests.hs
@@ -12,8 +12,6 @@ main :: IO ()
 main = getSources >>= \sources -> doctest $
     "-isrc"
   : "-idist/build/autogen"
-  : "-optP-include"
-  : "-optPdist/build/autogen/cabal_macros.h"
   : "-hide-all-packages"
   : map ("-package="++) deps ++ sources
ekmett commented 9 years ago

We should be able to make this change. I don't use this sort of hack anymore anywhere else in my packages.

glguy commented 9 years ago

I my experience problems with cabal versions changed can be resolved by cleaning out ~/.cabal/setup-exe-cache/

jtojnar commented 9 years ago

@glguy I tried nuking the ~/.cabal, .cabal-sandbox and ~/.ghc directories but no luck. According to someone on /r/haskell[1] it should be fixed in cabal 1.24 though.

jtojnar commented 9 years ago

@ekmett should I make a pull request then or are would you rather switch to Simple build-type completely?

glguy commented 9 years ago

Using the following stack.yaml I was able to successfully execute stack test. This was after updating the doctest dependency bound. I don't know if that was related.

resolver: ghc-7.10

flags:
  text:
    integer-simple: false
extra-deps:
- HUnit-1.3.0.0
- StateVar-1.1.0.1
- adjunctions-4.2.2
- ansi-terminal-0.6.2.3
- ansi-wl-pprint-0.6.7.3
- base-orphans-0.4.4
- bifunctors-5
- bytes-0.15.0.1
- cereal-0.4.1.1
- comonad-4.2.7.2
- contravariant-1.3.3
- distributive-0.4.4
- doctest-0.10.1
- exceptions-0.8.0.2
- extensible-exceptions-0.1.1.4
- free-4.12.1
- ghc-paths-0.1.0.9
- hashable-1.2.3.3
- hostname-1.0
- kan-extensions-4.2.3
- lens-4.13
- mtl-2.2.1
- nats-1
- old-locale-1.0.0.7
- parallel-3.2.0.6
- prelude-extras-0.4.0.2
- primitive-0.6
- profunctors-5.1.1
- random-1.1
- reflection-2.1
- regex-base-0.93.2
- regex-posix-0.95.2
- semigroupoids-5.0.0.4
- semigroups-0.17.0.1
- simple-reflect-0.3.2
- stm-2.4.4
- syb-0.5.1
- tagged-0.8.1
- test-framework-0.8.1.1
- test-framework-hunit-0.3.0.2
- text-1.2.1.3
- transformers-compat-0.4.0.4
- unordered-containers-0.2.5.1
- vector-0.11.0.0
- void-0.7.1
- xml-1.3.14
jtojnar commented 9 years ago

@glguy you can also use to make things simpler

flags:
  linear:
    template-haskell: true
packages:
- '.'
extra-deps: []
resolver: lts-3.5
glguy commented 9 years ago

I'm not so much worried about the stack.yaml as figuring out what the issue is that needs to be resolved.

jtojnar commented 9 years ago

Maybe it is related to this issue? https://github.com/haskell/cabal/issues/1434

I tried rebuilding with your stack.yaml and got the same problem until I removed the optP arguments.

glguy commented 9 years ago

This reminds me of an issue we had on lens. Perhaps your version of cpphs is out of date?

https://github.com/ekmett/lens/issues/415

glguy commented 9 years ago

Ah, I see. It stopped working for me once I removed the /dist directory that cabal left behind

ekmett commented 9 years ago

We can't switch to a Simple build plan. Otherwise when multiple versions of a package are installed in the users package database then the doctests don't work for them. Not everyone uses stack.

We can remove the

  : "-optP-include"
  : "-optPdist/build/autogen/cabal_macros.h"

lines however.

ekmett commented 9 years ago

Actually I don't think that we can remove them. We may need to modify the Build_doctests thing to contain the actual build dir, rather than assume dist, then use that in tests/doctests.hsc

ekmett commented 9 years ago

Leaving this open until I can confirm that that fix works.

jtojnar commented 9 years ago

@ekmett tests now work but you still can’t run stack ghci.

ekmett commented 9 years ago

What goes wrong with stack ghci?

ekmett commented 9 years ago

I dropped the .ghci file in HEAD. Setting up stack locally for a test, but you can give it a shot off HEAD directly if you like.

jtojnar commented 9 years ago

It seems to work now. Previously the same error could be seen.

Configuring GHCi with the following packages: linear
GHCi, version 7.10.2: http://www.haskell.org/ghc/  :? for help

<command-line>:10:0:
     fatal error: dist/build/autogen/cabal_macros.h: No such file or directory
compilation terminated.
phase `C pre-processor' failed (exitcode = 1)