haskell / haskell/cabal

list-bin lists wrong binary for native-static foreign libraries

Open
#9,638 0 comments 0 reactions 0 assignees View on GitHub
needs triage type: bug
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

**Describe the bug**
Running `cabal list-bin myflib`, when the `flib` has `type: native-static`, should return the path to the static archive, however, it instead prints the path to the flib if it had been of type: `native-shared`.

**To Reproduce**
With a cabal file with a foreign library of type native-static:
```
cabal-version: 3.0
name: foreignlibstatic
version: 0.1.0.0
license: NONE
build-type: Simple
extra-doc-files: CHANGELOG.md

common warnings
ghc-options: -Wall

library
import: warnings
exposed-modules: MyLib
build-depends: base ^>=4.19.0.0
hs-source-dirs: src
default-language: Haskell2010

foreign-library myflib
type: native-static

other-modules: MyForeignLib
build-depends: base, foreignlibstatic
hs-source-dirs: flib
c-sources: csrc/MyForeignLibWrapper.c
default-language: Haskell2010
```
Run
```
cabal list-bin myflib
```

**Expected behaviour**
List-bin returns
```
$ cabal list-bin myflib
.../dist-newstyle/build/aarch64-osx/ghc-9.8.1/foreignlibstatic-0.1.0.0/f/myflib/build/myflib/libmyflib.dylib
```
But it should really be
```
$ cabal list-bin myflib
.../dist-newstyle/build/aarch64-osx/ghc-9.8.1/foreignlibstatic-0.1.0.0/f/myflib/build/myflib/libmyflib.a
```

**System information**
- Operating system
- `cabal` HEAD

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue with the foreign-library Cabal file shown in the report and run `cabal list-bin myflib`. Trace the `list-bin` entry point and its handling of native-static versus native-shared foreign libraries. Done means the command returns the static archive path ending in `libmyflib.a` for the native-static case.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
build-system, cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.