forked from OSchip/llvm-project
add -fpch-codegen/debuginfo mapping to -fmodules-codegen/debuginfo
Using -fmodules-* options for PCHs is a bit confusing, so add -fpch-* variants. Having extra options also makes it simple to do a configure check for the feature. Also document the options in the release notes. Differential Revision: https://reviews.llvm.org/D83623
This commit is contained in:
parent
3895466e2c
commit
54eea6127c
|
@ -63,6 +63,32 @@ New Compiler Flags
|
|||
|
||||
- ...
|
||||
|
||||
- -fpch-codegen and -fpch-debuginfo generate shared code and/or debuginfo
|
||||
for contents of a precompiled header in a separate object file. This object
|
||||
file needs to be linked in, but its contents do not need to be generated
|
||||
for other objects using the precompiled header. This should usually save
|
||||
compile time. If not using clang-cl, the separate object file needs to
|
||||
be created explicitly from the precompiled header.
|
||||
Example of use:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ clang++ -x c++-header header.h -o header.pch -fpch-codegen -fpch-debuginfo
|
||||
$ clang++ -c header.pch -o shared.o
|
||||
$ clang++ -c source.cpp -o source.o -include-pch header.pch
|
||||
$ clang++ -o binary source.o shared.o
|
||||
|
||||
- Using -fpch-instantiate-templates when generating the precompiled header
|
||||
usually increases the amount of code/debuginfo that can be shared.
|
||||
- In some cases, especially when building with optimizations enabled, using
|
||||
-fpch-codegen may generate so much code in the shared object that compiling
|
||||
it may be a net loss in build time.
|
||||
- Since headers may bring in private symbols of other libraries, it may be
|
||||
sometimes necessary to discard unused symbols (such as by adding
|
||||
-Wl,--gc-sections on ELF platforms to the linking command, and possibly
|
||||
adding -fdata-sections -ffunction-sections to the command generating
|
||||
the shared object).
|
||||
|
||||
Deprecated Compiler Flags
|
||||
-------------------------
|
||||
|
||||
|
|
|
@ -1440,6 +1440,10 @@ def fpch_instantiate_templates:
|
|||
def fno_pch_instantiate_templates:
|
||||
Flag <["-"], "fno-pch-instantiate-templates">,
|
||||
Group<f_Group>, Flags<[CC1Option]>;
|
||||
defm pch_codegen: OptInFFlag<"pch-codegen", "Generate ", "Do not generate ",
|
||||
"code for uses of this PCH that assumes an explicit object file will be built for the PCH">;
|
||||
defm pch_debuginfo: OptInFFlag<"pch-debuginfo", "Generate ", "Do not generate ",
|
||||
"debug info for types in an object file built from this PCH and do not generate them elsewhere">;
|
||||
|
||||
def fmodules : Flag <["-"], "fmodules">, Group<f_Group>,
|
||||
Flags<[DriverOption, CC1Option]>,
|
||||
|
|
|
@ -5642,6 +5642,12 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
if (Args.hasFlag(options::OPT_fpch_instantiate_templates,
|
||||
options::OPT_fno_pch_instantiate_templates, false))
|
||||
CmdArgs.push_back("-fpch-instantiate-templates");
|
||||
if (Args.hasFlag(options::OPT_fpch_codegen, options::OPT_fno_pch_codegen,
|
||||
false))
|
||||
CmdArgs.push_back("-fmodules-codegen");
|
||||
if (Args.hasFlag(options::OPT_fpch_debuginfo, options::OPT_fno_pch_debuginfo,
|
||||
false))
|
||||
CmdArgs.push_back("-fmodules-debuginfo");
|
||||
|
||||
Args.AddLastArg(CmdArgs, options::OPT_fexperimental_new_pass_manager,
|
||||
options::OPT_fno_experimental_new_pass_manager);
|
||||
|
|
|
@ -7,21 +7,21 @@
|
|||
// CHECK-PCH-CREATE-NOT: -fmodules-codegen
|
||||
// CHECK-PCH-CREATE-NOT: -fmodules-debuginfo
|
||||
|
||||
// Create PCH with -fmodules-codegen.
|
||||
// RUN: %clang -x c++-header -Xclang -fmodules-codegen %S/../Modules/Inputs/codegen-flags/foo.h -o %t/foo-cg.pch -### 2>&1 | FileCheck %s -check-prefix=CHECK-PCH-CODEGEN-CREATE
|
||||
// Create PCH with -fpch-codegen.
|
||||
// RUN: %clang -x c++-header -fpch-codegen %S/../Modules/Inputs/codegen-flags/foo.h -o %t/foo-cg.pch -### 2>&1 | FileCheck %s -check-prefix=CHECK-PCH-CODEGEN-CREATE
|
||||
// CHECK-PCH-CODEGEN-CREATE: -emit-pch
|
||||
// CHECK-PCH-CODEGEN-CREATE: -fmodules-codegen
|
||||
// CHECK-PCH-CODEGEN-CREATE: "-x" "c++-header"
|
||||
// CHECK-PCH-CODEGEN-CREATE-NOT: -fmodules-debuginfo
|
||||
|
||||
// Create PCH with -fmodules-debuginfo.
|
||||
// RUN: %clang -x c++-header -Xclang -fmodules-debuginfo %S/../Modules/Inputs/codegen-flags/foo.h -g -o %t/foo-di.pch -### 2>&1 | FileCheck %s -check-prefix=CHECK-PCH-DEBUGINFO-CREATE
|
||||
// Create PCH with -fpch-debuginfo.
|
||||
// RUN: %clang -x c++-header -fpch-debuginfo %S/../Modules/Inputs/codegen-flags/foo.h -g -o %t/foo-di.pch -### 2>&1 | FileCheck %s -check-prefix=CHECK-PCH-DEBUGINFO-CREATE
|
||||
// CHECK-PCH-DEBUGINFO-CREATE: -emit-pch
|
||||
// CHECK-PCH-DEBUGINFO-CREATE: -fmodules-debuginfo
|
||||
// CHECK-PCH-DEBUGINFO-CREATE: "-x" "c++-header"
|
||||
// CHECK-PCH-DEBUGINFO-CREATE-NOT: -fmodules-codegen
|
||||
|
||||
// Create PCH's object file for -fmodules-codegen.
|
||||
// Create PCH's object file for -fpch-codegen.
|
||||
// RUN: touch %t/foo-cg.pch
|
||||
// RUN: %clang -c %t/foo-cg.pch -o %t/foo-cg.o -### 2>&1 | FileCheck %s -check-prefix=CHECK-PCH-CODEGEN-OBJ
|
||||
// CHECK-PCH-CODEGEN-OBJ: -emit-obj
|
||||
|
@ -29,7 +29,7 @@
|
|||
// CHECK-PCH-CODEGEN-OBJ: "-o" "{{.*}}foo-cg.o"
|
||||
// CHECK-PCH-CODEGEN-OBJ: "-x" "precompiled-header"
|
||||
|
||||
// Create PCH's object file for -fmodules-debuginfo.
|
||||
// Create PCH's object file for -fpch-debuginfo.
|
||||
// RUN: touch %t/foo-di.pch
|
||||
// RUN: %clang -c %t/foo-di.pch -g -o %t/foo-di.o -### 2>&1 | FileCheck %s -check-prefix=CHECK-PCH-DEBUGINFO-OBJ
|
||||
// CHECK-PCH-DEBUGINFO-OBJ: -emit-obj
|
||||
|
|
Loading…
Reference in New Issue