-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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
GCC fails because argument list created by nix is too long #41340
Comments
How many dependencies are we talking here? I've worked with quite a few without error. |
CCing people that were in the past involved in dealing with large amount of args to gcc (#26554, #26974, #27609, #27657): @domenkozar @edolstra @orivej @copumpkin @Ericson2314 @ryantrinkle |
|
Could we use GCC spec files instead of command line arguments? This wouldn't work with Clang, but creating a Clang wrapper for supporting spec files is something that has sounded useful for a while now. |
I am relatively certain that this involves inserting an just as in the line below that. I have confirmed that this line produces the duplicates. |
@ElvishJerricco I don't know that. It may well be that Do you know how to use them? If yes, could you make a small example that we can |
… and `PD.extraLibDirs`. Should help with big invocations as found in NixOS/nixpkgs#41340.
… and `PD.extraLibDirs`. Should help with big invocations as found in NixOS/nixpkgs#41340.
I can see the duplicated The nixpkgs manual says
but I haven't quite found yet where it's done and whether we can dedupe it there. |
I found there's another part to it (haskell/cabal#5356 (comment)): Independet of Haskell depencencies, for system dependencies (so, stuff that makes it in via no-Haskell-package- My case has 11 of those, so that also contributes to some blow-up. |
Great cabal fixes! We should set |
@Ericson2314 I think the |
… and `PD.extraLibDirs`. Should help with big invocations as found in NixOS/nixpkgs#41340.
So is there a workaround/trick how I can build a stack project now? Can I downgrade the version of something? |
… and `PD.extraLibDirs`. Should help with big invocations as found in NixOS/nixpkgs#41340.
@i-am-the-slime Building |
… and `PD.extraLibDirs`. Should help with big invocations as found in NixOS/nixpkgs#41340.
… and `PD.extraLibDirs`. Should help with big invocations as found in NixOS/nixpkgs#41340.
…LibDirs`. Should help with big invocations as found in NixOS/nixpkgs#41340.
My cabal PR has been merged which should provide a temporary mitigation: haskell/cabal#5356 For the long run we still have to fix GCC upstream to not use the length-limited |
@Mistuke I saw your comment and a mentioned fix on https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86030 What confuses me is that everthing there talks about Do you know if this should be fixed by that upstream patch? |
@nh2 probably, the code filters out the If you want confirmation I can test using a GCC 9 build on Monday. |
@nh2 So I'm not sure it'll fix your particular problem.. It definitely adds the But also more annoyingly, |
@Mistuke Thanks for double-checking that for us. Will you follow up with upstream GCC on your issue, or should I do that? |
I will re-open the ticket on Monday, but it would be helpful if you could
then comment as well, especially mention that it's a problem on Linux too
as I think that carries more weight than a Windows issue :)
…On Thu, Jun 28, 2018 at 12:57 PM, Niklas Hambüchen ***@***.*** > wrote:
@Mistuke <https://github.com/Mistuke> Thanks for double-checking that for
us. Will you follow up with upstream GCC on your issue, or should I do that?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#41340 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABH3KY7zKNKCFQrVUzdiNuCD7ac-3fWMks5uBMS2gaJpZM4UVz4b>
.
|
@Mistuke Sure, just let me know when I shall comment! |
I have a similar issue on macOS using GHC 8.4.3:
|
Also, for |
The motivation behind this is to alleviate the problem described in NixOS#41340. I'm not sure if this completely fixes the problem, but it eliminates one more area where we can exceed command line length limits. This is essentially the same change as in NixOS#112449, except for `ld-wrapper.sh` instead of `cc-wrapper.sh`. However, that change alone was not enough; on macOS the `ld` provided by `darwin.cctools` fails if you use process substitution to generate the response file, so I put up a PR to fix that: tpoechtrager/cctools-port#131 … and I included a patch referencing that fix so that the new `ld-wrapper` still works on macOS.
The motivation behind this is to alleviate the problem described in NixOS#41340. I'm not sure if this completely fixes the problem, but it eliminates one more area where we can exceed command line length limits. This is essentially the same change as in NixOS#112449, except for `ld-wrapper.sh` instead of `cc-wrapper.sh`. However, that change alone was not enough; on macOS the `ld` provided by `darwin.cctools` fails if you use process substitution to generate the response file, so I put up two PRs to fix that: tpoechtrager/cctools-port#131 tpoechtrager/cctools-port#132 … and I included a patch referencing that fix so that the new `ld-wrapper` still works on macOS.
The motivation behind this is to alleviate the problem described in NixOS#41340. I'm not sure if this completely fixes the problem, but it eliminates one more area where we can exceed command line length limits. This is essentially the same change as in NixOS#112449, except for `ld-wrapper.sh` instead of `cc-wrapper.sh`. However, that change alone was not enough; on macOS the `ld` provided by `darwin.cctools` fails if you use process substitution to generate the response file, so I put up two PRs to fix that: tpoechtrager/cctools-port#131 tpoechtrager/cctools-port#132 … and I included a patch referencing that fix so that the new `ld-wrapper` still works on macOS.
The motivation behind this is to alleviate the problem described in #41340. I'm not sure if this completely fixes the problem, but it eliminates one more area where we can exceed command line length limits. This is essentially the same change as in #112449, except for `ld-wrapper.sh` instead of `cc-wrapper.sh`. However, that change alone was not enough; on macOS the `ld` provided by `darwin.cctools` fails if you use process substitution to generate the response file, so I put up a PR to fix that: tpoechtrager/cctools-port#131 … and I included a patch referencing that fix so that the new `ld-wrapper` still works on macOS.
We've verified internally that the combination of #213831 and and https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9897 fixes Haskell builds on macOS to no longer exceed Fixing Linux builds still might require a tiny bit more work (since This obviates the need to deduplicate or compress command-line arguments, but that's still a good thing to do anyway. |
Unfortunately, limiting Edit: This link does not really capture just how much of a risk E2BIG is. For reference, just search through this file for E2BIG. |
With GHC 9.4.5 on NixOS 24.05, it seems I am still encountering the issue when trying to build xmobar:
Quite possibly, I'm going about this the wrong way - I have detailed instructions and all the relevant files at https://github.com/bbarker/dotxmonad/tree/0fdc2c9f4efb2895350474c2ceb7784cbf1c919f - any suggestions would be welcome. |
I'm encountering it on NixOS 24.05 with the Haskell
because the |
This is most (in my mind) a gcc bug. Most everything that gcc drives gets invoked with a response file. There is one exception: I think the problem is a hard one to solve but would make a lot of people's lives a lot better. There is a workaround - put your problematic modules in separate packages altogether. That's what we ended up doing at $WORK. |
@jsoo1 Yes, definitely a GCC bug. |
A workaround for #41340 (comment) that is to set
which is from nixpkgs/pkgs/development/haskell-modules/generic-builder.nix Lines 123 to 132 in 63b875e
That existing is to some extent my fault: |
Any idea how to do this with |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/trouble-building-xmobar-argument-list-too-long/46897/3 |
Quick summary
-L
flags passed to GCC-L
flags to its subprogramcc1
via an environment variableE2BIG
Details
So once again, I'm building some Haskell with lots of library dependencies.
Trying to upgrade this build to 18.03, the
nix-build
of the Haskell package newly fails withThis error message is wrong (cabal doesn't correctly propagate the
argument list too long
error shown below; I filed a bug about it being misleading at haskell/cabal#5355); the dependency exists.The problem is that because in some eventual
gcc
invocation the amount of arguments passed to GCC turns out to be very long.strace
confirms:E2BIG (Argument list too long)
, in this case becauseCOLLECT_GCC_OPTIONS
is longer than 128 KB (32 * 4 KB pages, see here, and a repro script I made here).What is the
COLLECT_GCC_OPTIONS
environment variable? It is an environment variable set bygcc
before calling out tocc1
, over which it communicates flags tocc1
. Most (if not all?) flags given to gcc will make it into this variable. So it can grow very big (easily larger than the 128 KB limit, especially on nix).Note that even flags given in a "response file" via
gcc @myresponsefile.rsp
(which was designed to pass GCC flags via a file instead of command line args to circumvent command line arg limits) will be put intoCOLLECT_GCC_OPTIONS
bygcc
itself to communicate them tocc1
(I have just confirmed that with a small example on my Ubuntu 16.04). So using@myresponsefile.rsp
is not a workaround. (Yes, this seems to defeat the purpose of response files, but I suspect those were originally made to circumvent a much smaller limit of command line argument on Windows, where the limit is well below the 128 KB limit for environment variable lengths on Linux).Aside: nix inflates the number of
-L
flags by the fact that each-L
option to gcc is present multiple times, but those duplicates make only for factor 4x or so; even if they were deduplicated, I'd already be at half ofMAX_ARG_STRLEN
with my medium-size Haskell project; so if I added a couple more dependencies to my Haskell project (all recursive nix Haskell dependencies make it as-L
options into the gcc command line), I'd quickly exceed that limit again even without duplication.Problems to fix
-L
flags passed to GCC will help the issue by a small constant factor and make a couple more projects compile, but won't help with projects with many dependencies.Steps to reproduce
executable
sections in the cabal file, see comment belowEnvironment
The text was updated successfully, but these errors were encountered: