diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2017-02-20 16:28:06 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2017-02-21 10:18:58 +0000 |
commit | 0a99b5a1b7325454fe3d1174d44354888aa22012 (patch) | |
tree | 9edc1d3cca42c07ae4767ad7ca3b150895ac5295 /solenv/gbuild/LinkTarget.mk | |
parent | 0649622956431e0a1955cb80d1175025401ab5e5 (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>
Diffstat (limited to 'solenv/gbuild/LinkTarget.mk')
-rw-r--r-- | solenv/gbuild/LinkTarget.mk | 91 |
1 files changed, 89 insertions, 2 deletions
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))) |