How to avoid too long input lines on Windows?

When there are a lot of object files to be linked, the cmd.exe could issue the error "too long input line". This is a limitation of the cmd.exe. The compiler driver supports the passing of command line options via @<file> functionality.

The contents of the file are inserted in place of the original @<file> option. If the file does not exist, or the control program can not read the content, the option is treated literally, and not removed.

Note that there is no '-' (dash) before the '@' character, and there is no space between the '@' character and the filename. This option can be used more than once. The control program concatenates options from all the following files.

The options in the file are separated by whitespace. You can include an option with a whitespace character by surrounding the entire option in either single or double quotes. You can include any character (including a backslash) by prefixing the character to be included with a backslash. The file may itself contain additional @<file> options. The control program processes such options recursively.

The @<file> option can be used together with -Wp,<options>, -Wa,<options>, -Wl,<options> .

Example

clang @commonopts.txt -Wp,@preprocessoropts.txt -Wa,@assembleropts.txt -Wl,@linkeropts.txt