[Libreoffice-commits] core.git: config_host.mk.in configure.ac solenv/gbuild
LuboÅ¡ LuÅák (via logerrit)
logerrit at kemper.freedesktop.org
Sat Jan 18 13:57:12 UTC 2020
config_host.mk.in | 2 ++
configure.ac | 31 +++++++++++++++++++++++++++++++
solenv/gbuild/platform/com_GCC_class.mk | 16 +++++++++++++++-
3 files changed, 48 insertions(+), 1 deletion(-)
New commits:
commit a0323937ff4b36594e26b5c1a143af188c75abfc
Author: Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Sat Jun 22 21:17:56 2019 +0200
Commit: Luboš Luňák <l.lunak at collabora.com>
CommitDate: Sat Jan 18 14:56:37 2020 +0100
support Clang's -fmodules-codegen/debuginfo options for PCH building
These (starting with my patches for Clang-to-be-10) allowing emitting
debuginfo and functions into a dedicated object file, so that all
the normal compilations using the PCH can skip those, thus saving
the time. The debuginfo option seems to always be worth it. The codegen
option is more tricky, it doesn't seem to be worth it for optimized
builds (optimizing all the functions in that one object file costs
too much).
This requires also using --Wl,--gc-sections . The reason is that
the object file contains all template instances instantiated from the PCH,
so that they can be shared, but the template instance may come
from another library or use a private symbol from that library.
For example the std::unique_ptr<ScInterpreterContext>
in ScInterpreterContextPool in the header refers to ScInterpreterContext
dtor. But even though both these classes are private, the header
gets used also by scfilt, because there it is included by document.hxx
because of a private ScDocument data member. So even though nothing
in scfilt uses ScInterpreterContext, the PCH object file will refer to it.
Fortunately that template instance itself is not used by scfilt,
so --gc-sections will remove it.
Change-Id: I2a06ebcc4dd4175424b3a72ab3ebcaf2ac3ee295
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87011
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 e1cddb295964..2c5eec97a156 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -448,6 +448,8 @@ 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_MODULES_CODEGEN=@PCH_MODULES_CODEGEN@
+export PCH_MODULES_DEBUGINFO=@PCH_MODULES_DEBUGINFO@
export PERL=@PERL@
export PKGFORMAT=@PKGFORMAT@
export PKGMK=@PKGMK@
diff --git a/configure.ac b/configure.ac
index 1f7eb690b6cc..5b9fd601ef9e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5202,6 +5202,37 @@ if test -n "$ENABLE_PCH"; then
fi
AC_SUBST(BUILDING_PCH_WITH_OBJ)
+PCH_MODULES_CODEGEN=
+if test -n "$BUILDING_PCH_WITH_OBJ"; then
+ AC_MSG_CHECKING([whether $CC supports -Xclang -fmodules-codegen])
+ save_CFLAGS=$CFLAGS
+ CFLAGS="$CFLAGS -Werror -Xclang -fmodules-codegen"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ PCH_MODULES_CODEGEN="-Xclang -fmodules-codegen" ],[])
+ CFLAGS=$save_CFLAGS
+ if test -n "$PCH_MODULES_CODEGEN"; then
+ AC_MSG_RESULT(yes)
+ else
+ AC_MSG_RESULT(no)
+ fi
+ CFLAGS=$save_CFLAGS
+fi
+AC_SUBST(PCH_MODULES_CODEGEN)
+PCH_MODULES_DEBUGINFO=
+if test -n "$BUILDING_PCH_WITH_OBJ"; then
+ AC_MSG_CHECKING([whether $CC supports -Xclang -fmodules-debuginfo])
+ save_CFLAGS=$CFLAGS
+ CFLAGS="$CFLAGS -Werror -Xclang -fmodules-debuginfo"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ PCH_MODULES_DEBUGINFO="-Xclang -fmodules-debuginfo" ],[])
+ CFLAGS=$save_CFLAGS
+ if test -n "$PCH_MODULES_DEBUGINFO"; then
+ AC_MSG_RESULT(yes)
+ else
+ AC_MSG_RESULT(no)
+ fi
+ CFLAGS=$save_CFLAGS
+fi
+AC_SUBST(PCH_MODULES_DEBUGINFO)
+
TAB=`printf '\t'`
AC_MSG_CHECKING([the GNU Make version])
diff --git a/solenv/gbuild/platform/com_GCC_class.mk b/solenv/gbuild/platform/com_GCC_class.mk
index 2ec7a66f3e25..f40d315b1c3b 100644
--- a/solenv/gbuild/platform/com_GCC_class.mk
+++ b/solenv/gbuild/platform/com_GCC_class.mk
@@ -89,8 +89,22 @@ gb_PrecompiledHeader_EXT := .gch
endif
# 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.
+# 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)
+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 += -Wl,--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)
+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)
+endif
+endif
# This is for MSVC's object file built directly as a side-effect of building the PCH.
gb_PrecompiledHeader_get_objectfile =
More information about the Libreoffice-commits
mailing list