haskell / cabal

Official upstream development repository for Cabal and cabal-install
https://haskell.org/cabal
Other
1.59k stars 686 forks source link

--library-profiling-detail seems a bit missleading. #8530

Open AndreasPK opened 1 year ago

AndreasPK commented 1 year ago

Describe the bug

It seems the flag only affects "local" packages. For "global" packages the flag is either ignored when checking if we need to rebuild or completely.

To Reproduce Steps to reproduce the behavior:

cabal unpack hasktags
cd hasktags

# Build with library-profiling set to auto
cabal build --enable-profiling --enable-executable-profiling --enable-library-profiling --library-profiling-detail=auto

... # Builds libs +executable

# Change library profiling detail
cabal build --enable-profiling --enable-executable-profiling --enable-library-profiling --library-profiling-detail=none

<Only hasktags but not the dependencies are rebuild>

Expected behavior

I would have expected this to work similar to ghc-options where it causes packages to be rebuilt with the appropriate profiling flags set.

System information

Additional context Add any other context about the problem here.

Mikolaj commented 1 year ago

Indeed, it seems better to me if this completely mimics passing ghc-options, unless there is a strong reason not to. Does anybody have a use case where it's better if only local packages are affected (and others presumably require an option in a project file)? I suppose this may be handy if somebody experiments with profiling detail only for the local package? How did it work in v1?

jneira commented 1 year ago

https://cabal.readthedocs.io/en/stable/cabal-project.html#cfg-field-profiling claims it will ensure the selected packages (local ones if set as cli option or top level cabal.project field) and their transitive dependencies will be build with profiling enable. Don't mention anything about rebuilding them or if changing detail should rebuild (although it seems the sensible behaviour)

I would check the behaviour of

package *
  library-profiling: true
  executable-profiling: true
  library-profiling-detail: auto

changing the detail to see it they make any difference

mpickering commented 1 year ago

I think it's confusing that you can write

profiling: true
profiling-detail:none

and this will result in everything being built with profiling enable but profiling-detail is only applied to local packages.

It's unfortunate that if someone is prudent enough to try to attempt to stop GHC inserting cost centres that cabal will ignore this intent and insert lots anyway.