summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2017-02-20 16:28:06 +0100
committerStephan Bergmann <sbergman@redhat.com>2017-02-21 10:18:58 +0000
commit0a99b5a1b7325454fe3d1174d44354888aa22012 (patch)
tree9edc1d3cca42c07ae4767ad7ca3b150895ac5295
parent0649622956431e0a1955cb80d1175025401ab5e5 (diff)
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@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
-rw-r--r--cli_ure/Executable_climaker.mk7
-rw-r--r--cli_ure/Library_cli_cppuhelper_native.mk13
-rw-r--r--cli_ure/Library_cli_uno.mk9
-rw-r--r--config_host.mk.in1
-rw-r--r--configure.ac21
-rwxr-xr-xsolenv/clang-cl/config_global.h21
-rw-r--r--solenv/gbuild/CompilerTest.mk2
-rw-r--r--solenv/gbuild/CppunitTest.mk3
-rw-r--r--solenv/gbuild/Executable.mk3
-rw-r--r--solenv/gbuild/Library.mk3
-rw-r--r--solenv/gbuild/LinkTarget.mk91
-rw-r--r--solenv/gbuild/StaticLibrary.mk3
-rw-r--r--solenv/gbuild/TargetLocations.mk2
-rw-r--r--solenv/gbuild/extensions/post_GbuildToJson.mk7
-rw-r--r--solenv/gbuild/platform/com_MSC_class.mk10
-rwxr-xr-x[-rw-r--r--]solenv/gbuild/platform/com_MSC_defs.mk57
-rw-r--r--solenv/qa/python/gbuildtojson.py2
17 files changed, 198 insertions, 57 deletions
diff --git a/cli_ure/Executable_climaker.mk b/cli_ure/Executable_climaker.mk
index 298f01ebf45f..6f1a37b8ce10 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 52314a3baeaa..bb230fb0108d 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 0629a171ec6c..75eadae723d6 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 f07cc04cee4a..71362a4838b9 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 9259c4dec3a7..42bab2e99e76 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 000000000000..80120f1d2a08
--- /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 4178b51a59d2..a495cf368dda 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 a916e49ca76a..23ea06ad5f85 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 cef95d554205..afe4ddf51c47 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 8042f3357010..18640d6437d4 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 ca1f5ad7c42a..5d192df299cb 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 dc7778f2dd11..849c0b51a5ad 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 78ed59c07835..394b44eae7d4 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 345b3556cba0..29bdf8d78f8c 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 f55559c71e66..1aef9384d8fc 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
index 5e7c2e689438..a6b1b32d8c3d 100644..100755
--- 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 479299844a39..ab27497ca3ed 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: