diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2019-09-03 16:17:14 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2019-09-06 12:07:23 +0200 |
commit | dc79dc76f18148296ae18ed7251cf61505e25d44 (patch) | |
tree | 65edee50f0c257c578f8459dbfcdc9db61c52e5a /compilerplugins | |
parent | ceb26770b3d1c5c2ffaf73f8f589c5e169e6db06 (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')
-rw-r--r-- | compilerplugins/Makefile-clang.mk | 27 | ||||
-rw-r--r-- | compilerplugins/clang/sharedvisitor/analyzer.cxx | 9 | ||||
-rw-r--r-- | compilerplugins/clang/sharedvisitor/precompiled_clang.hxx | 12 |
3 files changed, 44 insertions, 4 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: diff --git a/compilerplugins/clang/sharedvisitor/analyzer.cxx b/compilerplugins/clang/sharedvisitor/analyzer.cxx index 171fc8528a28..5b716f407fd4 100644 --- a/compilerplugins/clang/sharedvisitor/analyzer.cxx +++ b/compilerplugins/clang/sharedvisitor/analyzer.cxx @@ -243,14 +243,19 @@ int main(int argc, char** argv) #define STRINGIFY(a) STRINGIFY2(a) args.insert( args.end(), - { + { // These must match LO_CLANG_ANALYZER_PCH_CXXFLAGS in Makefile-clang.mk . "-I" BUILDDIR "/config_host", // plugin sources use e.g. config_global.h "-I" STRINGIFY(CLANGDIR) "/include", // clang's headers "-I" STRINGIFY(CLANGSYSINCLUDE), // clang system headers STDOPTION, "-D__STDC_CONSTANT_MACROS", // Clang headers require these. "-D__STDC_FORMAT_MACROS", - "-D__STDC_LIMIT_MACROS", + "-D__STDC_LIMIT_MACROS" +#ifdef LO_CLANG_USE_ANALYZER_PCH + , + "-include-pch", // use PCH with Clang headers to speed up parsing/analysing + BUILDDIR "/compilerplugins/clang/sharedvisitor/clang.pch" +#endif }); for( ; i < argc; ++ i ) { diff --git a/compilerplugins/clang/sharedvisitor/precompiled_clang.hxx b/compilerplugins/clang/sharedvisitor/precompiled_clang.hxx new file mode 100644 index 000000000000..3baf4b04f6f8 --- /dev/null +++ b/compilerplugins/clang/sharedvisitor/precompiled_clang.hxx @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +// Used by the analyzer to speed up processing plugin sources. + +#include "../plugin.hxx" |