summaryrefslogtreecommitdiff
path: root/solenv
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2017-09-29 08:37:45 +0200
committerStephan Bergmann <sbergman@redhat.com>2017-09-30 11:28:43 +0200
commit39e7a72b3e328e6b3d87479d693b01315610457b (patch)
tree2e07a1fe514a34fcca223a8e608c32a53ce475ad /solenv
parent6a9d90fd4d89359ec11711e581010011fd25807b (diff)
Support loplugin in clang-cl
This works at least with a recent Clang trunk (towards Clang 6.0). In order for the plugin.dll to find the LLVM/Clang symbols, it needs to be loaded into clang.exe not clang-cl.exe, so set CC/CXX to 'clang.exe --driver-mode=cl ...'. Buidling the plugin requires some linker flags that must go at the very end of the COMPILER_PLUGINS_CXX command line, after a /link switch, so introduce another COMPILER_PLUGINS_CXX_LINKFLAGS variable for that. Also, clang.lib is not installed as part of LLVM's 'cmake --build ... --target install' step, so is not available under CLANGDIR and needs to be taken from the build tree instead, so introduce another CLANGLIBDIR variable for that. autogen.input settings that work for me on Windows 8.1 with Microsoft Visual Studio 14.0 are: > CLANGDIR=C:/llvm/inst > CLANGLIBDIR=C:/llvm/build/lib > COMPILER_PLUGINS_CXX=C:/PROGRA~2/MICROS~3.0/VC/bin/amd64/cl.exe /IC:\PROGRA~2\MICROS~3.0\VC\INCLUDE /IC:\PROGRA~2\MICROS~3.0\VC\ATLMFC\INCLUDE /IC:\PROGRA~2\WI3CF2~1\10\include\100102~1.0\ucrt /IC:\PROGRA~2\WI3CF2~1\NETFXSDK\46D346~1.1\include\um /IC:\PROGRA~2\WI3CF2~1\8.1\include\shared /IC:\PROGRA~2\WI3CF2~1\8.1\include\um /IC:\PROGRA~2\WI3CF2~1\8.1\include\winrt > COMPILER_PLUGINS_CXX_LINKFLAGS=/LIBPATH:C:/PROGRA~2/MICROS~3.0/VC/LIB/amd64 /LIBPATH:C:/PROGRA~2/MICROS~3.0/VC/ATLMFC/LIB/amd64 /LIBPATH:C:/PROGRA~2/WI3CF2~1/10/lib/100102~1.0/ucrt/x64 /LIBPATH:C:/PROGRA~2/WI3CF2~1/NETFXSDK/46D346~1.1/lib/um/x64 /LIBPATH:C:/PROGRA~2/WI3CF2~1/8.1/lib/winv6.3/um/x64 (The last two are "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/ amd64/cl.exe" and translations of %INCLUDE% and %LIB% as set in the "VS2015 x64 Native Tools Command Prompt" shell. AC_CHECK_HEADER(clang/AST/RecursiveASTVisitor.h, ...) in configure.ac wouldn't like CXX to start with INCLUDE=... LIB=... environment variable settings, so it wouldn't work to instead pass %INCLUDE% and %LIB% to cl.exe that way. See <https://wiki.documentfoundation.org/Development/clang-cl> for general information about building with clang-cl on Windows.) There's still some room for improvement marked "TODO". (And some of the unused* plugins, which are not run by default anyway, use Unix-style functionality, so have been disabled for now.) Change-Id: I6c28bdeb801af39ce2bae03111f455e2338d66c9 Reviewed-on: https://gerrit.libreoffice.org/42931 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'solenv')
-rw-r--r--solenv/gbuild/platform/com_MSC_class.mk8
-rw-r--r--solenv/gbuild/platform/com_MSC_defs.mk24
2 files changed, 28 insertions, 4 deletions
diff --git a/solenv/gbuild/platform/com_MSC_class.mk b/solenv/gbuild/platform/com_MSC_class.mk
index 79107f926760..660ba83d73ef 100644
--- a/solenv/gbuild/platform/com_MSC_class.mk
+++ b/solenv/gbuild/platform/com_MSC_class.mk
@@ -49,16 +49,18 @@ $(call gb_Helper_abbreviate_dirs,\
$(if $(EXTERNAL_CODE), \
$(if $(filter -clr,$(2)),,$(if $(COM_IS_CLANG),-Wno-undef)), \
$(gb_DEFS_INTERNAL)) \
- $(if $(WARNINGS_NOT_ERRORS),,$(gb_CFLAGS_WERROR)) \
+ $(if $(WARNINGS_NOT_ERRORS),$(if $(ENABLE_WERROR),$(if $(PLUGIN_WARNINGS_AS_ERRORS),$(gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS))),$(gb_CFLAGS_WERROR)) \
+ $(if $(filter -clr,$(2)),,$(if $(5),$(gb_COMPILER_PLUGINS))) \
+ $(if $(COMPILER_TEST),-fsyntax-only -ferror-limit=0 -Xclang -verify) \
-Fd$(PDBFILE) \
$(PCHFLAGS) \
- $(gb_COMPILERDEPFLAGS) \
+ $(if $(COMPILER_TEST),,$(gb_COMPILERDEPFLAGS)) \
-I$(dir $(3)) \
$(INCLUDE) \
$(if $(filter YES,$(CXXOBJECT_X64)), -U_X86_ -D_AMD64_,) \
-c $(3) \
-Fo$(1)) $(if $(filter $(true),$(gb_SYMBOL)),/link /DEBUG:FASTLINK) \
- $(call gb_create_deps,$(4),$(1),$(3))
+ $(if $(COMPILER_TEST),,$(call gb_create_deps,$(4),$(1),$(3)))
endef
# PrecompiledHeader class
diff --git a/solenv/gbuild/platform/com_MSC_defs.mk b/solenv/gbuild/platform/com_MSC_defs.mk
index 9aa1435a5a94..dd3e31952ed8 100644
--- a/solenv/gbuild/platform/com_MSC_defs.mk
+++ b/solenv/gbuild/platform/com_MSC_defs.mk
@@ -224,7 +224,7 @@ gb_PCHWARNINGS = \
gb_STDLIBS := \
advapi32.lib \
-gb_CFLAGS_WERROR := $(if $(ENABLE_WERROR),-WX)
+gb_CFLAGS_WERROR = $(if $(ENABLE_WERROR),-WX)
# there does not seem to be a way to force C++03 with MSVC
gb_CXX03FLAGS :=
@@ -301,6 +301,28 @@ gb_CXXFLAGS += \
endif
+ifeq ($(COM_IS_CLANG),TRUE)
+gb_COMPILER_TEST_FLAGS := -Xclang -plugin-arg-loplugin -Xclang --unit-test-mode
+ifeq ($(COMPILER_PLUGIN_TOOL),)
+gb_COMPILER_PLUGINS := -Xclang -load -Xclang $(BUILDDIR)/compilerplugins/obj/plugin.dll -Xclang -add-plugin -Xclang loplugin
+ifneq ($(COMPILER_PLUGIN_WARNINGS_ONLY),)
+gb_COMPILER_PLUGINS += -Xclang -plugin-arg-loplugin -Xclang \
+ --warnings-only='$(COMPILER_PLUGIN_WARNINGS_ONLY)'
+endif
+else
+gb_COMPILER_PLUGINS := -Xclang -load -Xclang $(BUILDDIR)/compilerplugins/obj/plugin.dll -Xclang -plugin -Xclang loplugin $(foreach plugin,$(COMPILER_PLUGIN_TOOL), -Xclang -plugin-arg-loplugin -Xclang $(plugin))
+ifneq ($(UPDATE_FILES),)
+gb_COMPILER_PLUGINS += -Xclang -plugin-arg-loplugin -Xclang --scope=$(UPDATE_FILES)
+endif
+endif
+gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS := \
+ -Xclang -plugin-arg-loplugin -Xclang --warnings-as-errors
+else
+gb_COMPILER_TEST_FLAGS :=
+gb_COMPILER_PLUGINS :=
+gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS :=
+endif
+
# Helper class
ifeq ($(GNUMAKE_WIN_NATIVE),TRUE)