What state is kept between running 'stack build' vs 'stack build --profile' or a similar change in ghc options?

If I run stack clean && stack build --profile , I get an executable that is slower than if I ran stack clean && stack build , this is normal and normal.

If I run stack clean && stack build --profile && stack build , then I get an executable file that is also slow and this persists until I run stack clean && stack build

I set the rebuild-ghc-options: true option to stack.yaml, but I either don’t understand how to use the stack correctly, or I use it incorrectly because I don’t have a clear mental model of what state the stack build starts. Does this explicitly affect future builds until I run stack clean , does that also affect dependencies? How can I make sure that when I create with the default settings, I get the same executable every time?

Edit: Let me be clear, I understand what happens mechanically, I understand that the stack build only repairs what needs to be rebuilt, the fact is that if I run stack build , then I want it to rebuild everything, what is required to build the release, and if I just built with profiling, which means rebuilding everything, let it be.

Edit 2: Well, I know that the stack has no idea about release builds or profiling, etc., that there is no fundamental difference, but --profile just changes the ghc flags? I suppose I'm asking why not rebuild-ghc-options do what it says on tin? If ghc options change, why not completely rebuild the project? What does this flag do?

+7
haskell haskell-stack
source share

No one has answered this question yet.

See related questions:

52
Profiling assemblies using the stack
37
What is the difference between Cabal and Stack?
eleven
What is the difference between `stack clean` and removing the `.stack-work` directory?
nine
How to configure IntelliJ to create Haskell projects with Stack?
6
Haskell-Stack: access violation error during build
3
Haskell-stack command with GHC parameter
3
Conditional Compilation in the Haskell Submodule
2
Haskell stack ignores -Wall -Werror cabal ghc-options flags when building
one
GHC default flags with Haskell Stack
0
Checking GHC Settings in a Stack Assembly

All Articles