Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cabal extra-libraries check does not correctly propagate E2BIG error #5355

Open
nh2 opened this issue May 31, 2018 · 4 comments
Open

cabal extra-libraries check does not correctly propagate E2BIG error #5355

nh2 opened this issue May 31, 2018 · 4 comments

Comments

@nh2
Copy link
Member

nh2 commented May 31, 2018

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).

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.

@nh2
Copy link
Member Author

nh2 commented Jun 1, 2018

Related nix issue: NixOS/nixpkgs#41340

@nh2
Copy link
Member Author

nh2 commented Jun 1, 2018

I noticed that if I run with --verbose=3, I see in the output:

gcc returned
ExitFailure 1 with error message:
gcc: error trying to exec
'cc1':
execv: Argument list too long

but cabal continues nevertheless.

@23Skidoo
Copy link
Member

23Skidoo commented Jun 8, 2018

I think that this should be easy to fix: just check the exit code and tweak the error message. The relevant code is in Distribution.Simple.Configure.checkForeignDeps.

@dminuoso
Copy link

@23Skidoo Would this be a suitable patch?
dminuoso@76075c4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants