当我运行时cabal build,cabal 会经历两次编译过程。由于编译已经花费了相对较长的时间(约 60 秒),这开始妨碍我的工作流程。
这是我的 cabal 文件中的 ghc 选项:
GHC-Options: -O3 -rtsopts -funbox-strict-fields -threaded -Wall -feager-blackholing -fllvm -optlo-O3
if flag(Eventlog)
GHC-Options: -O3 -rtsopts -funbox-strict-fields -threaded -eventlog -Wall
if flag(Profiling)
ghc-prof-options: -O3 -auto-all
GHC-Options: -O3 -rtsopts -funbox-strict-fields -threaded -fprof-auto -Wall
if flag(Dump)
GHC-options: -O3 -funbox-strict-fields -Wall -ddump-simpl -dsuppress-module-prefixes -dsuppress-uniques -ddump-to-file
Run Code Online (Sandbox Code Playgroud)
输出cabal build看起来完全正常,除了最后一个模块第一次完成编译后编译会立即重新启动。
[ 1 of 13] Compiling HaObj ( src/HaObj.hs, nothing )
[ 2 of 13] Compiling Surfaces ( src/Surfaces.hs, nothing )
[ 3 of 13] Compiling Materials ( src/Materials.hs, nothing )
[ 4 of 13] Compiling Geometry3 ( src/Geometry3.hs, nothing )
[ 5 of 13] Compiling Triangles ( src/Triangles.hs, nothing )
[ 6 of 13] Compiling BoundingVolumeHierarchy ( src/BoundingVolumeHierarchy.hs, nothing )
[ 7 of 13] Compiling RayTracer ( src/RayTracer.hs, nothing )
[ 8 of 13] Compiling BenchmarkScene5 ( src/BenchmarkScene5.hs, nothing )
[ 9 of 13] Compiling BenchmarkScene4 ( src/BenchmarkScene4.hs, nothing )
[10 of 13] Compiling BenchmarkScene3 ( src/BenchmarkScene3.hs, nothing )
[11 of 13] Compiling BenchmarkScene2 ( src/BenchmarkScene2.hs, nothing )
[12 of 13] Compiling BenchmarkScene ( src/BenchmarkScene.hs, nothing )
[13 of 13] Compiling Main ( src/Main.hs, nothing )
[ 1 of 13] Compiling HaObj ( src/HaObj.hs, nothing )
[ 2 of 13] Compiling Surfaces ( src/Surfaces.hs, nothing )
[ 3 of 13] Compiling Materials ( src/Materials.hs, nothing )
[ 4 of 13] Compiling Geometry3 ( src/Geometry3.hs, nothing )
[ 5 of 13] Compiling Triangles ( src/Triangles.hs, nothing )
[ 6 of 13] Compiling BoundingVolumeHierarchy ( src/BoundingVolumeHierarchy.hs, nothing )
[ 7 of 13] Compiling RayTracer ( src/RayTracer.hs, nothing )
[ 8 of 13] Compiling BenchmarkScene5 ( src/BenchmarkScene5.hs, nothing )
[ 9 of 13] Compiling BenchmarkScene4 ( src/BenchmarkScene4.hs, nothing )
[10 of 13] Compiling BenchmarkScene3 ( src/BenchmarkScene3.hs, nothing )
[11 of 13] Compiling BenchmarkScene2 ( src/BenchmarkScene2.hs, nothing )
[12 of 13] Compiling BenchmarkScene ( src/BenchmarkScene.hs, nothing )
[13 of 13] Compiling Main ( src/Main.hs, nothing )
Run Code Online (Sandbox Code Playgroud)
我使用的是 Ubuntu 14.04、GHC 7.10.1、cabal-install 1.22.4、cabal 库 1.22.3。如果您有兴趣尝试复制,这里是repo的链接。我建议运行cabal build --ghc-options="-fno-code"以将构建时间减少到几秒钟。
编辑:Zeta 指出这是因为我的 cabal 文件中有一个可执行文件ray-tracer和一个基准测试bench。有没有办法只建造其中一个?我试过了,cabal build ray-tracer但这也建立了两个目标。我也试过了cabal configure --disable-benchmarks。有没有办法在不重组 cabal 文件结构的情况下选择性地只构建一个目标?