GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
driver

Spill long COLLECT_GCC_OPTIONS to a response file

GCC's driver now writes excessively long `COLLECT_GCC_OPTIONS` to a temporary response file to circumvent operating system argument limits, preventing build fa…

Operating systems impose limits on the length of command-line arguments and environment variables. To prevent GCC builds from failing when the COLLECT_GCC_OPTIONS environment variable exceeds these limits (e.g., 128KB on Linux, 32KB on Windows), the compiler driver now automatically spills these options to a temporary response file. The driver then sets COLLECT_GCC_OPTIONS to @<path> to this file, which collect2, lto-wrapper, and lto-plugin transparently expand, ensuring that large option sets can be handled without breaking the build.

In Details

The GCC driver's COLLECT_GCC_OPTIONS environment variable marshals parameters to collect2 and LTO components. This change addresses execve() argument length limits by automatically writing options exceeding COLLECT2_OPTIONS_MAX_LENGTH to a temporary response file and passing an @file argument. The existing expandargv() infrastructure in libiberty and lto-plugin then transparently consumes this, mitigating issues with extremely long command lines without altering the user-facing interface, particularly relevant for complex LTO builds or large numbers of -Wl,-Map= flags.

For Context

When you compile a program, the GCC compiler driver often needs to pass a lot of settings and options to its internal components, like the linker. These options are sometimes stored in an environment variable called COLLECT_GCC_OPTIONS. However, all operating systems have a maximum length for how long environment variables or command-line arguments can be. If the list of options gets too long, the build process can fail. To fix this, GCC now automatically writes these options to a temporary file, and then simply tells its internal components to read the options from that file. This way, even very complex builds with many options can proceed without hitting operating system limitations.

Filed Under: build-systemdriverportability