[PATCH] Teach Clang how to use response files when calling other tools

Nico Weber thakis at chromium.org
Wed Aug 13 21:19:01 PDT 2014

(prior art: http://reviews.llvm.org/D4104)

On Wed, Aug 13, 2014 at 9:13 PM, Rafael Auler <rafaelauler at gmail.com> wrote:

> Hi rafael, asl,
> This patch addresses PR15171 and teaches Clang how to call other tools
> with response files, when the command line exceeds system limits. This is a
> problem for Windows systems, whose maximum command-line length is 32kb.
> I introduce the concept of "response file support" for each Tool object. A
> given Tool may have full support for response files (e.g. MSVC's link.exe)
> or only support file names inside response files, but no flags (e.g.
> Apple's ld64, as commented in PR15171), or no support at all (the default
> case). Therefore, if you implement a toolchain in the clang driver and you
> want clang to be able to use response files in your tools, you must
> override a method (getReponseFileSupport()) to tell so.
> I designed it to support different kinds of tools and internationalisation
> needs:
> - VS response files ( UTF-16 )
> - GNU tools ( uses system's current code page, windows' legacy intl.
> support, with escaped backslashes. On unix, fallback to UTF-8 )
> - Clang itself ( UTF-16 on windows, UTF-8 on unix )
> - ld64 response files ( only a limited file list, UTF-8 on unix )
> With this design, I was able to test input file names with spaces and
> international characters for Windows. When the linker input is large
> enough, it creates a response file with the correct encoding. On a Mac, to
> test ld64, I temporarily changed Clang's behavior to always use response
> files regardless of the command size limit (avoiding using huge command
> line inputs). I tested clang with the LLVM test suite (compiling
> benchmarks) and it did fine.
> Note: It depends on http://reviews.llvm.org/D4896 landing in the LLVM
> tree.
> http://reviews.llvm.org/D4897
> Files:
>   include/clang/Driver/Compilation.h
>   include/clang/Driver/Job.h
>   include/clang/Driver/Tool.h
>   lib/Driver/Compilation.cpp
>   lib/Driver/Job.cpp
>   lib/Driver/Tools.cpp
>   lib/Driver/Tools.h
>   test/Driver/response-file.c
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140813/fb954aaa/attachment.html>

More information about the cfe-commits mailing list