make -fmodules-codegen and -fmodules-debuginfo work also with PCHs
authorLuboš Luňák <l.lunak@centrum.cz>
Sun, 3 Nov 2019 20:15:03 +0000 (21:15 +0100)
committerLuboš Luňák <l.lunak@centrum.cz>
Thu, 9 Jul 2020 13:22:26 +0000 (15:22 +0200)
commit31b05692cd33b6dcc39402169b36d895e1aa87f4
tree5c6b101c3769c235b15df011620da6b2c00056d8
parentf54402b63a4f5b0b4b15e0f82ce8ff8501b206e6
make -fmodules-codegen and -fmodules-debuginfo work also with PCHs

Allow to build PCH's (with -building-pch-with-obj and the extra .o file)
with -fmodules-codegen -fmodules-debuginfo to allow emitting shared code
into the extra .o file, similarly to how it works with modules. A bit of
a misnomer, but the underlying functionality is the same. This saves up
to 20% of build time here. The patch is fairly simple, it basically just
duplicates -fmodules checks to also alternatively check
-building-pch-with-obj.

This already got committed as cbc9d22e49b434b6ceb2eb94b67079d02e0a7b74,
but then got reverted in 7ea9a6e0220da36ff2fd1fbc29c2755be23e5166
because of PR44953, as discussed in D74846. This is a corrected version
which does not include two places for the PCH case that aren't included
in the modules -fmodules-codegen path either.

Differential Revision: https://reviews.llvm.org/D69778
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
clang/test/Modules/Inputs/codegen-flags/foo.h
clang/test/PCH/codegen.cpp [new file with mode: 0644]