为什么当我执行cabal build
然后cabal install
时,cabal会重新编译两次。
(我正在使用沙箱)。
为了澄清,我问在做cabal build
之后(我理解编译我的文件的2个版本),为什么然后再做cabal install
编译。这不是build
构建的目的吗?
好吧好像在两个不同的目录dist
和dist/sandbox-...
中编译
两者有什么区别?
> cabal build
Building cache-0.1.0.0...
Preprocessing executable 'cache' for cache-0.1.0.0...
[1 of 1] Compiling Main ( main.hs, dist/build/cache/cache-tmp/Main.o )
Linking dist/build/cache/cache ...
> cabal install
Warning: The package list for 'hackage.haskell.org' is 60 days old.
Run 'cabal update' to get the latest list of available packages.
Resolving dependencies...
Configuring cache-0.1.0.0...
Warning: The 'license-file' field refers to the file 'LICENSE' which does not exist.
Building cache-0.1.0.0...
Preprocessing executable 'cache' for cache-0.1.0.0...
[1 of 1] Compiling Main ( main.hs, dist/dist-sandbox-db136cca/build/cache/cache-tmp/Main.o )
Linking dist/dist-sandbox-db136cca/build/cache/cache ...
答案 0 :(得分:2)
在cabal build
期间,它创建了两个版本的编译代码 - 一个带有分析,一个没有。
命令行参数的差异非常小,很容易被遗漏。在下面的输出中,第一个用-O -j2
编译,第二个用-O -prof -j2
编译。此外,输出文件具有不同的后缀 - .o
与.p_o
:
Preprocessing library split-0.2.2...
Building library...
creating dist/build
/usr/bin/ghc --make -fbuilding-cabal-package -O -j2 -static -dynamic-too -dynosuf dyn_o -dynhisuf dyn_hi -outputdir dist/build -odir dist/build -hidir dist/build -stubdir dist/build -i -idist/build -isrc -idist/build/autogen -Idist/build/autogen -Idist/build -optP-include -optPdist/build/autogen/cabal_macros.h -package-name split-0.2.2 -hide-all-packages -no-user-package-db -package-db /Users/erantapaa/try/split-0.2.2/.cabal-sandbox/x86_64-osx-ghc-7.8.3-packages.conf.d -package-db dist/package.conf.inplace -package-id base-4.7.0.1-df210ede1eb79477fef5662549c32927 -XHaskell2010 Data.List.Split Data.List.Split.Internals -Wall
[1 of 2] Compiling Data.List.Split.Internals ( src/Data/List/Split/Internals.hs, dist/build/Data/List/Split/Internals.o )
[2 of 2] Compiling Data.List.Split ( src/Data/List/Split.hs, dist/build/Data/List/Split.o )
/usr/bin/ghc --make -fbuilding-cabal-package -O -prof -j2 -osuf p_o -hisuf p_hi -outputdir dist/build -odir dist/build -hidir dist/build -stubdir dist/build -i -idist/build -isrc -idist/build/autogen -Idist/build/autogen -Idist/build -optP-include -optPdist/build/autogen/cabal_macros.h -package-name split-0.2.2 -hide-all-packages -no-user-package-db -package-db /Users/erantapaa/try/split-0.2.2/.cabal-sandbox/x86_64-osx-ghc-7.8.3-packages.conf.d -package-db dist/package.conf.inplace -package-id base-4.7.0.1-df210ede1eb79477fef5662549c32927 -XHaskell2010 Data.List.Split Data.List.Split.Internals -Wall
[1 of 2] Compiling Data.List.Split.Internals ( src/Data/List/Split/Internals.hs, dist/build/Data/List/Split/Internals.p_o )
[2 of 2] Compiling Data.List.Split ( src/Data/List/Split.hs, dist/build/Data/List/Split.p_o )
Linking...