commercialhaskell / stack

The Haskell Tool Stack
http://haskellstack.org
BSD 3-Clause "New" or "Revised" License
4k stars 843 forks source link

Flags are not being overridden for local extra-deps #5375

Open jasagredo opened 4 years ago

jasagredo commented 4 years ago

General summary/comments

When having local packages that have cabal flags and setting them either with the cli --flag PACKAGE:[-]FLAG argument or on the stack.yaml file, the flag is not changed. It works properly for remote packages.

Steps to reproduce

I created a sample project that has an internal sub-project and a remote dependency. To observe this behavior, the inner package has to have a flag defined and so must the remote dependency. Setting a value for the local flag doesn't change the behavior.

sample.zip

For instance, in this example we have:

The sample/stack.yaml file has these fields defined:

extra-deps: [ ./othersample ]

# Override default flag values for local packages and extra-deps
flags:
  othersample:
    hello: True
  cryptonite:
    support_deepseq: False

I also created a cabal.project file in order to check that Cabal did the right thing, with these contents:

packages: ./ ./othersample
constraints: othersample +hello
constraints: cryptonite -support_deepseq

(Note that in order to force recompile of cryptonite deleting ~/.stack/snapshot and ~/.cabal/store might be needed)

Expected

I would have expected that the flag was overridden also for the local package.

Actual

See the line with the number 4 and the line with number 1646. As shown, the hello flag has not been overridden but the support_deepseq flag has been:

❯ stack build --flag othersample:hello --cabal-verbose 2>&1 | grep -n2 Flag
2-othersample> Using Parsec parser
3-othersample> Configuring othersample-0.1.0.0...
4:othersample> Flags chosen: hello=False
5-othersample> Dependency base ==4.13.0.0: using base-4.13.0.0
6-othersample> Dependency base ==4.13.0.0: using base-4.13.0.0
--
1146-memory     > Using Parsec parser
1147-memory     > Configuring memory-0.15.0...
1148:memory     > Flags chosen: support_basement=True, support_bytestring=True,
1149-memory     > support_deepseq=True, support_foundation=True
1150-memory     > Dependency base ==4.13.0.0: using base-4.13.0.0
--
1643-cryptonite > Using Parsec parser
1644-cryptonite > Configuring cryptonite-0.26...
1645:cryptonite > Flags chosen: check_alignment=False, integer-gmp=True,
1646-cryptonite > old_toolchain_inliner=False, support_aesni=True, support_deepseq=False,
1647-cryptonite > support_pclmuldq=False, support_rdrand=True, support_sse=False

Note that with the mentioned cabal.project file I'm able to do:

❯ cabal build --verbose 2>&1 | grep -n2 Flag
198-Redirecting build log to {handle:
199-/home/javier/.cabal/logs/ghc-8.8.3/basement-0.0.11-7df2738a446782507b41a27a4163e523923450c995eff9dcc98038607281b040.log}
200:Flags chosen: hello=True
201-Dependency base ==4.13.0.0: using base-4.13.0.0
202-Source component graph: component lib
❯ grep -n2 Flags ~/.cabal/logs/ghc-8.8.3/cryptonite-0.27-dcb26d37094d192b29f1da7bb6cdc8e2cc11d3fe14d9b55f12da72554485c787.log
12-/home/javier/.ghcup/bin/ghc-pkg dump '--package-db=/home/javier/.cabal/store/ghc-8.8.3/package.db' -v0
13-/home/javier/.ghcup/bin/ghc --print-libdir -hide-all-packages
14:Flags chosen: check_alignment=False, integer-gmp=True,
15-old_toolchain_inliner=False, support_aesni=True, support_deepseq=False,
16-support_pclmuldq=False, support_rdrand=True, support_sse=False,

Stack version

❯ stack --version
2.3.3 x86_64 hpack-0.34.2

Method of installation

get.haskellstack.org

mtolly commented 2 years ago

This is still an issue, just encountered it on Version 2.7.3, Git revision 7927a3aec32e2b2e5e4fb5be76d0d50eddcc197f x86_64 hpack-0.34.4. Also #5301 appears to be the same issue

jship commented 8 months ago

Confirmed this is happening in Version 2.13.1, Git revision 8102bb8afce90fc954f48efae38b87f37cabc988 x86_64 hpack-0.36.0.