Skip to content

ghc-options applies to all dependencies, not just local packages #3883

Closed

Description

@edsko

With traditional build, I would use

cabal build --ghc-option=-ddump-simpl

If I try the same with new-build, it starts to rebuild every single dependency; presumably because it considers the compiler flags for all dependencies to have changed. I tried to do

packages: ingest.cabal

profiling: True
executable-profiling: True
constraints: Cabal >= 1.24

program-options
  ghc-options: -fprof-auto 

package ingest
  ghc-options: -ddump-simpl -ddump-to-file

but although it doesn't complain about the ghc-options inside the package section, it doesn't seem to take it into account either; no dump files get created. What is the right approach?


edit by @23Skidoo: Currently recommended workaround is to add a cabal.project that enables ghc-options for each package separately:

package foo
  ghc-options: -Werror

package bar
  ghc-options: -Werror

Cabal's own CI uses this approach.

Activity

  1. added
    cabal-install: v2-build system
    on Sep 22, 2016
  2. 23Skidoo commented on Sep 22, 2016

    @23Skidoo
    Member

    My intuition is that the second option ought to work, so we should fix it if it doesn't. Related: I've long wanted a cabal ghc-core ModuleName command.

  3. dcoutts commented on Sep 26, 2016

    @dcoutts
    Contributor

    The prog options should apply only to local packages, not all deps, just as all other command line or config top level options do.

  4. edsko commented on Sep 26, 2016

    @edsko
    ContributorAuthor

    Ah, turns out this is a duplicate of #3891 .

  5. dcoutts commented on Sep 26, 2016

    @dcoutts
    Contributor

    With traditional build, I would use

    cabal build --ghc-option=-ddump-simpl
    

    If I try the same with new-build, it starts to rebuild every single dependency; presumably because it considers the compiler flags for all dependencies to have changed.

    This is still a bug.

  6. 60 remaining items

  7. chshersh commented on Jun 25, 2019

    @chshersh
    Member

    I favour the approach where you use -Wall locally and -Werror on CI. During development, it's a bit tedious to get rid of all warnings every time: redundant imports, missing export lists, unused functions/types/fields/constructors, etc. But your final result shouldn't contain any warnings. Unfortunately, it's quite easy to miss them locally. Fortunately, this is a purpose of CI — catch all such things.

  8. harendra-kumar commented on Jun 25, 2019

    @harendra-kumar

    @phadej thanks for pointing out the workaround. I was not aware of it. This is useful.

  9. lexi-lambda commented on Oct 29, 2019

    @lexi-lambda

    A problem with the current workaround is that it’s impossible to list out all local packages in the global ~/.cabal/config file. I’d like to enable ghc-options: -j for all local packages globally, but I don’t think that’s currently possible.

  10. modified the milestones: 2.4.2.0, 3.4 on Nov 27, 2019
  11. cartazio commented on Mar 6, 2020

    @cartazio
    Contributor

    What are the architectural or man power blockers here ?

  12. emilypi commented on Mar 6, 2020

    @emilypi
    Member

    @lexi-lambda agreed - this would be great for tooling as well, since certain tools like hsinspect require plugins to be enabled in order to gather the correct data. Obviously committing build-tool specific details to source is a bad idea, but without being able to support flags and options with some global config or cabal.project.local-like behavior, I'm left in a suboptimal position.

    Just so it doesn't like I'm complaining at developers, I'm available to discuss this more in depth and contribute code towards this. Just point me in the right direction 😄

  13. sol commented on Aug 31, 2020

    @sol
    Member

    Bumping priority, this is pretty major and makes top-level ghc-options unusable.

    @ezyang agree!

    I don't think this is high priority as there is a workaround by explicitly listing the packages

    @phadej disagree!

    @hvr & co, instead of pointing fingers at others, lobbying against other peoples projects and hampering competition, please put your effort into producing working software yourself!

  14. cartazio commented on Aug 31, 2020

    @cartazio
    Contributor
  15. jneira commented on May 1, 2022

    @jneira
    Member

    After #7973, ghc-options is only applied to all local packages. It is still possible recover the old behaviour, see the workaround here: #7973 (comment)
    Closing the issue, thanks all!

  16. added a commit that references this issue on Jul 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

attention: pr-welcomecabal-install: v2-build systemtype: enhancement

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions