summaryrefslogtreecommitdiff
path: root/compilerplugins/Makefile-clang.mk
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2019-10-15 10:04:54 +0200
committerLuboš Luňák <l.lunak@collabora.com>2019-10-15 16:02:40 +0200
commit1c8b2b6da13636b07d47e157b2ddac445966ddf4 (patch)
tree823e2adb5db894a9d2af5bc317aebec0e81e57e5 /compilerplugins/Makefile-clang.mk
parenta5496f4441450bec4dfb7468642d72c758a725a8 (diff)
use PCH for clang plugin source too, if enabled
This currently supports only building with Clang on Linux, as I'm lazy to handle the other cases (and Clang should be usually self-built anyway). The main compile time cost is in optimizing the code, but this still saves few seconds per source. Change-Id: Ib6c0fd874820af737ee1257cb5234fb78bc63ad8 Reviewed-on: https://gerrit.libreoffice.org/80810 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'compilerplugins/Makefile-clang.mk')
-rw-r--r--compilerplugins/Makefile-clang.mk41
1 files changed, 40 insertions, 1 deletions
diff --git a/compilerplugins/Makefile-clang.mk b/compilerplugins/Makefile-clang.mk
index c6b3b208c7e0..9e6b7fd490b2 100644
--- a/compilerplugins/Makefile-clang.mk
+++ b/compilerplugins/Makefile-clang.mk
@@ -43,6 +43,10 @@ ifeq ($(OS),WNT)
LO_CLANG_SHARED_PLUGINS=
endif
+# Whether to use precompiled headers for the sources. This is actually controlled
+# by gb_ENABLE_PCH like everywhere else, but unsetting this disables PCH.
+LO_CLANG_USE_PCH=1
+
# Whether to use precompiled headers for the analyzer too. Does not apply to compiling sources.
LO_CLANG_USE_ANALYZER_PCH=1
@@ -100,6 +104,20 @@ CLANGWERROR := -Werror
endif
endif
+ifneq ($(LO_CLANG_USE_PCH),)
+# Reset and enable only if actually supported and enabled.
+LO_CLANG_USE_PCH=
+ifneq ($(gb_ENABLE_PCH),)
+ifneq ($(OS),WNT)
+# Currently only Clang PCH is supported (which should usually be the case, as Clang is usually self-built).
+ifneq ($(findstring clang,$(COMPILER_PLUGINS_CXX)),)
+LO_CLANG_USE_PCH=1
+endif
+endif
+endif
+endif
+
+
compilerplugins: compilerplugins-build
ifdef LO_CLANG_SHARED_PLUGINS
@@ -139,6 +157,7 @@ compilerplugins-clean:
$(CLANGOBJDIR) \
$(CLANGOUTDIR)/clang-timestamp \
$(CLANGOUTDIR)/plugin$(CLANG_DL_EXT) \
+ $(CLANGOUTDIR)/clang.pch{,.d} \
$(CLANGOUTDIR)/sharedvisitor/*.plugininfo \
$(CLANGOUTDIR)/sharedvisitor/clang.pch{,.d} \
$(CLANGOUTDIR)/sharedvisitor/sharedvisitor.{cxx,d,o} \
@@ -176,10 +195,12 @@ else
# clangbuildsrc cxxfile ofile dfile
define clangbuildsrc
-$(2): $(1) $(SRCDIR)/compilerplugins/Makefile-clang.mk $(CLANGOUTDIR)/clang-timestamp
+$(2): $(1) $(SRCDIR)/compilerplugins/Makefile-clang.mk $(CLANGOUTDIR)/clang-timestamp \
+ $(if $(LO_CLANG_USE_PCH),$(CLANGOUTDIR)/clang.pch)
$$(call gb_Output_announce,$(subst $(SRCDIR)/,,$(subst $(BUILDDIR)/,,$(1))),$(true),CXX,3)
$(QUIET)$(COMPILER_PLUGINS_CXX) $(CLANGDEFS) $(CLANGCXXFLAGS) $(CLANGWERROR) \
$(CLANGINCLUDES) -I$(BUILDDIR)/config_host -I$(CLANGINDIR) $(1) \
+ $(if $(LO_CLANG_USE_PCH),-include-pch $(CLANGOUTDIR)/clang.pch -DPCH_LEVEL=$(gb_ENABLE_PCH)) \
-fPIC -c -o $(2) -MMD -MT $(2) -MP -MF $(3)
-include $(3)
@@ -294,7 +315,25 @@ $(CLANGOUTDIR)/sources-shared.txt:
touch $@
endif
+ifneq ($(LO_CLANG_USE_PCH),)
+# the PCH for plugin sources themselves
+
+ifeq ($(OS),WNT)
+# TODO
+else
+$(CLANGOUTDIR)/clang.pch: $(CLANGINDIR)/precompiled_clang.hxx \
+ $(SRCDIR)/compilerplugins/Makefile-clang.mk $(CLANGOUTDIR)/clang-timestamp
+ $(call gb_Output_announce,$(subst $(BUILDDIR)/,,$@),$(true),PCH,1)
+ $(QUIET)$(COMPILER_PLUGINS_CXX) -x c++-header $(CLANGDEFS) $(CLANGCXXFLAGS) $(CLANGWERROR) \
+ $(CLANGINCLUDES) -I$(BUILDDIR)/config_host -I$(CLANGINDIR) -DPCH_LEVEL=$(gb_ENABLE_PCH) \
+ -fPIC $< -o $@ -MMD -MT $@ -MP -MF $(CLANGOUTDIR)/clang.pch.d
+endif
+-include $(CLANGOUTDIR)/clang.pch.d
+
+endif
+
ifdef LO_CLANG_USE_ANALYZER_PCH
+# the PCH for usage in sharedvisitor/analyzer
# these are from the invocation in analyzer.cxx
LO_CLANG_ANALYZER_PCH_CXXFLAGS := -I$(BUILDDIR)/config_host $(CLANGTOOLDEFS)