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

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

Closed
lierdakil opened this issue Dec 17, 2022 · 8 comments
Closed

Comments

@lierdakil
Copy link

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.

@jneira
Copy link
Member

jneira commented Dec 19, 2022

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

@gbaz gbaz added this to the Considered for 3.10 milestone Dec 24, 2022
@gbaz
Copy link
Collaborator

gbaz commented Jan 9, 2023

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

@patrickdoc
Copy link
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.

@gbaz
Copy link
Collaborator

gbaz commented Jan 10, 2023

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

@Mikolaj
Copy link
Member

Mikolaj commented Feb 9, 2023

@patrickdoc: ping?

@Mikolaj
Copy link
Member

Mikolaj commented Feb 14, 2023

@patrickdoc: hopeful ping again?

patrickdoc added a commit to patrickdoc/cabal that referenced this issue Feb 18, 2023
patrickdoc added a commit to patrickdoc/cabal that referenced this issue Feb 18, 2023
@Mikolaj
Copy link
Member

Mikolaj commented Feb 23, 2023

A fix in progress: #8779.

cocreature pushed a commit to patrickdoc/cabal that referenced this issue Feb 24, 2023
mergify bot pushed a commit that referenced this issue Feb 24, 2023
* Apply command line flags to install packages (#8637)

* remove expectBroken on NonIgnoredConfigs test

---------

Co-authored-by: gbaz <[email protected]>
mergify bot pushed a commit that referenced this issue Feb 24, 2023
* Apply command line flags to install packages (#8637)

* remove expectBroken on NonIgnoredConfigs test

---------

Co-authored-by: gbaz <[email protected]>
(cherry picked from commit 76670eb)
@Mikolaj
Copy link
Member

Mikolaj commented Feb 24, 2023

@patrickdoc: thank you!

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

@Mikolaj Mikolaj closed this as completed Feb 24, 2023
mergify bot added a commit that referenced this issue Feb 24, 2023
Apply command line flags to install packages (#8637) (backport #8779)
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

6 participants