Skip to content
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

Optimizations specified on the command line with -O should override the .cabal file #2443

Closed
mightybyte opened this issue Feb 27, 2015 · 7 comments

Comments

@mightybyte
Copy link
Collaborator

Currently -O ghc-options specified in the .cabal file override anything specified on the command line. I believe this is backwards. The .cabal file should be used when nothing is specified on the command line, but the command line should override it. This is necessary for a proper solution to #2442.

@bitemyapp
Copy link
Contributor

Tend to agree, command-line arguments are a more direct assertion of intent than config files.

(+1)

@ttuegel
Copy link
Member

ttuegel commented Feb 27, 2015

This should be true of all the command-line arguments. I suspect that -O is being lumped in with all the other Cabal-generated options to GHC, but the proper order should be

  1. Cabal generated
  2. cabal.config
  3. command-line --ghc-options
  4. command-line -O, -prof, -fhpc, etc.
    (assuming GHC takes the last -O option specified).

@dcoutts
Copy link
Contributor

dcoutts commented Mar 3, 2015

I agree, the command line should override what is specified in the .cabal file. So e.g. people can have -O2 in the .cabal file but cabal configure -O0 should nevertheless do the right thing. Note that it means we'll need to make sure that not specifying any -O setting to cabal configure passes nothing to ghc, or we'll always override.

@ttuegel ttuegel added this to the Cabal-1.24 milestone Apr 25, 2015
@mkawalec
Copy link

We've looked into it during Zurihac with @kosmikus and it seems that the options are passed to GHC in correct order ie. the command line options comes after the .cabal file one. Furthermore GHC seems to behave according to the last -O option specified.

Has this been fixed in the meantime?

@ttuegel
Copy link
Member

ttuegel commented May 29, 2015

Have you also checked the behavior with respect to the cabal.config file? It's possible that's what the original poster meant (and we should check it while we're at it).

@23Skidoo 23Skidoo modified the milestones: Cabal 1.24, Cabal 1.26 Feb 21, 2016
@ezyang ezyang modified the milestone: Cabal 2.0 Sep 6, 2016
@ulysses4ever
Copy link
Collaborator

I checked the problem as stated in the title ("Optimizations specified on the command line with -O should override the .cabal file"), and it no longer exists: command-line --ghc-options -O2 does override the option given in the .cabal file. I think this issue can be closed.

As for behavior w.r.t. the cabal config file, it is weird: the config file seems to take priority before both .cabal file and command line. At lerast w.r.t. the -O option. If anyone concerned about that, they could open another ticket. But I doubt many people specify -ON in the config file...

@Mikolaj
Copy link
Member

Mikolaj commented Jun 29, 2022

I agree that we should call success and close. I seem to remember --disable-optimization and --enable optimization also override .cabal file fine. Closing.

@Mikolaj Mikolaj closed this as completed Jun 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants