path: root/solenv/gbuild
diff options
authorLuboš Luňák <>2020-07-17 12:05:58 +0200
committerLuboš Luňák <>2020-07-17 13:30:55 +0200
commitd60dc145adf15cf9d06ea191dfd4b2f4c5c3fc33 (patch)
tree3fbb63f8f5c8bbe509016c1d90ac82a2fca2eb35 /solenv/gbuild
parent621514cf1dbb089a6da35da7f8c43d0a3c645fa7 (diff)
use Clang11's -fpch-instantiate-templates if available
The optimization to instantiate templates already while creating the PCH instead for every single compilation has been finally accepted upstream, but it's opt-in. Change-Id: Ia6456df05512329fc594f9ed0e400250c4f5029e Reviewed-on: Tested-by: Jenkins Reviewed-by: Luboš Luňák <>
Diffstat (limited to 'solenv/gbuild')
1 files changed, 7 insertions, 4 deletions
diff --git a/solenv/gbuild/platform/ b/solenv/gbuild/platform/
index d19f0d3686ad..93f750c4ce56 100644
--- a/solenv/gbuild/platform/
+++ b/solenv/gbuild/platform/
@@ -101,21 +101,24 @@ gb_PrecompiledHeader_get_enableflags = \
gb_PrecompiledHeader_EXT := .gch
+gb_PrecompiledHeader_extra_pch_cxxflags += $(PCH_INSTANTIATE_TEMPLATES)
# Clang supports building extra object file where it puts code that would be shared by all users of the PCH.
# Unlike with MSVC it is built as a separate step. The relevant options are used only when generating the PCH
# and when creating the PCH's object file, normal compilations using the PCH do not need extra options.
-gb_PrecompiledHeader_pch_with_obj = $(BUILDING_PCH_WITH_OBJ)
+gb_PrecompiledHeader_pch_with_obj += $(BUILDING_PCH_WITH_OBJ)
+gb_PrecompiledHeader_extra_pch_cxxflags += $(BUILDING_PCH_WITH_OBJ)
# If using Clang's PCH extra object, we may need to strip unused sections, otherwise inline and template functions
# emitted in that object may in some cases cause unresolved references to private symbols in other libraries.
gb_LinkTarget_LDFLAGS += $(LD_GC_SECTIONS)
gb_PrecompiledHeader_pch_with_obj += -ffunction-sections -fdata-sections
# Enable generating more shared code and debuginfo in the PCH object file.
-gb_PrecompiledHeader_pch_with_obj += $(PCH_MODULES_DEBUGINFO)
+gb_PrecompiledHeader_extra_pch_cxxflags += $(PCH_MODULES_DEBUGINFO)
# -fmodules-codegen appears to be worth it only if not optimizing, otherwise optimizing all the functions emitted
# in the PCH object file may take way too long, especially given that many of those may get thrown away
-gb_PrecompiledHeader_pch_with_obj += $(PCH_MODULES_CODEGEN)
+gb_PrecompiledHeader_extra_pch_cxxflags += $(PCH_MODULES_CODEGEN)
@@ -138,7 +141,7 @@ $(call gb_Helper_abbreviate_dirs,\
$(if $(EXTERNAL_CODE),$(gb_CXXFLAGS_Wundef),$(gb_DEFS_INTERNAL)) \
- $(gb_PrecompiledHeader_pch_with_obj) \
+ $(gb_PrecompiledHeader_extra_pch_cxxflags) \
$(6) \
$(call gb_cxx_dep_generation_options,$(1),$(call gb_PrecompiledHeader_get_dep_target_tmp,$(2),$(7))) \
-c $(patsubst %.cxx,%.hxx,$(3)) \