haskell / haskell/cabal

cabal extra-libraries check does not correctly propagate E2BIG error

Open
#5,355 5 comments 2 reactions 0 assignees View on GitHub
cabal-install: cmd/(re)configure meta: easy type: bug
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

I have a Haskell library that uses `extra-libraries: glog`.

When I try to build it I get:

```
Setup: Missing dependencies on foreign libraries:
* Missing C libraries: glog
```

This is a lie; the dependency exists.

The problem is that because in the eventual `gcc` invocation that Cabal creates to check whether the dependency really exists (I suspect it compiles a small C file to check if it can really use `glog`, similar to how `autoconf` does it), the amount of arguments passed to GCC turns out to be very long (further inflated by the fact that I use `nix`, but in general that's just a small constant factor difference).

Strace confirms:

```
strace -fye execve -s 100000000 -v runhaskell Setup.hs build 2>&1 | grep E2BIG
```

```
execve("cc1", [arguments here], [env vars here, "COLLECT_GCC_OPTIONS='-fno-stack-protector -L... 150KB of -L flags here'"] = -1 E2BIG (Argument list too long)
```

`E2BIG (Argument list too long)`, in this case because `COLLECT_GCC_OPTIONS` is longer than 128 KB (32 * 4 KB pages, see [here](https://unix.stackexchange.com/a/120842/100270)).

But cabal doesn't correctly propagate the `E2BIG` failure; instead of telling me that some internal invocaiton failed, it claims `Missing dependencies on foreign libraries`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.