How to use “-ddump-minimal-imports” with stack

2019-03-28 16:55发布

问题:

I am such a big fan of stack, that I've removed any independent cabal and ghc executables completely from my machine (letting stack install whatever it needs in its own mysterious ~/.stack/ directory)....

However, it looks like some flags aren't working properly under stack. For instance, I want to use -ddump-minimal-imports. In cabal this would be

cabal build --ghc-option=-ddump-minimal-imports

The obvious translation would be

stack build --ghc-options -ddump-minimal-imports

This runs, but produces nothing but the executable (as far as I can tell, at least.... Perhaps the output is somewhere in the mysterious ~/.stack dir).

Is there a way to do this?

回答1:

I just tried this, using stack build --ghc-options=-ddump-minimal-imports, and it produced output files in ./.stack-work/dist/x86_64-osx/Cabal-1.22.4.0/build/, e.g.:

$ stack clean

$ stack build --ghc-options=-ddump-minimal-imports
stack-0.1.5.0: configure
Configuring stack-0.1.5.0...
stack-0.1.5.0: build
Preprocessing library stack-0.1.5.0...
[ 1 of 69] Compiling Data.Set.Monad   ( src/Data/Set/Monad.hs, .stack-work/dist/x86_64-osx/Cabal-1.22.4.0/build/Data/Set/Monad.o )
[ 2 of 69] Compiling Data.Attoparsec.Combinators ( src/Data/Attoparsec/Combinators.hs, .stack-work/dist/x86_64-osx/Cabal-1.22.4.0/build/Data/Attoparsec/Combinators.o )
[ 3 of 69] Compiling Network.HTTP.Download.Verified ( src/Network/HTTP/Download/Verified.hs, .stack-work/dist/x86_64-osx/Cabal-1.22.4.0/build/Network/HTTP/Download/Verified.o )
^Cuser interrupt

$ find . -name '*imports*'
./.stack-work/dist/x86_64-osx/Cabal-1.22.4.0/build/Data.Attoparsec.Combinators.imports
./.stack-work/dist/x86_64-osx/Cabal-1.22.4.0/build/Data.Set.Monad.imports
./.stack-work/dist/x86_64-osx/Cabal-1.22.4.0/build/Network.HTTP.Download.Verified.imports