hanchenye-llvm-project/clang/test/Driver/Inputs
Nico Weber 2ca4be97de clang-cl: Implement initial limited support for precompiled headers.
In the gcc precompiled header model, one explicitly runs clang with `-x
c++-header` on a .h file to produce a gch file, and then includes the header
with `-include foo.h` and if a .gch file exists for that header it gets used.
This is documented at
http://clang.llvm.org/docs/UsersManual.html#precompiled-headers

cl.exe's model is fairly different, and controlled by the two flags /Yc and
/Yu. A pch file is generated as a side effect of a regular compilation when
/Ycheader.h is passed. While the compilation is running, the compiler keeps
track of #include lines in the main translation unit and writes everything up
to an `#include "header.h"` line into a pch file. Conversely, /Yuheader.h tells
the compiler to skip all code in the main TU up to and including `#include
"header.h"` and instead load header.pch. (It's also possible to use /Yc and /Yu
without an argument, in that case a `#pragma hrdstop` takes the role of
controlling the point where pch ends and real code begins.)

This patch implements limited support for this in that it requires the pch
header to be passed as a /FI force include flag – with this restriction,
it can be implemented almost completely in the driver with fairly small amounts
of code. For /Yu, this is trivial, and for /Yc a separate pch action is added
that runs before the actual compilation. After r261774, the first failing
command makes a compilation stop – this means if the pch fails to build the
main compilation won't run, which is what we want. However, in /fallback builds
we need to run the main compilation even if the pch build fails so that the
main compilation's fallback can run. To achieve this, add a ForceSuccessCommand
that pretends that the pch build always succeeded in /fallback builds (the main
compilation will then fail to open the pch and run the fallback cl.exe
invocation).

If /Yc /Yu are used in a setup that clang-cl doesn't implement yet, clang-cl
will now emit a "not implemented yet; flag ignored" warning that can be
disabled using -Wno-clang-cl-pch.

Since clang-cl doesn't yet serialize some important things (most notably
`pragma comment(lib, ...)`, this feature is disabled by default and only
enabled by an internal driver flag. Once it's more stable, this internal flag
will disappear.

(The default stdafx.h setup passes stdafx.h as explicit argument to /Yc but not
as /FI – instead every single TU has to `#include <stdafx.h>` as first thing it
does. Implementing support for this should be possible with the approach in
this patch with minimal frontend changes by passing a --stop-at / --start-at
flag from the driver to the frontend. This is left for a follow-up. I don't
think we ever want to support `#pragma hdrstop`, and supporting it with this
approach isn't easy: This approach relies on the driver knowing the pch
filename in advance, and `#pragma hdrstop(out.pch)` can set the output
filename, so the driver can't know about it in advance.)

clang-cl now also honors /Fp and puts pch files in the same spot that cl.exe
would put them, but the pch file format is of course incompatible. This has
ramifications on /fallback, so /Yc /Yu aren't passed through to cl.exe in
/fallback builds.

http://reviews.llvm.org/D17695

llvm-svn: 262420
2016-03-01 23:16:44 +00:00
..
B_opt_tree
CUDA/usr/local/cuda [CUDA] Invoke ptxas and fatbinary during compilation. 2016-01-14 21:41:27 +00:00
Windows/ARM/8.1/usr/bin Driver: support -fuse-ld= on cross windows 2015-10-28 04:45:58 +00:00
basic_android_tree [Mips] Support mips-r6 path suffix for Adnroid MIPS toolchain 2015-02-25 07:31:12 +00:00
basic_cross_linux_tree/usr
basic_freebsd64_tree
basic_freebsd_tree
basic_linux_libcxx_tree/usr
basic_linux_libcxxv2_tree/usr Extend linux header search to find libc++ headers in c++/vN for any N. 2015-11-09 21:10:54 +00:00
basic_linux_libstdcxx_libcxxv2_tree/usr Extend linux header search to find libc++ headers in c++/vN for any N. 2015-11-09 21:10:54 +00:00
basic_linux_tree
basic_myriad_tree [Myriad]: insert -L paths into linker cmd only when they exist. 2015-11-18 16:24:46 +00:00
basic_netbsd_tree/usr/lib
cl-libs
debian_6_mips64_tree
debian_6_mips_tree
debian_8_sparc64_tree [SPARC] Add multiarch include paths. 2015-06-05 13:44:43 +00:00
debian_8_sparc_multilib_tree [SPARC] Add multiarch include paths. 2015-06-05 13:44:43 +00:00
debian_multiarch_tree [PPC]: Fix bug in getMultiarchTriple. 2015-06-26 18:37:15 +00:00
debian_reduced_mips_tree
fake_install_tree
fedora_18_tree
fedora_21_tree/usr
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
mingw_arch_tree/usr Add extensive tests for the mingw toolchain and remove trailing slash from Arch. 2015-07-24 08:50:15 +00:00
mingw_clang_tree/mingw32 Driver: Fix include directories when not using libgcc under mingw 2015-08-13 15:41:04 +00:00
mingw_mingw_builds_tree/mingw32 Add extensive tests for the mingw toolchain and remove trailing slash from Arch. 2015-07-24 08:50:15 +00:00
mingw_mingw_org_tree/mingw Add extensive tests for the mingw toolchain and remove trailing slash from Arch. 2015-07-24 08:50:15 +00:00
mingw_msys2_tree/msys64/mingw32 Add extensive tests for the mingw toolchain and remove trailing slash from Arch. 2015-07-24 08:50:15 +00:00
mingw_opensuse_tree/usr Add extensive tests for the mingw toolchain and remove trailing slash from Arch. 2015-07-24 08:50:15 +00:00
mingw_ubuntu_tree/usr Add extensive tests for the mingw toolchain and remove trailing slash from Arch. 2015-07-24 08:50:15 +00:00
mips_cs_tree
mips_fsf_tree
mips_img_tree
mips_mti_linux Re-recommit: Add support for the new mips-mti-linux toolchain. 2015-11-12 15:26:54 +00:00
module
montavista_i686_tree/usr/lib/gcc/i686-montavista-linux/4.2.0
multiarch_freebsd64_tree
multilib_32bit_linux_tree
multilib_64bit_linux_tree
multilib_arm_linux_tree/usr/include/arm-linux-gnueabi Driver: add multilibs for ARM EB 2015-12-11 06:20:59 +00:00
multilib_armeb_linux_tree/usr/include/armeb-linux-gnueabi Driver: add multilibs for ARM EB 2015-12-11 06:20:59 +00:00
multilib_armebhf_linux_tree/usr/include/armeb-linux-gnueabihf Driver: add multilibs for ARM EB 2015-12-11 06:20:59 +00:00
multilib_armhf_linux_tree/usr/include/arm-linux-gnueabihf Driver: add multilibs for ARM EB 2015-12-11 06:20:59 +00:00
prefixed_tools_tree
resource_dir Add whole-program vtable optimization feature to Clang. 2016-02-24 20:46:36 +00:00
scei-ps4_tree/target Bring back r250262: PS4 toolchain 2015-10-14 12:25:43 +00:00
sparc-sun-solaris2.11/usr Stop hardcoding GCC paths in crt/ld.so lookup. 2015-08-31 19:17:51 +00:00
suse_10.3_ppc64_tree
ubuntu_11.04_multiarch_tree
ubuntu_12.04_LTS_multiarch_tree
ubuntu_13.04_multiarch_tree
ubuntu_14.04_multiarch_tree
ubuntu_14.04_multiarch_tree2
x86-64_ubuntu_13.10
cc1-response.txt
file.ll
file.prof
gen-response.c Teach Clang how to use response files when calling other tools 2014-09-15 17:45:39 +00:00
pchfile.cpp clang-cl: Implement initial limited support for precompiled headers. 2016-03-01 23:16:44 +00:00
pchfile.h clang-cl: Implement initial limited support for precompiled headers. 2016-03-01 23:16:44 +00:00
wildcard1.c
wildcard2.c