-
Notifications
You must be signed in to change notification settings - Fork 710
Confusing -O1 in build profile #6221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It means that the local packages in the project are configured with |
Ah, thanks! In my case there weren't any other local packages that could be configured with I first noticed it while benchmarking where it caused me much doubt about the validity of the numbers I was seeing. What's the motivation for outputting this default(?) setting, especially when it doesn't apply / is overridden? |
The motivation is that we consider `ghc-options: -O2` (any -O flag) to be at the very least questionable practice.
In `cabal.project` you can have
optimization: 2
for all local, or per package (also non-local)
The core idea is that optimizations could be configured for all packages in an uniform way, without investigating if there’s some `dev`, `devel` or `fast` flag.
Also as a bonus, changing optimization level (also possible from command line), won’t cause full recompilation (or worse: mixed-level compilation) as build products are kept separate.
… On 1 Sep 2019, at 7.58, Simon Jakobi ***@***.***> wrote:
Ah, thanks! In my case there weren't any other local packages that could be configured with -O1.
I first noticed it while benchmarking where it caused me much doubt about the validity of the numbers I was seeing.
What's the motivation for outputting this default(?) setting, especially when it doesn't apply / is overridden?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Interesting! Was there some kind of discussion that I could read? Configuring the optimization level like this seems useful. Reporting |
I guess I'm not following the back and forth here.
I have a project where I have a
and a .cabal file like:
So I'm not sure what "Build profile" is supposed to mean, and not sure if what it's reporting is correct, and not sure if I'm using my Related to #5353 |
The problem is the same unresolved one as with profiling. Prof and non-prof libraries can depend on each others, opt and non-opt libraries can depend on each other. The prof discussion needs input from @dcoutts as iirc he had some ideas.
… On 22. Jan 2020, at 2.34, Brandon Simmons ***@***.***> wrote:
I guess I'm not following the back and forth here.
It means that the local packages in the project are configured with -O1.
I have a project where I have a cabal.project.local that looks like:
package our-project
optimization: 0
documentation: false
and a .cabal file like:
name: our-project
library
...
executable our-project
...
When I do a new-build I see Build profile: -w ghc-8.6.5 -O1
If I move optimization: 0 to the top-level I see ``Build profile: -w ghc-8.6.5 -O0`
In both cases it looks like the library and executable in my project are built without optimizations (as intended)
So I'm not sure what "Build profile" is supposed to mean, and not sure if what it's reporting is correct, and not sure if I'm using my cabal.project.local file correctly
Related to #5353
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
FYI I have also just experienced puzzlement at this. |
I think it's the "global" optimization level, ie. the top-level |
and what about include that useful info in the message, something like |
@sjakobi @jberryman @tomjaguarpaw is @jneira's proposal enough to clarify the meaning of that message? If not, any suggestions? |
Well, it would certainly be better (and give something more substantial to Duck Duck Go for when confused). |
I don't have a better proposal. However I just noticed that the term "build profile" doesn't appear to be documented. My suggestion would be to fix that, or alternatively to use a different term if that one is better established and documented. |
It sounds like in the message "Build profile: -w ghc-8.6.5 -O1" the "-O1" will often be meaningless, one of many global defaults which might be overridden in sections of the cabal.projec(.local) or .cabal files. I guess I'd suggest deleting the message unless someone can explain how it might be helpful info for users? |
I agree. It would be much more helpful to see the actual options that each package is being built with, but failing that seeing nothing at all is probably more helpful than seeing something that is misleading. |
Well the ghc version is useful imo and the optimization level should reflect the top level config, taking in account the global config and several cabal.project.* |
There is a reason why that specific info is shown though. "build profiles" have separate caches, so switching between --disable-optimization and --enable-optimization should cause no recompilation. Same for -w. See #3343 for more info. We should check if this is mentioned in the docs. |
I just reminded myself that top-level things in cabal.project apply to all local packages, while a I'm kind of stumped on a good short-term solution. Maybe a message saying whether we are using an existing cached build profile directory would be just as useful? Long term I wonder if what we want is:
|
I think a very easy "fix" would be to say instead of "Build profile" the slightly more verbose "Build profile (subject to package-level overrides" |
That's a totally valid fix. |
While this is probably an improvement, it's not ideal unless there's a diagnostic message later on that some of the mentioned parameters were, in fact, overridden. Also, GHC version is impossible to override, so it's not completely true either. |
Cabal-3.8.1.0. Could you explain why Cabal reports Leaving alone whether P.S. Thankfully, Cabal reports the GHC version correctly. |
@mouse07410 what optimization level do you actually get when building the project? Is the message incorrect or is |
@fgaz hard to say, because Cabal logging does not work either (see #8456). ;-) But, based on the captured console output, It is unclear from the docs, whether I need just one of these (and if so - which one), or both: |
@mouse07410 did you read the doc? It suggests that |
The doc says that it "builds with optimization" and passes Did it mean that GHC will also use P.S. Docs IMHO do lack in the areas of clarity and comprehensiveness. |
@mouse07410 you don't need ghc-options if you use |
That is not to say that the |
Admitting my lack of expertise here - why should it be any more complicated than printing the message after reading the config (when Cabal learns what GHC compiler is requested, and what options to pass to it)...? |
@mouse07410 Very simply, because finding and changing a string is easier than moving the string, if you don’t know where to move exactly. Cabal’s code base is significant (after tests) it’s ~500 .hs files with ~100K SLOC (w/o spaces or comments). And that’s assuming that my guess is right, which it may not be. |
From haskell/cabal#6221, it seems like this is the preferred way to set the optimisation level. I’m also not certain whether this is taken into account when building with nix: it’s not mentioned in the output of cabal2nix, so how does the builder know what optimisation level to use?
What does the
-O1
in theBuild profile:
line mean? Theghc-options
for my library component include-O2
, and the verbose log shows thatghc
is invoked with-O2
too.The text was updated successfully, but these errors were encountered: