[Libreoffice-commits] core.git: cli_ure/Executable_climaker.mk cli_ure/Library_cli_cppuhelper_native.mk cli_ure/Library_cli_uno.mk config_host.mk.in configure.ac solenv/clang-cl solenv/gbuild solenv/qa

Stephan Bergmann sbergman at redhat.com
Tue Feb 21 10:19:23 UTC 2017


 cli_ure/Executable_climaker.mk                |    7 --
 cli_ure/Library_cli_cppuhelper_native.mk      |   13 ---
 cli_ure/Library_cli_uno.mk                    |    9 --
 config_host.mk.in                             |    1 
 configure.ac                                  |   21 ++++--
 solenv/clang-cl/config_global.h               |   21 ++++++
 solenv/gbuild/CompilerTest.mk                 |    2 
 solenv/gbuild/CppunitTest.mk                  |    3 
 solenv/gbuild/Executable.mk                   |    3 
 solenv/gbuild/Library.mk                      |    3 
 solenv/gbuild/LinkTarget.mk                   |   91 +++++++++++++++++++++++++-
 solenv/gbuild/StaticLibrary.mk                |    3 
 solenv/gbuild/TargetLocations.mk              |    2 
 solenv/gbuild/extensions/post_GbuildToJson.mk |    7 ++
 solenv/gbuild/platform/com_MSC_class.mk       |   10 ++
 solenv/gbuild/platform/com_MSC_defs.mk        |   57 +++++++++-------
 solenv/qa/python/gbuildtojson.py              |    2 
 17 files changed, 198 insertions(+), 57 deletions(-)

New commits:
commit 0a99b5a1b7325454fe3d1174d44354888aa22012
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Feb 20 16:28:06 2017 +0100

    When building with clang-cl on Windows, build CLR code with MSVC
    
    ...as clang-cl doesn't support the /clr switch.
    
    * In configure.ac, capture the MSCV version (that would be used if CC hadn't
      been overridden to use clang-cl) into MSVC_CXX.
    
    * The logic which flags to pass into gb_CObject__command_pattern is coded into
      the platform-agnostic LinkTarget.mk, so it's too late to try and filter all
      relevant flags in com_GCC_class.mk, depending on whether a given .cxx file is
      a normal one built with the normal $CXX or a special /clr one built with
      $MSVC_CXX.  Thus, a new CxxClrObject class had to be introduced that captures
      this information early.
    
    * When building with clang-cl, the generated config_host/config_*.h files
      contain values suitable for clang-cl, but not for MSVC.  But the .cxx files
      compiled with MSVC happen to include config_global.h, and would fail.  Hack
      around that problem for now by introducing a hard-coded, minimal
      solenv/clang-cl/config_global.h that is found first when buliding such a
      CxxClrObject.  Needs cleaning-up properly.
    
    Change-Id: Iff8aac51c0b4fa906b14503c692640dda0996d33
    Reviewed-on: https://gerrit.libreoffice.org/34509
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/cli_ure/Executable_climaker.mk b/cli_ure/Executable_climaker.mk
index 298f01e..6f1a37b 100644
--- a/cli_ure/Executable_climaker.mk
+++ b/cli_ure/Executable_climaker.mk
@@ -13,11 +13,8 @@ $(eval $(call gb_Executable_use_package,climaker,\
 	cli_basetypes_copy \
 ))
 
