Haskell Stack's executable profiling and ghc options fails to build - haskell

I'm trying to debug performance problems in a Haskell project, but I can't get profiling to be compiled in so I can use it through +RTS -p command line arguments.
The options for GHC in my .cabal file are:
ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -Werror
Here's me attempting to build it:
stack build --executable-profiling --library-profiling --ghc-options="-fprof-auto -rtsopts"
Which results in:
While constructing the BuildPlan the following exceptions were encountered:
-- Failure when adding dependencies:
base: needed (>=2 && <5), not present in build plan (latest applicable is 4.9.0.0)
mtl: needed (>=2.1 && <2.3), couldn't resolve its dependencies
random: needed (-any), couldn't resolve its dependencies
transformers: needed (>=0.3 && <0.6), couldn't resolve its dependencies
transformers-compat: needed (>=0.4 && <0.6), couldn't resolve its dependencies
needed for package: MonadRandom-0.4.2.3
-- Failure when adding dependencies:
base: needed (>=4 && <5), not present in build plan (latest applicable is 4.9.0.0)
stm: needed (>=2.0 && <2.5), couldn't resolve its dependencies
transformers: needed (>=0.2 && <0.6), couldn't resolve its dependencies
needed for package: StateVar-1.1.0.4
<snipped large log>
Even trying with just stack build --executable-profiling results in the same error.
For reference, my library dependencies are:
build-depends: base >= 4.7 && < 5
, aeson
, servant
, servant-server
, wai
, warp
, either
, bytestring
, transformers
, postgresql-simple
, amazonka
, amazonka-sqs
, lens
, text
, time
, resource-pool
How can I resolve this so I can compile my project with stack and have profiling built in for use with +RTS -p?

What does "stack exec -- which ghc" say? If your ghc is installed globally, it could be that it lacks profiling libraries. If so, "stack setup --no-system-ghc" + "stack build --no-system-ghc"
What is your stack.yaml configuration? If you've set a resolver of "ghc-*", it won't work unless you specify the versions of all your dependencies in "extra-deps". Usually you'll want to use a stackage snapshot - https://www.stackage.org/

Related

Cannot build project with z3-haskell on windows 10

I want to build the haskell bindings for z3 in a Cabal project, the following is the minimum (faulty) example:
Using a project initialized by cabal init:
test/
- Main.hs
- Setup.hs
- CHANGELOG.md
- test.cabal
With modified test.cabal:
cabal-version: 3.0
name: z3-test
version: 0.1.0.0
extra-source-files: CHANGELOG.md
executable test
main-is: Main.hs
build-depends: base >=4.14 && <4.15
, z3 ^>=408.2
default-language: Haskell2010
Z3 binaries are located at C:\z3-4.8.5-x86-win.
Z3-bindings are installed:
cabal v1-install z3 --extra-lib-dirs=C:/z3-4.8.5-x64-win/bin --extra-include-dirs=C:/z3-4.8.5-x64-win/include -v3
All the requested packages are already installed:
z3-408.2
Use --reinstall if you want to reinstall anyway.
Now building the project using:
cabal v2-build --extra-lib-dirs=C:/z3-4.8.5-x64-win/bin --extra-include-dirs=C:/z3-4.8.5-x64-win/include -v3
Results in the error:
Build profile: -w ghc-8.10.2 -O1
In order, the following will be built (use -v for more details):
- z3-408.2 (lib) (requires build)
- z3-test-0.1.0.0 (exe:test) (first run)
Starting z3-408.2 (lib)
Failed to build z3-408.2. The failure occurred during the configure step.
Build log (
C:\cabal\logs\ghc-8.10.2\z3-408.2-1722a25655334afbca91ac935f14ff0d20ccf8c4.log
):
Configuring library for z3-408.2..
cabal.exe: Missing dependency on a foreign library:
* Missing (or bad) header file: z3.h
* Missing (or bad) C library: z3
This problem can usually be solved by installing the system package that
provides this library (you may need the "-dev" version). If the library is
already installed but in a non-standard location then you can use the flags
--extra-include-dirs= and --extra-lib-dirs= to specify where it is.If the
library file does exist, it may contain errors that are caught by the C
compiler at the preprocessing stage. In this case you can re-run configure
with the verbosity flag -v3 to see the error messages.
If the header file does exist, it may contain errors that are caught by the C
compiler at the preprocessing stage. In this case you can re-run configure
with the verbosity flag -v3 to see the error messages.
cabal.exe: Failed to build z3-408.2 (which is required by exe:test from
z3-test-0.1.0.0). See the build log above for details.
How can I build a project with the z3 bindings?
Note that:
GHC version = 8.10.2
Cabal version = 3.2.0.0
I can only use cabal
Using cabal install ... or cabal v2-install ... results in Cannot build .. z3 because none of the components are available to build:

haskell stack exception missing dependencies

