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

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

Closed
andreasabel opened this issue Apr 21, 2021 · 11 comments
Labels
can-workaround There is a (maybe partial) workaround for the issue or missing feature re: -fno-code Concerning type-checking-only builds re: ghc-options Concerning passing options to GHC

Comments

@andreasabel
Copy link
Member

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).

@phadej
Copy link
Collaborator

phadej commented Apr 22, 2021

What's wrong with cabal build -O0?

@andreasabel
Copy link
Member Author

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).

@fgaz
Copy link
Member

fgaz commented Aug 28, 2021

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?

@gbaz gbaz added type: bug and removed type: bug labels Aug 28, 2021
@andreasabel
Copy link
Member Author

@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

@Mikolaj
Copy link
Member

Mikolaj commented Jan 29, 2022

@andreasabel: any news here?

@fgaz
Copy link
Member

fgaz commented Jan 29, 2022

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?

@andreasabel
Copy link
Member Author

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.

@fgaz
Copy link
Member

fgaz commented Jan 30, 2022

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

packages: .

package my_package
    ghc-options: -fno-code -fwrite-interface

@fgaz
Copy link
Member

fgaz commented Jan 30, 2022

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

@andreasabel
Copy link
Member Author

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.

@andreasabel andreasabel added can-workaround There is a (maybe partial) workaround for the issue or missing feature re: -fno-code Concerning type-checking-only builds re: ghc-options Concerning passing options to GHC labels Jan 30, 2022
@jneira
Copy link
Member

jneira commented May 1, 2022

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

@jneira jneira closed this as completed May 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
can-workaround There is a (maybe partial) workaround for the issue or missing feature re: -fno-code Concerning type-checking-only builds re: ghc-options Concerning passing options to GHC
Projects
None yet
Development

No branches or pull requests

6 participants