llvm-project/clang/test/Driver/Inputs
Reid Kleckner 0290c9ca5c Teach Clang how to use response files when calling other tools
Patch by Rafael Auler!

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.

Test Plan: A LIT test that tests proper response files support. This is
tricky, since, for Unix systems, we need a 2MB response file, otherwise
Clang will simply use regular arguments instead of a response file. To
do this, my LIT test generate the file on the fly by cloning many -DTEST
parameters until we have a 2MB file. I found out that processing 2MB of
arguments is pretty slow, it takes 1 minute using my notebook in a debug
build, or 10s in a Release build. Therefore, I also added "REQUIRES:
long_tests", so it will only run when the user wants to run long tests.

In the full discussion in
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20130408/171463.html,
Rafael Espindola discusses a proper way to test
llvm::sys::argumentsFitWithinSystemLimits(), and, there, Chandler
suggests to use 10 times the current system limit (20MB resp file), so
we guarantee that the system will always use response file, even if a
new linux comes up that can handle a few more bytes of arguments.
However, by testing with a 20MB resp file, the test takes long 8 minutes
just to perform a silly check to see if the driver will use a response
file. I found it to be unreasonable. Thus, I discarded this approach and
uses a 2MB response file, which should be enough.

Reviewers: asl, rafael, silvas

Reviewed By: silvas

Subscribers: silvas, rnk, thakis, cfe-commits

Differential Revision: http://reviews.llvm.org/D4897

llvm-svn: 217792
2014-09-15 17:45:39 +00:00
..
B_opt_tree Extend -Bprefix functionality and make it closer to gcc. If the "prefix" 2012-10-31 12:01:53 +00:00
basic_android_tree Propset the executables for GetProgramPath(). 2014-06-26 14:38:46 +00:00
basic_cross_linux_tree/usr Update a comment to clarify that searching the target triple bin 2013-06-20 23:37:54 +00:00
basic_freebsd64_tree
basic_freebsd_tree Propset the executables for GetProgramPath(). 2014-06-26 14:38:46 +00:00
basic_linux_libcxx_tree/usr Add the test trees that were supposed to be part of r199632. 2014-01-20 09:47:21 +00:00
basic_linux_tree Beef up the testing of our 'ld' invocation on linux to cover static 2013-03-04 01:27:49 +00:00
basic_netbsd_tree/usr/lib For NetBSD, use the same settings for PPC64 as for PPC when it comes to 2014-08-13 14:17:32 +00:00
cl-libs Make clang-cl accept .lib inputs (PR20065) 2014-06-18 17:21:50 +00:00
debian_6_mips64_tree [Driver][Mips] Support mips64-linux-gnuabi64 / mips64el-linux-gnuabi64 target triples. 2014-06-24 19:00:12 +00:00
debian_6_mips_tree
debian_multiarch_tree Testcase for r188400. 2013-08-14 19:45:27 +00:00
debian_reduced_mips_tree [Mips] Check all MIPS toolchains to find the one that best meets command 2014-03-04 18:37:28 +00:00
fake_install_tree
fedora_18_tree Revert "Support cross linking to arm on ubuntu." 2013-10-28 23:14:34 +00:00
fedora_21_tree/usr Add driver support for AArch64 Fedora. 2014-05-06 16:58:14 +00:00
freescale_ppc64_tree
freescale_ppc_tree
gcc_version_parsing1
gcc_version_parsing2
gcc_version_parsing3
gcc_version_parsing4
gentoo_linux_gcc_4.6.2_tree/usr Fix PR20773 which I introduced with a silly edit mistake in r216531. 2014-08-27 18:21:27 +00:00
gentoo_linux_gcc_4.6.4_tree/usr Fix PR20773 which I introduced with a silly edit mistake in r216531. 2014-08-27 18:21:27 +00:00
hexagon_tree Hexagon TC: Reimplement Link::ConstructJob to call 2012-12-06 15:46:07 +00:00
mips_cs_tree [Driver] Support -muclibc / -mglibc command line options for a couple 2014-08-13 14:34:14 +00:00
mips_fsf_tree [Driver] Support -muclibc / -mglibc command line options for a couple 2014-08-13 14:34:14 +00:00
mips_img_tree [mips][mips64r6] Add support for mips-img-linux-gnu GCC toolchains 2014-07-10 14:40:57 +00:00
module Driver: In crashdumps with -fmodule, dump the module dependencies 2014-06-20 22:59:50 +00:00
montavista_i686_tree/usr/lib/gcc/i686-montavista-linux/4.2.0
multiarch_freebsd64_tree
multilib_32bit_linux_tree Update a comment to clarify that searching the target triple bin 2013-06-20 23:37:54 +00:00
multilib_64bit_linux_tree [x32] Adding X32 target support to driver, including TargetInfo,DescriptionString, flags, paths lookup, etc. Cover changes with new tests. The author of the patch is Pavel Chupin (@pavel.v.chupin). 2014-07-10 15:27:19 +00:00
prefixed_tools_tree
resource_dir/lib Macho-embedded: fix tests after last rename 2014-01-21 13:23:09 +00:00
suse_10.3_ppc64_tree
ubuntu_11.04_multiarch_tree
ubuntu_12.04_LTS_multiarch_tree
ubuntu_13.04_multiarch_tree Fix gcc search for cross-compiler on Ubuntu 13.04. 2013-07-26 00:53:40 +00:00
ubuntu_14.04_multiarch_tree [x32] Adding X32 target support to driver, including TargetInfo,DescriptionString, flags, paths lookup, etc. Cover changes with new tests. The author of the patch is Pavel Chupin (@pavel.v.chupin). 2014-07-10 15:27:19 +00:00
ubuntu_14.04_multiarch_tree2 Significantly fix Clang's header search for Ubuntu (and possibly other 2014-08-27 08:41:41 +00:00
x86-64_ubuntu_13.10 Teach the driver to not try to use 'lib32' multilib spellings on ARM 2013-10-29 10:27:30 +00:00
cc1-response.txt Fix PR17239 by changing the semantics of the RemainingArgsClass Option kind 2014-08-22 19:29:30 +00:00
file.ll clang-cl: /fallback only applies to C or C++ files 2014-04-25 16:44:17 +00:00
file.prof Add -fprofile-sample-use to Clang's driver. 2013-11-13 12:22:39 +00:00
gen-response.c Teach Clang how to use response files when calling other tools 2014-09-15 17:45:39 +00:00
wildcard1.c Add a test for wildcard expansion on Windows 2014-07-16 00:55:31 +00:00
wildcard2.c Add a test for wildcard expansion on Windows 2014-07-16 00:55:31 +00:00