haskell / haskell/cabal

sdist and clean command does not honor new custom-setup section

Open
#3,424 4 comments 1 reaction 0 assignees View on GitHub
cabal-install: cmd/clean cabal-install: cmd/sdist Cabal: stanza/custom-setup type: bug
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

`cabal sdist` from a clean directory will generate a new setup executable that doesn't have access to the setup_macros.h (and possibly other discrepencies). `cabal clean` seems to have the same issue when building from a fresh directory. It seems like only `cabal configure` builds the setup script correctly. `cabal build` does, but I'm guess only because it calls configure automatically for you when it hasn't been done yet.

`cabal new-build` will attempt to call sdist, strangely it generate the setup script inside `dist` and not `dist-newstyle`, similarly as above macros are not available.

This bug is not specific to `new-build`.

```
name: CustomSetup
version: 0.1.0.0
license: BSD3
license-file: LICENSE
author: Eric Mertens
maintainer: emertens@gmail.com
build-type: Custom
extra-source-files: ChangeLog.md
cabal-version: >=1.10

custom-setup
setup-depends: base, Cabal == 1.24.*

library
exposed-modules: Library
build-depends: base >=4.8 && <4.9
hs-source-dirs: src
default-language: Haskell2010
```

```
{-# Language CPP #-}
import Distribution.Simple
import System.Environment

main =
do args <- getArgs
putStr "SETUP RUNNING: "
print args
defaultMain

#ifndef MIN_VERSION_Cabal
#error "macros are missing"
#endif
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue from a clean directory with the shown custom-setup configuration and setup executable, comparing cabal configure with cabal sdist, cabal clean, cabal build, and cabal new-build. Trace how each command generates the setup executable and handles setup_macros.h and custom-setup dependencies; done means all affected commands provide the required macros and use the expected build directory.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
build-system, cli
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.