You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
local options do not work with install on local packages (was: Run okay with profiling enabled, but installed exe has NO profiling enabled) #7297
Describe the bug
Can't install profiling-enabled exe with cabal 3.2.0.0, while direct running works correctly.
To Reproduce
Steps to reproduce the behavior:
$ cabal v2-run --enable-profiling --enable-executable-profiling exe:els -- +RTS --info
Resolving dependencies...
Up to date
[("GHC RTS", "YES")
,("GHC version", "8.8.3")
,("RTS way", "rts_thr_p")
,("Build platform", "x86_64-apple-darwin")
,("Build architecture", "x86_64")
,("Build OS", "darwin")
,("Build vendor", "apple")
,("Host platform", "x86_64-apple-darwin")
,("Host architecture", "x86_64")
,("Host OS", "darwin")
,("Host vendor", "apple")
,("Target platform", "x86_64-apple-darwin")
,("Target architecture", "x86_64")
,("Target OS", "darwin")
,("Target vendor", "apple")
,("Word size", "64")
,("Compiler unregisterised", "NO")
,("Tables next to code", "YES")
,("Flag -with-rtsopts", "-maxN31 -qg")
]
$ cabal v2-install --enable-profiling --overwrite-policy=always --enable-executable-profiling exe:els && els +RTS --info
Wrote tarball sdist to
...
Resolving dependencies...
Up to date
Copying 'els'
[("GHC RTS", "YES")
,("GHC version", "8.8.3")
,("RTS way", "rts_thr")
,("Build platform", "x86_64-apple-darwin")
,("Build architecture", "x86_64")
,("Build OS", "darwin")
,("Build vendor", "apple")
,("Host platform", "x86_64-apple-darwin")
,("Host architecture", "x86_64")
,("Host OS", "darwin")
,("Host vendor", "apple")
,("Target platform", "x86_64-apple-darwin")
,("Target architecture", "x86_64")
,("Target OS", "darwin")
,("Target vendor", "apple")
,("Word size", "64")
,("Compiler unregisterised", "NO")
,("Tables next to code", "YES")
,("Flag -with-rtsopts", "-maxN31 -qg")
]
$ els +RTS -p
els: the flag -p requires the program to be built with -prof
els:
els: Usage: <prog> <args> [+RTS <rtsopts> | -RTS <args>] ... --RTS <args>
els: ...
$
Expected behavior
The built executable can have +RTS -p enabled
System information
Operating system
macOS Mojave
cabal, ghc versions
$ cabal --version
cabal-install version 3.2.0.0
compiled using version 3.2.0.0 of the Cabal library
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.8.3
Additional context
Add any other context about the problem here.
In addition to the cmdl options being ignored (as with #5982), I also instrumented in the cabal.project.local for profiling, hope this add more information (or concerns) for the diagnostics.
$ cat cabal.project.local
profiling: True
profiling-detail: all-functions
optimization: 0
$ cat cabal.project
-- Please change Cabal project settings per your needs
-- FOLLOWING CONTENTS GONNA BE OVERWRITTEN BY EPM --
-- * this file should be:
-- /fw/m3cyue/edh-universe/cabal.project
packages:
./e-wrks/edh/lossless-decimal/lossless-decimal.cabal
./e-wrks/edh/elr/elr.cabal
./e-wrks/edh/host.hs/edh.cabal
./e-wrks/nedh/host.hs/nedh.cabal
./e-wrks/sedh/host.hs/sedh.cabal
./e-wrks/hasdim/host.hs/hasdim.cabal
./e-wrks/haskit/host.hs/haskit.cabal
./e-wrks/els/host.hs/els.cabal
$
I actually tripped over this too when working on purebred-mua/purebred#299. Also not explicitly profiling disabled. What I thought was interesting was that setting profiling: True in my cabal.project.local would not have an effect and neither would --enable-library-profiling. And by affect I mean, that under dist-newstyle I find profiling information, but in the installed package under ~/.cabal/store just the normal libraries.
Even the build progress does not show that profiling is enabled. If I build with:
In order, the following will be built (use -v for more details):
- purebred-0.1.0.0 (lib) (requires build)
- purebred-icu-0.1.0.0 (lib) (requires build)
Using the workaround linked from the mailing list, I get:
In order, the following will be built (use -v for more details):
- purebred-0.1.0.0 (lib) --enable-profiling (requires build)
- purebred-icu-0.1.0.0 (lib) --enable-profiling (requires build)
Perhaps it has something to do with multiple packages that even the command line arguments are not applied? My config that enabled profiling:
changed the title [-]Run okay with profiling enabled, but installed exe has NO profiling enabled[/-][+]local options do not work with install on local packages (was: Run okay with profiling enabled, but installed exe has NO profiling enabled)[/+]on Oct 9, 2021
I am starting to think that actual implementation of cabal install is giving us more problems than a raw build + copy bins would do. Another symptom: the popularization of the pattern cabal build && cp $(cabal list-bins myexec) somepath
Afaik the actual mechanism was implemented to make the code reuse the cabal install my.local.or.remote.tar variation. am I correct?
I've observed some quite interesting behaviour regarding this and related issues (#7236, #8909), which report that flags passed to install are ignored and not applied to the executable being built.
Namely, note the following
cabal install --enable-profiling # NOT profiled
cabal install <my-pkg> --enable-profiling # DOES profile
cabal install exe:<my-pkg> --enable-profiling # NOT profile
To add a bit to the discussion:
At a certain point (76670eb) we started applying local configuration (such as cli arguments and top level cabal.project fields) to the packages being installed. However, that patch only accounted for exact package names being specified as cabal install targets.
So
cabal install <my-pkg> --enable-profiling
would apply --enable-profiling to the package, but any other form of target like all:exes, no explicit target, exe:my-exe, ... would not get the local configuration.
What I've done is properly account for cabal install targets, and apply the local configuration to the appropriate packages (the limitation is that there is no way to apply configuration per-component, but that's fine. it means that building the exe with --enable-profiling will also build the profiled sources of a library sharing the package with said executable).
Activity
fendor commentedon Feb 23, 2021
Looks like a duplicate of #5982
complyue commentedon Feb 24, 2021
In addition to the cmdl options being ignored (as with #5982), I also instrumented in the
cabal.project.localfor profiling, hope this add more information (or concerns) for the diagnostics.complyue commentedon Feb 24, 2021
BTW, Albert Y.C. Lai suggests in a Cafe list mail that such a workaround should work, but seemingly not for my case.
https://mail.haskell.org/pipermail/haskell-cafe/2021-February/133453.html
amigalemming commentedon Mar 4, 2021
Do you have profiling disabled globally in
.cabal/config?complyue commentedon Mar 5, 2021
@amigalemming I'm not sure, here is the content:
Did I?
amigalemming commentedon Mar 5, 2021
romanofski commentedon Sep 28, 2021
I actually tripped over this too when working on purebred-mua/purebred#299. Also not explicitly profiling disabled. What I thought was interesting was that setting
profiling: Truein mycabal.project.localwould not have an effect and neither would--enable-library-profiling. And by affect I mean, that underdist-newstyleI find profiling information, but in the installed package under~/.cabal/storejust the normal libraries.Even the build progress does not show that
profilingis enabled. If I build with:I get:
Using the workaround linked from the mailing list, I get:
Perhaps it has something to do with multiple packages that even the command line arguments are not applied? My config that enabled profiling:
The one which does not enable does not have the
package *line.Mikolaj commentedon Sep 28, 2021
That's a long shot, but it may be related to #7236, where static compilation works with
cabal build, but is ignored withcabal install.fgaz commentedon Oct 9, 2021
I have an hypothesis for why this happens:
v2-installed packages!If that's true, a possible workaround could be to set the desired options per-package in cabal.project. I did not test this yet.
fgaz commentedon Oct 9, 2021
I did a few tests and it looks like my hypothesis is correct.
Workaround
for every local package
x, add this snippet to your cabal.projectThe same applies for other flags.
edit: oops, I just noticed that a similar workaround was posted above (though that will apply to all dependencies too)
I'll edit the title to reflect this.
This is very likely to be a part of what's happening in #7236
[-]Run okay with profiling enabled, but installed exe has NO profiling enabled[/-][+]local options do not work with install on local packages (was: Run okay with profiling enabled, but installed exe has NO profiling enabled)[/+]jneira commentedon Oct 9, 2021
I am starting to think that actual implementation of cabal install is giving us more problems than a raw build + copy bins would do. Another symptom: the popularization of the pattern
cabal build && cp $(cabal list-bins myexec) somepathAfaik the actual mechanism was implemented to make the code reuse the
cabal install my.local.or.remote.tarvariation. am I correct?19 remaining items
Apply project local options on install
alt-romes commentedon Feb 2, 2024
I've observed some quite interesting behaviour regarding this and related issues (#7236, #8909), which report that flags passed to install are ignored and not applied to the executable being built.
Namely, note the following
I'm investigating...
Apply local configuration to install targets
alt-romes commentedon Feb 5, 2024
Fix in #9697.
alt-romes commentedon Feb 5, 2024
To add a bit to the discussion:
At a certain point (76670eb) we started applying local configuration (such as cli arguments and top level cabal.project fields) to the packages being installed. However, that patch only accounted for exact package names being specified as
cabal installtargets.So
would apply
--enable-profilingto the package, but any other form of target likeall:exes, no explicit target,exe:my-exe, ... would not get the local configuration.What I've done is properly account for
cabal installtargets, and apply the local configuration to the appropriate packages (the limitation is that there is no way to apply configuration per-component, but that's fine. it means that building the exe with --enable-profiling will also build the profiled sources of a library sharing the package with said executable).Apply local configuration to install targets
Apply local configuration to install targets
Apply local configuration to install targets
Apply local configuration to install targets
Apply local configuration to install targets
Apply local configuration to install targets
Apply local configuration to install targets
Apply local configuration to install targets