-$(eval $(call gb_Executable_add_cxxflags,climaker,\
-	-AI $(INSTDIR)/$(LIBO_URE_LIB_FOLDER) \
-	-EHa -clr \
+$(eval $(call gb_Executable_add_cxxclrflags,climaker,\
 	-LN \
-	-wd4339 \
 	-wd4715 \
 ))
 
@@ -43,7 +40,7 @@ $(eval $(call gb_Executable_use_system_win32_libs,climaker,\
 	msvcmrt \
 ))
 
-$(eval $(call gb_Executable_add_exception_objects,climaker,\
+$(eval $(call gb_Executable_add_cxxclrobjects,climaker,\
 	cli_ure/source/climaker/climaker_app \
 	cli_ure/source/climaker/climaker_emit \
 ))
diff --git a/cli_ure/Library_cli_cppuhelper_native.mk b/cli_ure/Library_cli_cppuhelper_native.mk
index 52314a3..bb230fb 100644
--- a/cli_ure/Library_cli_cppuhelper_native.mk
+++ b/cli_ure/Library_cli_cppuhelper_native.mk
@@ -11,15 +11,6 @@ include $(SRCDIR)/cli_ure/version/version.txt
 
 $(eval $(call gb_Library_Assembly,cli_cppuhelper))
 
-# When compiling for CLR, disable "warning C4339: use of undefined type detected
-# in CLR meta-data - use of this type may lead to a runtime exception":
-$(eval $(call gb_Library_add_cxxflags,cli_cppuhelper,\
-	-AI $(INSTDIR)/$(LIBO_URE_LIB_FOLDER) \
-	-EHa \
-	-clr \
-	-wd4339 \
-))
-
 $(eval $(call gb_Library_add_ldflags,cli_cppuhelper,\
 	-ignore:4248 \
 	-keyfile:$(SRCDIR)/cli_ure/source/cliuno.snk \
@@ -48,12 +39,12 @@ $(eval $(call gb_Library_use_system_win32_libs,cli_cppuhelper,\
 	msvcmrt \
 ))
 
-$(eval $(call gb_Library_add_exception_objects,cli_cppuhelper,\
+$(eval $(call gb_Library_add_cxxclrobjects,cli_cppuhelper,\
 	cli_ure/source/native/native_bootstrap \
 	cli_ure/source/native/path \
 ))
 
-$(eval $(call gb_Library_add_generated_exception_objects,cli_cppuhelper,\
+$(eval $(call gb_Library_add_generated_cxxclrobjects,cli_cppuhelper,\
 	CustomTarget/cli_ure/source/native/assembly \
 ))
 
diff --git a/cli_ure/Library_cli_uno.mk b/cli_ure/Library_cli_uno.mk
index 0629a17..75eadae 100644
--- a/cli_ure/Library_cli_uno.mk
+++ b/cli_ure/Library_cli_uno.mk
@@ -9,13 +9,6 @@
 
 $(eval $(call gb_Library_Library,cli_uno))
 
-$(eval $(call gb_Library_add_cxxflags,cli_uno,\
-	-AI $(INSTDIR)/$(LIBO_URE_LIB_FOLDER) \
-	-EHa \
-	-clr \
-	-wd4339 \
-))
-
 $(eval $(call gb_Library_add_ldflags,cli_uno,\
 	-ignore:4248 \
 ))
@@ -32,7 +25,7 @@ $(eval $(call gb_Library_use_system_win32_libs,cli_uno,\
 	msvcmrt \
 ))
 
-$(eval $(call gb_Library_add_exception_objects,cli_uno,\
+$(eval $(call gb_Library_add_cxxclrobjects,cli_uno,\
     cli_ure/source/uno_bridge/cli_bridge \
     cli_ure/source/uno_bridge/cli_data \
     cli_ure/source/uno_bridge/cli_environment \
diff --git a/config_host.mk.in b/config_host.mk.in
index f07cc04..71362a4 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -392,6 +392,7 @@ export MPL_SUBSET=@MPL_SUBSET@
 export MSM_PATH=@MSM_PATH@
 export MSPUB_CFLAGS=$(gb_SPACE)@MSPUB_CFLAGS@
 export MSPUB_LIBS=$(gb_SPACE)@MSPUB_LIBS@
+export MSVC_CXX=@MSVC_CXX@
 export MSVC_DLLS=@MSVC_DLLS@
 export MSVC_DLL_PATH=@MSVC_DLL_PATH@
 export MSVC_USE_DEBUG_RUNTIME=@MSVC_USE_DEBUG_RUNTIME@
diff --git a/configure.ac b/configure.ac
index 9259c4d..42bab2e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3558,25 +3558,35 @@ if test "$_os" = "WINNT"; then
     # location, isn't it likely that lots of other things needs changes, too, and just setting CC
     # is not enough?
 
-    if test -z "$CC"; then
+    dnl Save the true MSVC cl.exe for use when CC/CXX is actually clang-cl,
+    dnl needed when building CLR code:
+    if test -z "$MSVC_CXX"; then
         if test "$BITNESS_OVERRIDE" = ""; then
             if test -f "$VC_PRODUCT_DIR/bin/cl.exe"; then
-                CC="$VC_PRODUCT_DIR/$CL_DIR/cl.exe"
+                MSVC_CXX="$VC_PRODUCT_DIR/$CL_DIR/cl.exe"
             fi
         else
             if test "$vcexpress" = "Express"; then
                if test -f "$VC_PRODUCT_DIR/bin/x86_amd64/cl.exe"; then
-                    CC="$VC_PRODUCT_DIR/bin/x86_amd64/cl.exe"
+                    MSVC_CXX="$VC_PRODUCT_DIR/bin/x86_amd64/cl.exe"
                fi
             else
                if test -f "$VC_PRODUCT_DIR/$CL_DIR/cl.exe"; then
-                    CC="$VC_PRODUCT_DIR/$CL_DIR/cl.exe"
+                    MSVC_CXX="$VC_PRODUCT_DIR/$CL_DIR/cl.exe"
                fi
             fi
         fi
 
         # This gives us a posix path with 8.3 filename restrictions
-        CC=`win_short_path_for_make "$CC"`
+        MSVC_CXX=`win_short_path_for_make "$MSVC_CXX"`
+    fi
+
+    if test -z "$CC"; then
+        CC=$MSVC_CXX
+    fi
+    if test "$BITNESS_OVERRIDE" = ""; then
+        dnl since MSVC 2012, default for x86 is -arch:SSE2:
+        MSVC_CXX="$MSVC_CXX -arch:SSE"
     fi
 
     if test -n "$CC"; then
@@ -3720,6 +3730,7 @@ AC_SUBST(VCVER)
 AC_SUBST(DEVENV)
 PathFormat "$MSPDB_PATH"
 MSPDB_PATH="$formatted_path"
+AC_SUBST(MSVC_CXX)
 AC_SUBST(SHOWINCLUDES_PREFIX)
 
 if test "$_os" = "WINNT"; then
diff --git a/solenv/clang-cl/config_global.h b/solenv/clang-cl/config_global.h
new file mode 100755
index 0000000..80120f1
--- /dev/null
+++ b/solenv/clang-cl/config_global.h
@@ -0,0 +1,21 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * 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/.
+ */
+
+/* A partial copy of config_host/config_global.h.in, with hardcoded values that
+   suffice to compile CxxClr code in cli_ure/ with MSVC when building the rest
+   with clang-cl.  A bad hack, should be replaced with a better copy that is
+   actually filled in by configure.
+*/
+
+#ifndef CONFIG_GLOBAL_H
+#define CONFIG_GLOBAL_H
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/solenv/gbuild/CompilerTest.mk b/solenv/gbuild/CompilerTest.mk
index 4178b51..a495cf3 100644
--- a/solenv/gbuild/CompilerTest.mk
+++ b/solenv/gbuild/CompilerTest.mk
@@ -40,6 +40,8 @@ $(eval $(foreach method, \
     add_objcobjects \
     add_objcxxobject \
     add_objcxxobjects \
+    add_cxxclrobject \
+    add_cxxclrobjects \
     use_udk_api \
 , \
     $(call gb_CompilerTest__forward_to_Linktarget,$(method)) \
diff --git a/solenv/gbuild/CppunitTest.mk b/solenv/gbuild/CppunitTest.mk
index a916e49..23ea06a 100644
--- a/solenv/gbuild/CppunitTest.mk
+++ b/solenv/gbuild/CppunitTest.mk
@@ -423,6 +423,8 @@ $(eval $(foreach method,\
 	add_objcobjects \
 	add_objcxxobject \
 	add_objcxxobjects \
+	add_cxxclrobject \
+	add_cxxclrobjects \
 	add_asmobject \
 	add_asmobjects \
 	use_package \
@@ -435,6 +437,7 @@ $(eval $(foreach method,\
 	set_yaccflags \
 	add_objcflags \
 	add_objcxxflags \
+	add_cxxclrflags \
 	add_defs \
 	set_include \
 	add_ldflags \
diff --git a/solenv/gbuild/Executable.mk b/solenv/gbuild/Executable.mk
index cef95d5..afe4ddf 100644
--- a/solenv/gbuild/Executable.mk
+++ b/solenv/gbuild/Executable.mk
@@ -99,6 +99,8 @@ $(eval $(foreach method,\
 	add_objcobjects \
 	add_objcxxobject \
 	add_objcxxobjects \
+	add_cxxclrobject \
+	add_cxxclrobjects \
 	add_grammar \
 	add_grammars \
 	add_scanner \
@@ -111,6 +113,7 @@ $(eval $(foreach method,\
 	add_cxxflags \
 	add_objcflags \
 	add_objcxxflags \
+	add_cxxclrflags \
 	add_defs \
 	set_include \
 	add_ldflags \
diff --git a/solenv/gbuild/Library.mk b/solenv/gbuild/Library.mk
index 8042f33..18640d6 100644
--- a/solenv/gbuild/Library.mk
+++ b/solenv/gbuild/Library.mk
@@ -175,6 +175,8 @@ $(eval $(foreach method,\
 	add_objcobjects \
 	add_objcxxobject \
 	add_objcxxobjects \
+	add_cxxclrobject \
+	add_cxxclrobjects \
 	add_asmobject \
 	add_asmobjects \
 	add_exception_objects \
@@ -191,6 +193,7 @@ $(eval $(foreach method,\
 	add_cxxflags \
 	add_objcxxflags \
 	add_objcflags \
+	add_cxxclrflags \
 	add_defs \
 	set_include \
 	add_ldflags \
diff --git a/solenv/gbuild/LinkTarget.mk b/solenv/gbuild/LinkTarget.mk
index ca1f5ad..5d192df 100644
--- a/solenv/gbuild/LinkTarget.mk
+++ b/solenv/gbuild/LinkTarget.mk
@@ -60,6 +60,7 @@ gb_LinkTarget__get_cflags=$(if $(CFLAGS),$(CFLAGS),$(call gb_LinkTarget__get_deb
 gb_LinkTarget__get_objcflags=$(if $(OBJCFLAGS),$(OBJCFLAGS),$(call gb_LinkTarget__get_debugcflags,$(1)))
 gb_LinkTarget__get_cxxflags=$(if $(CXXFLAGS),$(CXXFLAGS),$(call gb_LinkTarget__get_debugcxxflags,$(1)))
 gb_LinkTarget__get_objcxxflags=$(if $(OBJCXXFLAGS),$(OBJCXXFLAGS),$(call gb_LinkTarget__get_debugcxxflags,$(1)))
+gb_LinkTarget__get_cxxclrflags=$(call gb_LinkTarget__get_debugcxxflags,$(1))
 # call gb_LinkTarget__get_ldflags,linktargetmakefilename
 gb_LinkTarget__get_ldflags=$(if $(LDFLAGS),$(LDFLAGS),$(call gb_LinkTarget__get_debugldflags,$(1)))
 
@@ -150,14 +151,31 @@ $(call gb_Helper_abbreviate_dirs,\
 		$(INCLUDE) \
 		)
 endef
+define gb_CxxClrObject__tool_command
+$(call gb_Output_announce,$(1).cxx,$(true),CLR,3)
+$(call gb_Helper_abbreviate_dirs,\
+        ICECC=no CCACHE_DISABLE=1 \
+	$(gb_CXX) \
+		$(DEFS) \
+		$(gb_LTOFLAGS) \
+		$(if $(VISIBILITY),,$(gb_VISIBILITY_FLAGS)) \
+		$(if $(WARNINGS_NOT_ERRORS),$(if $(ENABLE_WERROR),$(if $(PLUGIN_WARNINGS_AS_ERRORS),$(gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS))),$(gb_CFLAGS_WERROR)) \
+		$(gb_COMPILER_PLUGINS) \
+		$(T_CXXCLRFLAGS) $(T_CXXCLRFLAGS_APPEND) \
+		$(if $(EXTERNAL_CODE),$(gb_CXXFLAGS_Wundef),$(gb_DEFS_INTERNAL)) \
+		-c $(2) \
+		-I$(dir $(2)) \
+		$(INCLUDE) \
+		)
+endef
 
 
 # Overview of dependencies and tasks of LinkTarget
 #
 # target                      task                         depends on
-# LinkTarget                  linking                      AsmObject CObject CxxObject GenCObject GenCxxObject ObjCObject ObjCxxObject
+# LinkTarget                  linking                      AsmObject CObject CxxObject GenCObject GenCxxObject ObjCObject ObjCxxObject CxxClrObject
 #                                                          LinkTarget/headers
-# LinkTarget/dep              joined dep file              AsmObject/dep CObject/dep CxxObject/dep GenCObject/dep GenCxxObject/dep ObjCObject/dep ObjCxxObject/dep
+# LinkTarget/dep              joined dep file              AsmObject/dep CObject/dep CxxObject/dep GenCObject/dep GenCxxObject/dep ObjCObject/dep ObjCxxObject/dep CxxClrObject/dep
 #                                                          | LinkTarget/headers
 # LinkTarget/headers          all headers available
 #                             including own generated
@@ -170,6 +188,7 @@ endef
 #                              generated source
 # ObjCObject                  objective c compile          | LinkTarget/headers
 # ObjCxxObject                objective c++ compile        | LinkTarget/headers
+# CxxClrObject                C++ CLR compile              | LinkTarget/headers
 #
 # AsmObject                   asm compile                  | LinkTarget
 #
@@ -179,6 +198,7 @@ endef
 # GenCxxObject/dep            dependencies
 # ObjCObject/dep            dependencies
 # ObjCxxObject/dep            dependencies
+# CxxClrObject/dep            dependencies
 # AsmObject/dep               dependencies
 
 # LinkTarget/headers means gb_LinkTarget_get_headers_target etc.
@@ -443,6 +463,33 @@ $(call gb_ObjCObject_get_dep_target,%) :
 endif
 
 
+# CxxClrObject class
+#
+
+gb_CxxClrObject_get_source = $(1)/$(2).cxx
+
+ifneq ($(COMPILER_EXTERNAL_TOOL)$(COMPILER_PLUGIN_TOOL),)
+$(call gb_CxxClrObject_get_target,%) : $(call gb_CxxClrObject_get_source,$(SRCDIR),%) $(gb_FORCE_COMPILE_ALL_TARGET)
+	$(call gb_CxxClrObject__tool_command,$*,$<)
+else
+$(call gb_CxxClrObject_get_target,%) : $(call gb_CxxClrObject_get_source,$(SRCDIR),%)
+	$(call gb_Output_announce,$*.cxx,$(true),$(if $(COMPILER_TEST),C?R,CLR),3)
+	$(call gb_CObject__command_pattern,$@,$(T_CXXCLRFLAGS) $(T_CXXCLRFLAGS_APPEND),$<,$(call gb_CxxClrObject_get_dep_target,$*),$(COMPILER_PLUGINS))
+endif
+
+ifeq ($(gb_FULLDEPS),$(true))
+$(dir $(call gb_CxxClrObject_get_dep_target,%)).dir :
+	$(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
+
+$(dir $(call gb_CxxClrObject_get_dep_target,%))%/.dir :
+	$(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
+
+$(call gb_CxxClrObject_get_dep_target,%) :
+	$(if $(wildcard $@),touch $@)
+
+endif
+
+
 # AsmObject class
 
 $(call gb_AsmObject_get_target,%) : $(call gb_AsmObject_get_source,$(SRCDIR),%)
@@ -477,6 +524,8 @@ $(WORKDIR)/Clean/LinkTarget/% :
 		$(foreach object,$(OBJCOBJECTS),$(call gb_ObjCObject_get_dep_target,$(object))) \
 		$(foreach object,$(OBJCXXOBJECTS),$(call gb_ObjCxxObject_get_target,$(object))) \
 		$(foreach object,$(OBJCXXOBJECTS),$(call gb_ObjCxxObject_get_dep_target,$(object))) \
+		$(foreach object,$(CXXCLROBJECTS),$(call gb_CxxClrObject_get_target,$(object))) \
+		$(foreach object,$(CXXCLROBJECTS),$(call gb_CxxClrObject_get_dep_target,$(object))) \
 		$(foreach object,$(ASMOBJECTS),$(call gb_AsmObject_get_target,$(object))) \
 		$(foreach object,$(ASMOBJECTS),$(call gb_AsmObject_get_dep_target,$(object))) \
 		$(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_target,$(object))) \
@@ -504,6 +553,7 @@ $(call gb_Helper_abbreviate_dirs,\
 		$(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_dep_target,$(object))) \
 		$(foreach object,$(OBJCOBJECTS),$(call gb_ObjCObject_get_dep_target,$(object)))\
 		$(foreach object,$(OBJCXXOBJECTS),$(call gb_ObjCxxObject_get_dep_target,$(object)))\
+		$(foreach object,$(CXXCLROBJECTS),$(call gb_CxxClrObject_get_dep_target,$(object)))\
 		$(foreach object,$(ASMOBJECTS),$(call gb_AsmObject_get_dep_target,$(object)))\
 		$(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_dep_target,$(object))) \
 		$(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_dep_target,$(object))) \
@@ -520,6 +570,7 @@ TEMPFILE=$(call var2file,$(shell $(gb_MKTEMP)),200,\
 	$(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \
 	$(foreach object,$(OBJCOBJECTS),$(call gb_ObjCObject_get_target,$(object))) \
 	$(foreach object,$(OBJCXXOBJECTS),$(call gb_ObjCxxObject_get_target,$(object))) \
+	$(foreach object,$(CXXCLROBJECTS),$(call gb_CxxClrObject_get_target,$(object))) \
 	$(foreach object,$(ASMOBJECTS),$(call gb_AsmObject_get_target,$(object))) \
 	$(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_target,$(object))) \
 	$(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \
@@ -658,6 +709,8 @@ $(call gb_LinkTarget_get_target,$(1)) : OBJCOBJECTS :=
 $(call gb_LinkTarget_get_clean_target,$(1)) \
 $(call gb_LinkTarget_get_target,$(1)) : OBJCXXOBJECTS :=
 $(call gb_LinkTarget_get_clean_target,$(1)) \
+$(call gb_LinkTarget_get_target,$(1)) : CXXCLROBJECTS :=
+$(call gb_LinkTarget_get_clean_target,$(1)) \
 $(call gb_LinkTarget_get_target,$(1)) : ASMOBJECTS :=
 $(call gb_LinkTarget_get_clean_target,$(1)) \
 $(call gb_LinkTarget_get_target,$(1)) : GENCOBJECTS :=
@@ -672,6 +725,8 @@ $(call gb_LinkTarget_get_target,$(1)) : T_OBJCXXFLAGS := $$(gb_LinkTarget_OBJCXX
 $(call gb_LinkTarget_get_target,$(1)) : T_OBJCXXFLAGS_APPEND :=
 $(call gb_LinkTarget_get_target,$(1)) : T_OBJCFLAGS := $$(gb_LinkTarget_OBJCFLAGS)
 $(call gb_LinkTarget_get_target,$(1)) : T_OBJCFLAGS_APPEND :=
+$(call gb_LinkTarget_get_target,$(1)) : T_CXXCLRFLAGS := $$(gb_LinkTarget_CXXCLRFLAGS)
+$(call gb_LinkTarget_get_target,$(1)) : T_CXXCLRFLAGS_APPEND :=
 $(call gb_LinkTarget_get_target,$(1)) : DEFS := $$(gb_LinkTarget_DEFAULTDEFS) $(CPPFLAGS)
 $(call gb_LinkTarget_get_target,$(1)) : PCH_DEFS := $$(gb_LinkTarget_DEFAULTDEFS) $(CPPFLAGS)
 $(call gb_LinkTarget_get_target,$(1)) : INCLUDE := $$(gb_LinkTarget_INCLUDE)
@@ -706,6 +761,7 @@ $(call gb_LinkTarget_get_dep_target,$(1)) : COBJECTS :=
 $(call gb_LinkTarget_get_dep_target,$(1)) : CXXOBJECTS :=
 $(call gb_LinkTarget_get_dep_target,$(1)) : OBJCOBJECTS :=
 $(call gb_LinkTarget_get_dep_target,$(1)) : OBJCXXOBJECTS :=
+$(call gb_LinkTarget_get_dep_target,$(1)) : CXXCLROBJECTS :=
 $(call gb_LinkTarget_get_dep_target,$(1)) : ASMOBJECTS :=
 $(call gb_LinkTarget_get_dep_target,$(1)) : GENCOBJECTS :=
 $(call gb_LinkTarget_get_dep_target,$(1)) : GENCXXOBJECTS :=
@@ -754,6 +810,11 @@ $(call gb_LinkTarget_get_target,$(1)) : T_OBJCFLAGS_APPEND += $(2)
 
 endef
 
+# call gb_LinkTarget_add_cxxclrflags,linktarget,cxxclrflags
+define gb_LinkTarget_add_cxxclrflags
+$(call gb_LinkTarget_get_target,$(1)) : T_CXXCLRFLAGS_APPEND += $(2)
+endef
+
 # call gb_LinkTarget__add_include,linktarget,includes
 define gb_LinkTarget__add_include
 $(call gb_LinkTarget_get_target,$(1)) : INCLUDE += -I$(2)
@@ -1070,6 +1131,27 @@ endif
 
 endef
 
+# call gb_LinkTarget_add_cxxclrobject,linktarget,sourcefile,cxxclrflags,linktargetmakefilename
+define gb_LinkTarget_add_cxxclrobject
+$(if $(wildcard $(call gb_CxxClrObject_get_source,$(SRCDIR),$(2))),,$(eval $(call gb_Output_error,No such source file $(call gb_CxxClrObject_get_source,$(SRCDIR),$(2)))))
+$(call gb_LinkTarget_get_target,$(1)) : CXXCLROBJECTS += $(2)
+$(call gb_LinkTarget_get_clean_target,$(1)) : CXXCLROBJECTS += $(2)
+
+$(call gb_LinkTarget_get_target,$(1)) : $(call gb_CxxClrObject_get_target,$(2))
+$(call gb_CxxClrObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
+$(call gb_CxxClrObject_get_target,$(2)) : T_CXXCLRFLAGS += $(call gb_LinkTarget__get_cxxclrflags,$(4)) $(3)
+$(call gb_CxxClrObject_get_target,$(2)) : \
+	OBJECTOWNER := $(call gb_Object__owner,$(2),$(1))
+
+ifeq ($(gb_FULLDEPS),$(true))
+$(call gb_LinkTarget_get_dep_target,$(1)) : CXXCLROBJECTS += $(2)
+$(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_CxxClrObject_get_dep_target,$(2))
+$(call gb_CxxClrObject_get_dep_target,$(2)) :| $(dir $(call gb_CxxClrObject_get_dep_target,$(2))).dir
+$(call gb_CxxClrObject_get_target,$(2)) :| $(dir $(call gb_CxxClrObject_get_dep_target,$(2))).dir
+endif
+
+endef
+
 # call gb_LinkTarget_add_asmobject,linktarget,sourcefile
 define gb_LinkTarget_add_asmobject
 $(if $(wildcard $(call gb_AsmObject_get_source,$(SRCDIR),$(2))),,$(eval $(call gb_Output_error,No such source file $(call gb_AsmObject_get_source,$(SRCDIR),$(2)))))
@@ -1230,6 +1312,11 @@ define gb_LinkTarget_add_objcxxobjects
 $(foreach obj,$(2),$(call gb_LinkTarget_add_objcxxobject,$(1),$(obj),$(3),$(4)))
 endef
 
+# call gb_LinkTarget_add_cxxclrobjects,linktarget,sourcefiles,cxxclrflags,linktargetmakefilename
+define gb_LinkTarget_add_cxxclrobjects
+$(foreach obj,$(2),$(call gb_LinkTarget_add_cxxclrobject,$(1),$(obj),$(3),$(4)))
+endef
+
 # call gb_LinkTarget_add_asmobjects,linktarget,sourcefiles,asmflags,linktargetmakefilename
 define gb_LinkTarget_add_asmobjects
 $(foreach obj,$(2),$(call gb_LinkTarget_add_asmobject,$(1),$(obj),$(3)))
diff --git a/solenv/gbuild/StaticLibrary.mk b/solenv/gbuild/StaticLibrary.mk
index dc7778f..849c0b5 100644
--- a/solenv/gbuild/StaticLibrary.mk
+++ b/solenv/gbuild/StaticLibrary.mk
@@ -74,6 +74,8 @@ $(eval $(foreach method,\
 	add_cxxobjects \
 	add_objcxxobject \
 	add_objcxxobjects \
+	add_cxxclrobject \
+	add_cxxclrobjects \
 	add_asmobject \
 	add_asmobjects \
 	add_exception_objects \
@@ -86,6 +88,7 @@ $(eval $(foreach method,\
 	add_cxxflags \
 	add_objcflags \
 	add_objcxxflags \
+	add_cxxclrflags \
 	add_defs \
 	set_include \
 	add_ldflags \
diff --git a/solenv/gbuild/TargetLocations.mk b/solenv/gbuild/TargetLocations.mk
index 78ed59c..394b44e 100644
--- a/solenv/gbuild/TargetLocations.mk
+++ b/solenv/gbuild/TargetLocations.mk
@@ -127,6 +127,7 @@ gb_Module_get_uicheck_target = $(WORKDIR)/Module/uicheck/$(1)
 gb_Module_get_target = $(WORKDIR)/Module/$(1)
 gb_ObjCxxObject_get_target = $(WORKDIR)/ObjCxxObject/$(1).o
 gb_ObjCObject_get_target = $(WORKDIR)/ObjCObject/$(1).o
+gb_CxxClrObject_get_target = $(WORKDIR)/CxxClrObject/$(1).o
 gb_Pagein_get_target = $(WORKDIR)/Pagein/pagein-$(1)
 gb_Package_get_preparation_target = $(WORKDIR)/Package/prepared/$(1)
 gb_Package_get_target = $(WORKDIR)/Package/$(1).filelist
@@ -313,6 +314,7 @@ $(eval $(call gb_Helper_make_dep_targets,\
 	CxxObject \
 	ObjCObject \
 	ObjCxxObject \
+	CxxClrObject \
 	AsmObject \
 	GenCObject \
 	GenCxxObject \
diff --git a/solenv/gbuild/extensions/post_GbuildToJson.mk b/solenv/gbuild/extensions/post_GbuildToJson.mk
index 345b355..29bdf8d 100644
--- a/solenv/gbuild/extensions/post_GbuildToJson.mk
+++ b/solenv/gbuild/extensions/post_GbuildToJson.mk
@@ -55,6 +55,7 @@ $(call gb_Executable_get_command,gbuildtojson) \
 --yaccobjects=$(call var2file,$(shell $(gb_MKTEMP)),100,$(YACCOBJECTS)) \
 --objcobjects=$(call var2file,$(shell $(gb_MKTEMP)),100,$(OBJCOBJECTS)) \
 --objcxxobjects=$(call var2file,$(shell $(gb_MKTEMP)),100,$(OBJCXXOBJECTS)) \
+--cxxclrobjects=$(call var2file,$(shell $(gb_MKTEMP)),100,$(CXXCLROBJECTS)) \
 --asmobjects=$(call var2file,$(shell $(gb_MKTEMP)),100,$(ASMOBJECTS)) \
 --lexobjects=$(call var2file,$(shell $(gb_MKTEMP)),100,$(LEXOBJECTS)) \
 --gencobjects=$(call var2file,$(shell $(gb_MKTEMP)),100,$(GENCOBJECTS)) \
@@ -70,6 +71,8 @@ $(call gb_Executable_get_command,gbuildtojson) \
 --objcflagsappend=$(call var2file,$(shell $(gb_MKTEMP)),100,$(T_OBJCFLAGS_APPEND)) \
 --objcxxflags=$(call var2file,$(shell $(gb_MKTEMP)),100,$(T_OBJCXXFLAGS)) \
 --objcxxflagsappend=$(call var2file,$(shell $(gb_MKTEMP)),100,$(T_OBJCXXFLAGS_APPEND)) \
+--cxxclrflags=$(call var2file,$(shell $(gb_MKTEMP)),100,$(T_CXXCLRFLAGS)) \
+--cxxclrflagsappend=$(call var2file,$(shell $(gb_MKTEMP)),100,$(T_CXXCLRFLAGS_APPEND)) \
 --defs=$(call var2file,$(shell $(gb_MKTEMP)),100,$(DEFS)) \
 --include=$(call var2file,$(shell $(gb_MKTEMP)),100,$(INCLUDE)) \
 --linked_libs=$(call var2file,$(shell $(gb_MKTEMP)),100,$(LINKED_LIBS)) \
@@ -119,6 +122,10 @@ define gb_LinkTarget_add_objcxxobject
 $(call gb_LinkTarget_get_target,$(1)) : OBJCXXOBJECTS += $(2)
 
 endef
+define gb_LinkTarget_add_cxxclrobject
+$(call gb_LinkTarget_get_target,$(1)) : CXXCLROBJECTS += $(2)
+
+endef
 define gb_LinkTarget_add_scanners
 $(call gb_LinkTarget_get_target,$(1)) : LEXOBJECTS += $(2)
 
diff --git a/solenv/gbuild/platform/com_MSC_class.mk b/solenv/gbuild/platform/com_MSC_class.mk
index f55559c..1aef938 100644
--- a/solenv/gbuild/platform/com_MSC_class.mk
+++ b/solenv/gbuild/platform/com_MSC_class.mk
@@ -40,11 +40,15 @@ $(call gb_Helper_abbreviate_dirs,\
 	mkdir -p $(dir $(1)) $(dir $(4)) && \
 	unset INCLUDE && \
 	$(if $(filter YES,$(CXXOBJECT_X64)), $(CXX_X64_BINARY), \
-		$(if $(filter %.c,$(3)), $(gb_CC), $(gb_CXX))) \
+		$(if $(filter %.c,$(3)), $(gb_CC), \
+			$(if $(filter -clr,$(2)), \
+				$(MSVC_CXX) -I$(SRCDIR)/solenv/clang-cl,$(gb_CXX)))) \
 		$(DEFS) \
 		$(gb_LTOFLAGS) \
 		$(2) \
-		$(if $(EXTERNAL_CODE),$(if $(COM_IS_CLANG),-Wno-undef),$(gb_DEFS_INTERNAL)) \
+		$(if $(EXTERNAL_CODE), \
+			$(if $(filter -clr,$(2)),,$(if $(COM_IS_CLANG),-Wno-undef)), \
+			$(gb_DEFS_INTERNAL)) \
 		$(if $(WARNINGS_NOT_ERRORS),,$(gb_CFLAGS_WERROR)) \
 		-Fd$(PDBFILE) \
 		$(PCHFLAGS) \
@@ -105,6 +109,7 @@ endef
 
 gb_LinkTarget_CFLAGS := $(gb_CFLAGS)
 gb_LinkTarget_CXXFLAGS := $(gb_CXXFLAGS)
+gb_LinkTarget_CXXCLRFLAGS := $(gb_CXXCLRFLAGS)
 
 gb_LinkTarget_INCLUDE :=\
 	$(subst -I. , ,$(SOLARINC)) \
@@ -157,6 +162,7 @@ $(call gb_Helper_abbreviate_dirs,\
 		$(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \
 		$(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
 		$(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_target,$(object))) \
+		$(foreach object,$(CXXCLROBJECTS),$(call gb_CxxClrObject_get_target,$(object))) \
 		$(foreach object,$(ASMOBJECTS),$(call gb_AsmObject_get_target,$(object))) \
 		$(foreach extraobjectlist,$(EXTRAOBJECTLISTS),$(shell cat $(extraobjectlist))) \
 		$(PCHOBJS) $(NATIVERES)) && \
diff --git a/solenv/gbuild/platform/com_MSC_defs.mk b/solenv/gbuild/platform/com_MSC_defs.mk
old mode 100644
new mode 100755
index 5e7c2e6..a6b1b32
--- a/solenv/gbuild/platform/com_MSC_defs.mk
+++ b/solenv/gbuild/platform/com_MSC_defs.mk
@@ -152,16 +152,7 @@ gb_CFLAGS := \
 	-wd4706 \
 	-wd4800 \
 
-ifeq ($(COM_IS_CLANG),TRUE)
-gb_CFLAGS += \
-	-Wdeclaration-after-statement \
-	-Wendif-labels \
-	-Wshadow \
-	-Wstrict-prototypes \
-	-Wundef \
-	-Wunused-macros \
-
-else
+ifneq ($(COM_IS_CLANG),TRUE)
 
 gb_CFLAGS += \
 	$(if $(filter-out 120,$(VCVER)), -Wv:18 -wd4267) \
@@ -212,19 +203,7 @@ gb_CFLAGS += \
 
 endif
 
-ifeq ($(COM_IS_CLANG),TRUE)
-gb_CXXFLAGS += \
-	-Wendif-labels \
-	-Wimplicit-fallthrough \
-	-Wno-missing-braces \
-	-Wno-missing-braces \
-	-Wnon-virtual-dtor \
-	-Woverloaded-virtual \
-	-Wshadow \
-	-Wundef \
-	-Wunused-macros \
-
-else
+ifneq ($(COM_IS_CLANG),TRUE)
 
 gb_CXXFLAGS += \
 	$(if $(filter-out 120,$(VCVER)), -Wv:18 -wd4267) \
@@ -290,6 +269,38 @@ endif
 
 gb_LTOFLAGS := $(if $(filter TRUE,$(ENABLE_LTO)),-GL)
 
+# When compiling for CLR, disable "warning C4339: use of undefined type detected
+# in CLR meta-data - use of this type may lead to a runtime exception":
+gb_CXXCLRFLAGS := $(gb_CXXFLAGS) $(gb_LinkTarget_EXCEPTIONFLAGS) \
+	-AI $(INSTDIR)/$(LIBO_URE_LIB_FOLDER) \
+	-EHa \
+	-clr \
+	-wd4339 \
+	$(if $(filter-out 120,$(VCVER)), -Wv:18 -wd4267) \
+
+ifeq ($(COM_IS_CLANG),TRUE)
+
+gb_CFLAGS += \
+	-Wdeclaration-after-statement \
+	-Wendif-labels \
+	-Wshadow \
+	-Wstrict-prototypes \
+	-Wundef \
+	-Wunused-macros \
+
+gb_CXXFLAGS += \
+	-Wendif-labels \
+	-Wimplicit-fallthrough \
+	-Wno-missing-braces \
+	-Wno-missing-braces \
+	-Wnon-virtual-dtor \
+	-Woverloaded-virtual \
+	-Wshadow \
+	-Wundef \
+	-Wunused-macros \
+
+endif
+
 # Helper class
 
 ifeq ($(GNUMAKE_WIN_NATIVE),TRUE)
diff --git a/solenv/qa/python/gbuildtojson.py b/solenv/qa/python/gbuildtojson.py
index 4792998..ab27497 100644
--- a/solenv/qa/python/gbuildtojson.py
+++ b/solenv/qa/python/gbuildtojson.py
@@ -62,7 +62,7 @@ class CheckGbuildToJson(unittest.TestCase):
                 gbuildlibs.append(json.load(f))
         foundlibs = set()
         for lib in gbuildlibs:
-            self.assertEqual(set(lib.keys()), set(['MAKEFILE', 'ASMOBJECTS', 'CFLAGS', 'CFLAGSAPPEND', 'COBJECTS', 'CXXFLAGS', 'CXXFLAGSAPPEND', 'CXXOBJECTS', 'DEFS', 'LEXOBJECTS', 'GENCOBJECTS', 'GENCXXOBJECTS', 'ILIBTARGET', 'INCLUDE', 'JAVAOBJECTS', 'LINKED_LIBS', 'LINKED_STATIC_LIBS', 'LINKTARGET', 'OBJCFLAGS', 'OBJCFLAGSAPPEND', 'OBJCOBJECTS', 'OBJCXXFLAGS', 'OBJCXXFLAGSAPPEND', 'OBJCXXOBJECTS', 'PYTHONOBJECTS', 'YACCOBJECTS']))
+            self.assertEqual(set(lib.keys()), set(['MAKEFILE', 'ASMOBJECTS', 'CFLAGS', 'CFLAGSAPPEND', 'COBJECTS', 'CXXCLRFLAGS', 'CXXCLRFLAGSAPPEND', 'CXXCLROBJECTS', 'CXXFLAGS', 'CXXFLAGSAPPEND', 'CXXOBJECTS', 'DEFS', 'LEXOBJECTS', 'GENCOBJECTS', 'GENCXXOBJECTS', 'ILIBTARGET', 'INCLUDE', 'JAVAOBJECTS', 'LINKED_LIBS', 'LINKED_STATIC_LIBS', 'LINKTARGET', 'OBJCFLAGS', 'OBJCFLAGSAPPEND', 'OBJCOBJECTS', 'OBJCXXFLAGS', 'OBJCXXFLAGSAPPEND', 'OBJCXXOBJECTS', 'PYTHONOBJECTS', 'YACCOBJECTS']))
             if lib['LINKTARGET'].find('gbuildselftestdep') != -1:
                 foundlibs.add('gbuildselftestdep')
             elif lib['LINKTARGET'].find('gbuildselftest') != -1:


More information about the Libreoffice-commits mailing list