summaryrefslogtreecommitdiff
path: root/compilerplugins/Makefile-clang.mk
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2019-09-03 16:17:14 +0200
committerLuboš Luňák <l.lunak@collabora.com>2019-09-06 12:07:23 +0200
commitdc79dc76f18148296ae18ed7251cf61505e25d44 (patch)
tree65edee50f0c257c578f8459dbfcdc9db61c52e5a /compilerplugins/Makefile-clang.mk
parentceb26770b3d1c5c2ffaf73f8f589c5e169e6db06 (diff)
make clangplugin analyzer use internally a PCH to speed things up
This generally makes the sharedvisitor performance reasonable. The only costly thing that remains is compiling the large sharedvisitor.cxx, which with optimizations takes quite some time, but there's ccache for that. Change-Id: Iffa5fc9df34cdb5edf1cde34fc558fd007ef8263 Reviewed-on: https://gerrit.libreoffice.org/78569 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.mk27
1 files changed, 25 insertions, 2 deletions
diff --git a/compilerplugins/Makefile-clang.mk b/compilerplugins/Makefile-clang.mk
index 4fd3f7724032..c36bc6bd18cb 100644
--- a/compilerplugins/Makefile-clang.mk
+++ b/compilerplugins/Makefile-clang.mk
@@ -42,6 +42,9 @@ ifeq ($(OS),WNT)
LO_CLANG_SHARED_PLUGINS=
endif
+# Whether to use precompiled headers for the analyzer too. Does not apply to compiling sources.
+LO_CLANG_USE_ANALYZER_PCH=1
+
# The uninteresting rest.
include $(SRCDIR)/solenv/gbuild/gbuild.mk
@@ -207,7 +210,9 @@ ifdef LO_CLANG_SHARED_PLUGINS
SHARED_SOURCES := $(shell grep -l "LO_CLANG_SHARED_PLUGINS" $(CLANGINDIR)/*.cxx)
SHARED_SOURCE_INFOS := $(foreach source,$(SHARED_SOURCES),$(patsubst $(CLANGINDIR)/%.cxx,$(CLANGOUTDIR)/sharedvisitor/%.plugininfo,$(source)))
-$(CLANGOUTDIR)/sharedvisitor/%.plugininfo: $(CLANGINDIR)/%.cxx $(CLANGOUTDIR)/sharedvisitor/analyzer$(CLANG_EXE_EXT)
+$(CLANGOUTDIR)/sharedvisitor/%.plugininfo: $(CLANGINDIR)/%.cxx \
+ $(CLANGOUTDIR)/sharedvisitor/analyzer$(CLANG_EXE_EXT) \
+ $(CLANGOUTDIR)/sharedvisitor/clang.pch
$(call gb_Output_announce,$(subst $(BUILDDIR)/,,$@),$(true),GEN,1)
$(QUIET)$(ICECREAM_RUN) $(CLANGOUTDIR)/sharedvisitor/analyzer$(CLANG_EXE_EXT) \
$(COMPILER_PLUGINS_TOOLING_ARGS:%=-arg=%) $< > $@
@@ -222,7 +227,8 @@ CLANGTOOLLIBS = -lclangTooling -lclangDriver -lclangFrontend -lclangParse -lclan
# Path to the clang system headers (no idea if there's a better way to get it).
CLANGTOOLDEFS = -DCLANGSYSINCLUDE=$(shell $(LLVMCONFIG) --libdir)/clang/$(shell $(LLVMCONFIG) --version | sed 's/svn//')/include
# -std=c++11 is in line with the default value for COMPILER_PLUGINS_CXX in configure.ac:
-CLANGTOOLDEFS += -DSTDOPTION=\"$(or $(filter -std=%,$(COMPILER_PLUGINS_CXX)),-std=c++11)\"
+CLANGSTDOPTION := $(or $(filter -std=%,$(COMPILER_PLUGINS_CXX)),-std=c++11)
+CLANGTOOLDEFS += -DSTDOPTION=\"$(CLANGSTDOPTION)\"
ifneq ($(filter-out MACOSX WNT,$(OS)),)
ifneq ($(CLANGDIR),/usr)
# Help the generator find Clang shared libs, if Clang is built so and installed in a non-standard prefix.
@@ -235,6 +241,7 @@ $(CLANGOUTDIR)/sharedvisitor/analyzer$(CLANG_EXE_EXT): $(CLANGINDIR)/sharedvisit
$(call gb_Output_announce,$(subst $(BUILDDIR)/,,$@),$(true),GEN,1)
$(QUIET)$(COMPILER_PLUGINS_CXX) $(CLANGCXXFLAGS) $(CLANGWERROR) $(CLANGDEFS) $(CLANGTOOLDEFS) $(CLANGINCLUDES) \
-DCLANGDIR=$(CLANGDIR) -I$(BUILDDIR)/config_host \
+ -DLO_CLANG_USE_ANALYZER_PCH=$(LO_CLANG_USE_ANALYZER_PCH) \
-c $< -o $(CLANGOUTDIR)/sharedvisitor/analyzer.o -MMD -MT $@ -MP \
-MF $(CLANGOUTDIR)/sharedvisitor/analyzer.d
$(QUIET)$(COMPILER_PLUGINS_CXX) $(CLANGCXXFLAGS) $(CLANGOUTDIR)/sharedvisitor/analyzer.o \
@@ -261,4 +268,20 @@ $(CLANGOUTDIR)/sharedvisitor:
# TODO WNT version
endif
+ifdef LO_CLANG_USE_ANALYZER_PCH
+
+# these are from the invocation in analyzer.cxx
+LO_CLANG_ANALYZER_PCH_CXXFLAGS := -I$(BUILDDIR)/config_host -I$(CLANGDIR)/include $(CLANGTOOLDEFS) $(CLANGSTDOPTION) \
+ -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
+
+$(CLANGOUTDIR)/sharedvisitor/clang.pch: $(CLANGINDIR)/sharedvisitor/precompiled_clang.hxx \
+ $(CLANGOUTDIR)/clang-timestamp \
+ | $(CLANGOUTDIR)/sharedvisitor
+ $(call gb_Output_announce,$(subst $(BUILDDIR)/,,$@),$(true),PCH,1)
+ $(QUIET)$(CLANGDIR)/bin/clang -x c++-header $(LO_CLANG_ANALYZER_PCH_CXXFLAGS) $< -o $@
+else
+$(CLANGOUTDIR)/sharedvisitor/clang.pch:
+ touch $@
+endif
+
# vim: set noet sw=4 ts=4: