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

Rafael Auler rafaelauler at gmail.com
Wed Aug 13 21:13:51 PDT 2014


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4897.12483.patch
Type: text/x-patch
Size: 34613 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140814/ba98f390/attachment.bin>


More information about the cfe-commits mailing list