I want to add the bound library to my package dependencies;
The project is completely fresh initialized with stack new.
The entry in the cabal file looks like this:
executable DependendLambda-exe
hs-source-dirs: app
main-is: Main.hs
ghc-options: -threaded -rtsopts -with-rtsopts=-N
build-depends: base
, DependendLambda
, bound
default-language: Haskell2010
I get the following error message:
While constructing the build plan, the following exceptions were encountered:
In the dependencies for DependendLambda-0.1.0.0:
bound must match -any, but the stack configuration has no specified
version (latest applicable is 1.0.7)
Recommended action:
try adding the following to your extra-deps in /home/MyProject/stack.yaml:
- bound-1.0.7
You may also want to try the 'stack solver' command
Plan construction failed.
Warning: build failed, but optimistically launching GHCi anyway
The following GHC options are incompatible with GHCi and have not been passed to it: -threaded
Using main module: 1. Package `DependendLambda' component exe:DependendLambda-exe with main-is file: /home/MyProject/app/Main.hs
Configuring GHCi with the following packages: DependendLambda
GHCi, version 8.0.1: http://www.haskell.org/ghc/ :? for help
<command line>: cannot satisfy -package bound
(use -v for more information)
When I add the dependency to extra-deps it is still failing:
While constructing the build plan, the following exceptions were encountered:
In the dependencies for bound-1.0.7:
binary-0.8.3.0 must match >=0.5 && <0.8 (latest applicable is 0.7.6.1)
comonad-5 must match >=3 && <5 (latest applicable is 4.3)
transformers-0.5.2.0 must match >=0.2 && <0.5 (latest applicable is 0.4.3.0)
needed due to DependendLambda-0.1.0.0 -> bound-1.0.7
Plan construction failed.
Warning: build failed, but optimistically launching GHCi anyway
The following GHC options are incompatible with GHCi and have not been passed to it: -threaded
Using main module: 1. Package `DependendLambda' component
exe:DependendLambda-exe with main-is file: /home/MyProject/app/Main.hs
Configuring GHCi with the following packages: DependendLambda
GHCi, version 8.0.1: http://www.haskell.org/ghc/ :? for help
<command line>: cannot satisfy -package bound-1.0.7
(use -v for more information)
The stack solver command didn't help either ... what am I missing?
Thanks for your help!

Integrating Haste into Stack tool chain

I am using Haskell Stack for a project and I want to include Haste it compile client side logic. I like the fact that Stack abstracts away the different build and install issues among environments and if it builds on my machine, it will build on someone else's.
How do I integrate Haste into the Stack tool chain? Working out one time setup is fine, but I don't want to have to recreate the whole tool chain every time the code moves to a new system.
This should work, but take that with a grain of salt as I'm having extra issues due to this known bug. Make sure your .cabal file has the right dependencies, especially the if impl(haste) .. part (see this). Seems like most of the dependencies for Haste (and since Haste uses GHC 7.10.3 as of today) work with lts-6.14, so I used that as resolver.
haste-project.cabal
name: haste-project
version: 0.1.0.0
category: Web
build-type: Simple
cabal-version: >=1.10
executable haste-project-exe
hs-source-dirs: app
main-is: Main.hs
build-depends: base >= 4.8 && < 4.9
if impl(haste)
build-depends: haste-lib >= 0.5 && < 0.6
else
build-depends: haste-compiler >= 0.5 && < 0.6
default-language: Haskell2010
stack.yaml
extra-deps:
- HTTP-4000.2.23
- ghc-simple-0.3
- haste-compiler-0.5.4.2
- shellmate-0.2.3
resolver: lts-6.14
Then, from the same directory, you can now proceed with the usual setup instructions for Haste, but with Stack complements of the Cabal commands:
$ stack build
$ stack install haste-compiler # installs haste-boot, haste-cat, haste-pkg, and hastec
$ stack exec haste-boot # setup Haste (where I get the bug I mentioned above)
Then, you should be able to run all the usual commands, but prefixed with stack exec --. For example
$ stack exec -- hastec -O2 -fglasgow-exts myprog.hs

build error on dependencies when using cabal

I am building a small project, and when cabal attempts to install MissingH 1.3.0, it runs into a compiler error (name clash):
src/System/IO/HVFS.hs:287:23:
Ambiguous occurrence ‘isSymbolicLink’
It could refer to either ‘System.IO.PlafCompat.isSymbolicLink’,
imported from ‘System.IO.PlafCompat’ at src/System/IO/HVFS.hs:60:1-27
(and originally defined in ‘unix-2.7.2.0:System.Posix.Files.Common’)
or ‘System.Directory.isSymbolicLink’,
imported from ‘System.Directory’ at src/System/IO/HVFS.hs:63:1-23
cabal: Error: some packages failed to install:
MissingH-1.3.0.1 failed during the building phase.
The thing that puzzles me is that I'd have thought the versions in the .cabal file either produce a working build, or a contradiction involving the versions required, but not a build error. I've verified I can build MissingH on its own, but some other packages I depend on seem to cause this problem (here's the other packages I'm naming the .cabal file, in case that helps reproduce the problem).
build-depends: base >=4.7 && <4.8
, groom==0.1.2
, containers>=0.5.7
, sexp==0.7
, bytestring==0.10.6.0
, hashmap==1.3.0.1
, MissingH==1.3.0.1
Any pointers?

Dependency issues running "cabal test" for Haskell

I'm running my first "cabal test" for Haskell, but I get the error:
Package has never been configured. Configuring with default flags. If this
fails, please run configure manually.
Resolving dependencies...
Configuring sample-0.1.0.0...
cabal: At least the following dependencies are missing:
base ==4.7.*
sampel.cabal:
-- Initial sample.cabal generated by cabal init. For further
-- documentation, see http://haskell.org/cabal/users-guide/
name: sample
version: 0.1.0.0
build-type: Simple
cabal-version: >=1.10
executable SampleTest
main-is: SampleTest.hs
build-depends: base >= 4.7 && <4.8, HUnit >=1.2 && <1.3
hs-source-dirs: test, src
default-language: Haskell2010
Any help appreciated.
Versions of GHC come bundled with versions of base. GHC 7.10.2 uses base 4.8.1.0.
Your cabal must be using a slightly out of date template....
You should either change the range of acceptable base version (as you did in your comment above), or use a different version of GHC.

Resources