Fix clang-cl -Zc:dllexportInlines- build

That flag is only supported by clang-cl, not by MSVC, and
c7c9f3f57a "use clang-cl's -Zc:dllexportInlines-
for clang-cl builds" apparently naively assumed that it would work to build LO
with clang-cl and that flag without actually trying it out, and
1040228c35 "My clang-cl build does not work with
-Zc:dllexportInlines-" effectively disabled it completely.

The way to avoid unresolved external symbols during linking of URE libraries
(see the 1040228c35 commit message) is apparently
to also build libraries that the URE libraries depend on with the flag, hence
the change from gb_Library_set_is_ure_library to
gb_Library_set_is_ure_library_or_dependency.  For now, I only marked those
additional libraries (unoil and xmlreader) that actually caused issues when
linking the URE libraries.

Change-Id: I3a85c73246250981cd86b7ee41f87b41f393a4b1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126012
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Tested-by: Jenkins
This commit is contained in:
Stephan Bergmann 2021-11-29 08:32:42 +01:00
parent 6052d7b6e4
commit 45d93ea927
10 changed files with 17 additions and 11 deletions

View file

@ -7652,9 +7652,7 @@ fi
AC_SUBST([HAVE_BROKEN_GCC_WSTRINGOP_OVERFLOW])
HAVE_DLLEXPORTINLINES=
dnl At least for Clang 14 trunk, -Zc:dllexportInlines- would cause lots of unresolved symbols when
dnl linking e.g. Library_cppuhelper, for whatever reason:
if test "$_os" = "WINNT" && test "$COM_IS_CLANG" != TRUE; then
if test "$_os" = "WINNT"; then
AC_MSG_CHECKING([whether $CXX_BASE supports -Zc:dllexportInlines-])
AC_LANG_PUSH([C++])
save_CXXFLAGS=$CXXFLAGS

View file

@ -14,7 +14,7 @@ $(eval $(call gb_Library_set_soversion_script,cppu,$(SRCDIR)/cppu/util/cppu.map)
$(eval $(call gb_Library_use_udk_api,cppu))
$(eval $(call gb_Library_set_is_ure_library,cppu))
$(eval $(call gb_Library_set_is_ure_library_or_dependency,cppu))
$(eval $(call gb_Library_add_defs,cppu,\
-DCPPU_DLLIMPLEMENTATION \

View file

@ -16,7 +16,7 @@ $(eval $(call gb_Library_add_defs,purpenvhelper,\
-DPURPENV_DLLIMPLEMENTATION \
))
$(eval $(call gb_Library_set_is_ure_library,purpenvhelper))
$(eval $(call gb_Library_set_is_ure_library_or_dependency,purpenvhelper))
$(eval $(call gb_Library_use_udk_api,purpenvhelper))

View file

@ -20,7 +20,7 @@ $(eval $(call gb_Library_use_internal_comprehensive_api,cppuhelper,\
offapi \
))
$(eval $(call gb_Library_set_is_ure_library,cppuhelper))
$(eval $(call gb_Library_set_is_ure_library_or_dependency,cppuhelper))
$(eval $(call gb_Library_add_defs,cppuhelper,\
-DCPPUHELPER_DLLIMPLEMENTATION \

View file

@ -14,7 +14,7 @@ $(eval $(call gb_Library_set_soversion_script,sal,$(SRCDIR)/sal/util/sal.map))
$(eval $(call gb_Library_set_precompiled_header,sal,sal/inc/pch/precompiled_sal))
$(eval $(call gb_Library_set_is_ure_library,sal))
$(eval $(call gb_Library_set_is_ure_library_or_dependency,sal))
$(eval $(call gb_Library_set_include,sal,\
$$(INCLUDE) \

View file

@ -14,7 +14,7 @@ $(eval $(call gb_Library_add_defs,salhelper,\
-DSALHELPER_DLLIMPLEMENTATION \
))
$(eval $(call gb_Library_set_is_ure_library,salhelper))
$(eval $(call gb_Library_set_is_ure_library_or_dependency,salhelper))
$(eval $(call gb_Library_use_libraries,salhelper,\
sal \

View file

@ -268,6 +268,6 @@ gb_Library_use_clang = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$
gb_Library_set_clang_precompiled_header = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
gb_Library_use_glxtest = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
gb_Library_use_vclmain = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
gb_Library_set_is_ure_library = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
gb_Library_set_is_ure_library_or_dependency = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
# vim: set noet sw=4:

View file

@ -2099,8 +2099,12 @@ endef # gb_LinkTarget_use_vclmain
# Used by URE libraries that need to keep binary compatibility.
# Reset some flags that make sense for our internal libraries but might
# break public ABI.
# call gb_LinkTarget_set_is_ure_library,linktarget,,linktargetmakefilename
define gb_LinkTarget_set_is_ure_library
# (clang-cl's -Zc:dllexportInlines- would not only be a problem for the URE libraries themselves but
# also for any libraries they depend on. While that does not appear to be a problem for -Zc:inline
# for neither MSVC nor clang-cl, it should not really hurt to also switch that off not only for the
# URE libraries themselves but also for their dependencies.)
# call gb_LinkTarget_set_is_ure_library_or_dependency,linktarget,,linktargetmakefilename
define gb_LinkTarget_set_is_ure_library_or_dependency
$(call gb_LinkTarget_add_cxxflags,$(1),$(gb_CXXFLAGS_ZCINLINE_OFF))
ifeq ($(HAVE_DLLEXPORTINLINES),TRUE)
$(call gb_LinkTarget_add_cxxflags,$(1),-Zc:dllexportInlines)

View file

@ -32,6 +32,8 @@ $(eval $(call gb_Library_set_include,unoidl, \
-I$(SRCDIR)/unoidl/source \
))
$(eval $(call gb_Library_set_is_ure_library_or_dependency,unoidl))
$(eval $(call gb_Library_use_libraries,unoidl, \
reg \
sal \

View file

@ -23,6 +23,8 @@ $(eval $(call gb_Library_add_defs,xmlreader,\
-DOOO_DLLIMPLEMENTATION_XMLREADER \
))
$(eval $(call gb_Library_set_is_ure_library_or_dependency,xmlreader))
$(eval $(call gb_Library_use_external,xmlreader,boost_headers))
$(eval $(call gb_Library_use_libraries,xmlreader,\