-
Notifications
You must be signed in to change notification settings - Fork 847
Description
To see the problematic behavior, you can run the following in the wai repo (though other multi-package projects with inter-dependencies will work as well):
stack build --ghc-options=-O0 wai wai-extra
stack build --ghc-options=-O0 wai-extra
The first time, it will be wai, wai-logger, and wai-extra (as expected). The second call will result in all three packages being unregistered and rebuilt, even though it seems obvious that we only want to rebuild wai-extra. The reason is that in the second build, wai is no longer a wanted dependency, and therefore the extra GHC options do not apply to it. Because of that, the installed config options don't match the current config options, and therefore a reconfigure and rebuild is required.
I don't see an obvious better way to do things, unfortunately, without baking in special logic for different flags. The reason is this: consider the first build did not pass in -O0, and the second one did. We probably don't want to recompile wai just to disable optimizations.
One possibility is to mark some flags as "these don't make an installed package dirty", such as -O0. Even that is a bit problematic, since we now have some strange state following our build around such that stack build wai-extra will have different results depending on what sequence of commands was run previously.
I'm leaning towards saying that this is simply a corner case that stack will require a recompile for consistency, but I'm open to other ideas.