Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why cabal install recompiles what's been build?

Tags:

haskell

cabal

Why when I do cabal build and then cabal install, cabal recompiles things twice. (I'm using a sandbox).

Update

To clarify, I'm asking when after doing cabal build (which I understand compiles 2 version of my files), why doing then cabal install compile things again. Is that not the purpose of build to build ?

Update2

Ok it seems to compile in two different directories dist and dist/sandbox-... what is the difference between both ?

> 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 ...
like image 851
mb14 Avatar asked Dec 03 '14 16:12

mb14


1 Answers

During a cabal build it creates two versions of the compiled code - one with profiling and one without.

The difference in the command line arguments is very slight and can easily be missed. In the following output the first is compiled with -O -j2 and the second is compiled with -O -prof -j2. Also the output files have different suffixes - .o versus .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...
like image 178
ErikR Avatar answered Oct 25 '22 09:10

ErikR