Skip to content

Cabal-install 3.8.1.0 no longer passes through ghc-options on install #8637

Closed

Description

@lierdakil

Describe the bug

As per title, cabal install ignores --ghc-options. This is changed from 3.6.

To Reproduce
Compare:

$ cabal-3.6.2.0 v2-install --ghc-option=-foo hello --verbose 
// irrelevant...
/home/livid/.ghcup/bin/cabal-3.6.2.0 act-as-setup --build-type=Simple --
configure --verbose=2 --builddir=dist --ghc
// boilerplate...
--ghc-option=-hide-all-packages --ghc-option=-foo // <== here! the option is passed through
// more irrelevant
ghc: unrecognised flag: -foo // <== as expected

Usage: For basic information, try the `--help' option.

cabal-3.6.2.0: Failed to build
hello-1.0.0.2-0dbbae9b57058f3d4ff9f9e497f74f6444d6d82befb75c49e4ce49000b6f36a7.
The failure occurred during the configure step.
$ cabal-3.8.1.0 v2-install --ghc-option=-foo hello --verbose
// irrelevant...
/home/livid/.ghcup/bin/cabal-3.8.1.0 act-as-setup --build-type=Simple --
configure --verbose=2 --builddir=dist --ghc
// boilerplate...
--ghc-option=-hide-all-packages // <== here! the option is not passed through!
// irrelevant
Completed    hello-1.0.0.2 (all, legacy fallback)

Expected behavior

I don't know if this change is intentional, but as I couldn't find anything mentioning this specifically in the changelog, I'm guessing not.

System information

  • Operating system: Linux x86_64
  • cabal, ghc versions: cabal 3.8.1.0, ghc 9.0.2.

Additional context

Passing --ghc-options=-optl-static etc is actually pretty convenient in some cases. Besides, it's rather surprising that configuration options are ignored on install in the first place.

Activity

  1. jneira commented on Dec 19, 2022

    @jneira
    Member

    Hi, many thanks for the report.
    TBH i cant believe such a bug had not been catched by the test suite, but i just reproduced it locally 🤦

    Possible workarounds (the usual ones):

    • Add ghc-options field in the cabal file (using common stanzas if you want to apply them to various components)
    • Add cabal.project with
    package package-to-apply-options
      ghc-options: -foo
    

    or

    package *
      ghc-options: -foo
    

    Of course those workarounds do not work to install remote packages.

    I wonder if #7973 is related
    //cc @patrickdoc

  2. added this to the Considered for 3.10 milestone on Dec 24, 2022
  3. gbaz commented on Jan 9, 2023

    @gbaz
    Collaborator

    @patrickdoc did you get a chance to look at this?

  4. patrickdoc commented on Jan 10, 2023

    @patrickdoc
    Collaborator

    Reviewing my notes on #7998 , I believe the root issue here is that "hello" is not a local package.

    Internally, options are applied:

    • globally (all packages in the build)
    • locally (all packages being built from sources referenced in the current cabal.project)
    • per-package (i.e. apply X to package Y)

    In this case, "hello" is classified as a "remote" package instead of "local", so the command-line flags are not applied.

  5. gbaz commented on Jan 10, 2023

    @gbaz
    Collaborator

    Hrm. Do you think that we should change cabal install to record ghc-options and other program options as per-package scoped to the package the install command is run on?

    I think that would be the least surprising behavior, and hopefully a fairly minimally invasive change (since it just affects the single command).

  6. Mikolaj commented on Feb 9, 2023

    @Mikolaj
    Member
  7. Mikolaj commented on Feb 14, 2023

    @Mikolaj
    Member

    @patrickdoc: hopeful ping again?

  8. Mikolaj commented on Feb 23, 2023

    @Mikolaj
    Member

    A fix in progress: #8779.

  9. Mikolaj commented on Feb 24, 2023

    @Mikolaj
    Member

    @patrickdoc: thank you!

    We hope this is fixed in #8779, which I'm backporting to 3.10 right now. Please reopen if not.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions