commercialhaskell / commercialhaskell/stack

Flags are not being overridden for local extra-deps

Open
#5,375 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
Haskell
Stars
4.1k
Forks
850
Avg merge
10h 37m
Merged PRs (30d)
4

Description

### 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](https://github.com/commercialhaskell/stack/files/5129347/sample.zip)

For instance, in this example we have:
- the `sample` project which depends on `cryptonite` and `othersample`.
- `cryptonite` has a bunch of flags and for the example I am using `support_deepseq` which by default is `True`. I will set it to `False` on the stack.yaml file.
- `othersample` has a flag `hello` that is `False` by default. I will set it to `True` both by adding it in the stack.yaml file and providing the cli argument.

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

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with the sample.zip project using the shown stack.yaml extra-deps and flags settings, then compare local and remote package behavior with stack build --flag othersample:hello. Trace how Stack 2.3.3 handles flags for local extra-deps; done means the othersample hello flag is overridden like cryptonite's support_deepseq flag.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.