[Libreoffice-commits] core.git: config_host.mk.in configure.ac solenv/gbuild

Luboš Luňák (via logerrit) logerrit at kemper.freedesktop.org
Fri Jul 17 11:31:39 UTC 2020


 config_host.mk.in                       |    1 +
 configure.ac                            |   16 ++++++++++++++++
 solenv/gbuild/platform/com_GCC_class.mk |   11 +++++++----
 3 files changed, 24 insertions(+), 4 deletions(-)

New commits:
commit d60dc145adf15cf9d06ea191dfd4b2f4c5c3fc33
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Fri Jul 17 12:05:58 2020 +0200
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Fri Jul 17 13:30:55 2020 +0200

    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: https://gerrit.libreoffice.org/c/core/+/98948
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lunak at collabora.com>

diff --git a/config_host.mk.in b/config_host.mk.in
index 5b50b6f8ebe2..f0383acb318d 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -463,6 +463,7 @@ export PATH=@LO_PATH@
 export LIBO_PATH_SEPARATOR=@P_SEP@
 export PAGEMAKER_CFLAGS=$(gb_SPACE)@PAGEMAKER_CFLAGS@
 export PAGEMAKER_LIBS=$(gb_SPACE)@PAGEMAKER_LIBS@
+export PCH_INSTANTIATE_TEMPLATES=@PCH_INSTANTIATE_TEMPLATES@
 export PCH_MODULES_CODEGEN=@PCH_MODULES_CODEGEN@
 export PCH_MODULES_DEBUGINFO=@PCH_MODULES_DEBUGINFO@
 export PERL=@PERL@
diff --git a/configure.ac b/configure.ac
index 7dae274f3e43..9e206cc303d0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5317,6 +5317,22 @@ if test -n "$ENABLE_PCH" -a -n "$CCACHE_DEPEND_MODE" -a "$GCC" = "yes" -a "$COM_
     fi
 fi
 
+PCH_INSTANTIATE_TEMPLATES=
+if test -n "$ENABLE_PCH"; then
+    AC_MSG_CHECKING([whether $CC supports -fpch-instantiate-templates])
+    save_CFLAGS=$CFLAGS
+    CFLAGS="$CFLAGS -Werror -fpch-instantiate-templates"
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ PCH_INSTANTIATE_TEMPLATES="-fpch-instantiate-templates" ],[])
+    CFLAGS=$save_CFLAGS
+    if test -n "$PCH_INSTANTIATE_TEMPLATES"; then
+        AC_MSG_RESULT(yes)
+    else
+        AC_MSG_RESULT(no)
+    fi
+    CFLAGS=$save_CFLAGS
+fi
+AC_SUBST(PCH_INSTANTIATE_TEMPLATES)
+
 BUILDING_PCH_WITH_OBJ=
 if test -n "$ENABLE_PCH"; then
     AC_MSG_CHECKING([whether $CC supports -Xclang -building-pch-with-obj])
diff --git a/solenv/gbuild/platform/com_GCC_class.mk b/solenv/gbuild/platform/com_GCC_class.mk
index d19f0d3686ad..93f750c4ce56 100644
--- a/solenv/gbuild/platform/com_GCC_class.mk
+++ b/solenv/gbuild/platform/com_GCC_class.mk
@@ -101,21 +101,24 @@ gb_PrecompiledHeader_get_enableflags = \
 gb_PrecompiledHeader_EXT := .gch
 endif
 
+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)
 ifneq ($(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)
 ifeq ($(ENABLE_OPTIMIZED),)
 # -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)
 endif
 endif
 
@@ -138,7 +141,7 @@ $(call gb_Helper_abbreviate_dirs,\
 		$(if $(VISIBILITY),,$(gb_VISIBILITY_FLAGS)) \
 		$(if $(EXTERNAL_CODE),$(gb_CXXFLAGS_Wundef),$(gb_DEFS_INTERNAL)) \
 		$(gb_NO_PCH_TIMESTAMP) \
-		$(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)) \


More information about the Libreoffice-commits mailing list