Skip to content

v2-cabal: Don't rebuild dependencies when -O0 or -fno-code is supplied as --ghc-options #7368

Closed

Description

@andreasabel

It seems that cabal v2-build wants to rebuild all dependencies when I add --ghc-options=-O0 or ...=-fno-code to e.g. just check compilability after a change.

I don't understand the rationale behind this behavior.

Is there a workaround? I'd like to alternate compilation between -fno-code (for just type-checking), -O0 (for running a first few test), and -O1 (for thorough testing with a large testsuite).

See also #2442 and #1176.

Example see #1176 (comment).

Activity

  1. phadej commented on Apr 22, 2021

    @phadej
    Collaborator

    What's wrong with cabal build -O0?

  2. andreasabel commented on Apr 29, 2021

    @andreasabel
    MemberAuthor

    What's wrong with cabal build -O0?

    Ah, great, this works!

    So this means something like cabal build --no-code would remain as feature request (#1176).

  3. fgaz commented on Aug 28, 2021

    @fgaz
    Member

    Subsumed by #3579?

    edit: actually this should be possible already by specifying the option for every local package, like in #3579 (comment), just a bit tedious. @andreasabel does that work for you?

  4. andreasabel commented on Sep 14, 2021

    @andreasabel
    MemberAuthor

    @andreasabel does that work for you?

    Not sure, I how would that look like?
    I want something convenient and accessible, ideally as simple as passing the option -O0 to cabal.

    For comparison, with v1-cabal it is:

    cabal v1-build --builddir=dist-no-code --ghc-options=-fno-code --ghc-options=-fwrite-interface
    
  5. Mikolaj commented on Jan 29, 2022

    @Mikolaj
    Member

    @andreasabel: any news here?

  6. fgaz commented on Jan 29, 2022

    @fgaz
    Member

    Not sure, I how would that look like?

    Like the comment I mentioned ( #3579 (comment) ), so

    local-package-1
      ghc-options: -fno-code
    
    local-package-2
      ghc-options: -fno-code

    Not that convenient but it works. If you put that configuration in another cabal.project file you could switch between the two from the command line.

    Should we close this in favour of #1176 and #3579?

  7. andreasabel commented on Jan 30, 2022

    @andreasabel
    MemberAuthor

    This does not work, or maybe something is missing. Can you give full instructions?
    E.g. I am trying with cabal.project.tc

    packages: .
    
    builddir: dist-tc
    ghc-options: -fno-code -fwrite-interface
    
    cabal --project-file=cabal.project.tc build
    

    This reports, before starting the build:

    Warning: .../cabal.project.tc: Unrecognized field 'ghc-options' on line 4
    

    Further, the builddir:dist-tc seems to be silently dropped, at least no subfolder named dist-tc was created.

  8. fgaz commented on Jan 30, 2022

    @fgaz
    Member

    assuming my_package is the name of the package referred as .:

    packages: .
    
    package my_package
        ghc-options: -fno-code -fwrite-interface
    
  9. fgaz commented on Jan 30, 2022

    @fgaz
    Member

    Further, the builddir:dist-tc seems to be silently dropped, at least no subfolder named dist-tc was created.

    This is documented: https://cabal.readthedocs.io/en/3.4/cabal-project.html#cmdoption-builddir

    Though I don't know why it can't be specified in cabal.project. Probably caching reasons. I think there is a ticket somewhere discussing it

    Making it give a warning or error would be nice

  10. andreasabel commented on Jan 30, 2022

    @andreasabel
    MemberAuthor

    This is documented: cabal.readthedocs.io/en/3.4/cabal-project.html#cmdoption-builddir

    Thanks.
    (Yet I'd expect a warning that this is not understood, rather silently dropping it.)

    But to the original issue: With

    packages: .
    
    package Agda
      ghc-options: -fno-code -fwrite-interface
    

    and

    cabal --project-file=cabal.project.tc --builddir=dist-tc build
    

    It does indeed work. Fantastic!

    ...
    [404 of 404] Compiling Agda.Main        ( src/full/Agda/Main.hs, nothing, dist-tc/build/x86_64-osx/ghc-9.2.1/Agda-2.6.3/build/Agda/Main.dyn_o )
    ar: dist-tc/build/x86_64-osx/ghc-9.2.1/Agda-2.6.3/build/Agda/Auto/Auto.o: No such file or directory
    ...
    

    There are 404 errors about missing .o files, but this was already the case in v1-cabal.

  11. added
    can-workaround
    re: -fno-code
    re: ghc-options
    on Jan 30, 2022
  12. jneira commented on May 1, 2022

    @jneira
    Member

    After #7973 ghc-options only applies to local packages, so change it does not trigger the rebuild of dependencies (remote packages),thanks all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    can-workaroundre: -fno-codere: ghc-options

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions