use clang-cl's -Zc:dllexportInlines- for clang-cl builds

This is clang-cl's equivalent of -fvisibility-inlines-hidden,
and it seems to be also sort of the equivalent of MSVC's
-Zc:inline. So it saves build time and disk space.

Clang docs say that this is binary compatible in only one
direction, so our public C++ code shouldn't be using this,
as external C++ code could try to use exported inlines
that are no longer there.

Change-Id: Ie6217808f8ee4a15344183abfc65038e1558d1b0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122352
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
This commit is contained in:
Luboš Luňák 2021-09-20 10:31:40 +00:00 committed by Luboš Luňák
parent 36f7622319
commit c7c9f3f57a
11 changed files with 45 additions and 2 deletions

View file

@ -266,6 +266,7 @@ export HAMCREST_JAR=@HAMCREST_JAR@
export HAVE_BROKEN_GCC_WMAYBE_UNINITIALIZED=@HAVE_BROKEN_GCC_WMAYBE_UNINITIALIZED@
export HAVE_BROKEN_GCC_WSTRINGOP_OVERFLOW=@HAVE_BROKEN_GCC_WSTRINGOP_OVERFLOW@
export HAVE_CLANG_DEBUG_INFO_KIND_CONSTRUCTOR=@HAVE_CLANG_DEBUG_INFO_KIND_CONSTRUCTOR@
export HAVE_DLLEXPORTINLINES=@HAVE_DLLEXPORTINLINES@
export HAVE_LO_CLANG_DLLEXPORTINLINES=@HAVE_LO_CLANG_DLLEXPORTINLINES@
export HAVE_GCC_AVX=@HAVE_GCC_AVX@
export HAVE_GCC_BUILTIN_ATOMIC=@HAVE_GCC_BUILTIN_ATOMIC@

View file

@ -7599,6 +7599,21 @@ if test "$GCC" = yes && test "$COM_IS_CLANG" != TRUE; then
fi
AC_SUBST([HAVE_BROKEN_GCC_WSTRINGOP_OVERFLOW])
HAVE_DLLEXPORTINLINES=
if test "$_os" = "WINNT"; then
AC_MSG_CHECKING([whether $CXX_BASE supports -Zc:dllexportInlines-])
AC_LANG_PUSH([C++])
save_CXXFLAGS=$CXXFLAGS
CXXFLAGS="$CXXFLAGS -Werror -Zc:dllexportInlines-"
AC_COMPILE_IFELSE([AC_LANG_SOURCE()], [
HAVE_DLLEXPORTINLINES=TRUE
AC_MSG_RESULT([yes])
], [AC_MSG_RESULT([no])])
CXXFLAGS=$save_CXXFLAGS
AC_LANG_POP([C++])
fi
AC_SUBST([HAVE_DLLEXPORTINLINES])
dnl ===================================================================
dnl CPU Intrinsics support - SSE, AVX
dnl ===================================================================

View file

@ -14,6 +14,8 @@ $(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_add_defs,cppu,\
-DCPPU_DLLIMPLEMENTATION \
))

View file

@ -16,6 +16,8 @@ $(eval $(call gb_Library_add_defs,purpenvhelper,\
-DPURPENV_DLLIMPLEMENTATION \
))
$(eval $(call gb_Library_set_is_ure_library,purpenvhelper))
$(eval $(call gb_Library_use_udk_api,purpenvhelper))
$(eval $(call gb_Library_use_libraries,purpenvhelper,\

View file

@ -18,6 +18,8 @@ $(eval $(call gb_Library_use_internal_comprehensive_api,cppuhelper,\
offapi \
))
$(eval $(call gb_Library_set_is_ure_library,cppuhelper))
$(eval $(call gb_Library_add_defs,cppuhelper,\
-DCPPUHELPER_DLLIMPLEMENTATION \
))

View file

@ -14,6 +14,8 @@ $(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_include,sal,\
$$(INCLUDE) \
-I$(SRCDIR)/sal/inc \

View file

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

View file

@ -252,5 +252,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))
# vim: set noet sw=4:

View file

@ -2010,4 +2010,15 @@ $(call gb_LinkTarget_use_static_libraries,$(1),vclmain)
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
ifeq ($(HAVE_DLLEXPORTINLINES),TRUE)
$(call gb_LinkTarget_add_cxxflags,$(1),-Zc:dllexportInlines)
endif
endef
# vim: set noet sw=4:

View file

@ -48,9 +48,10 @@ endef
# Avoid annoying warning D9025 about overriding command-line arguments.
gb_Helper_remove_overridden_flags = \
$(lastword $(filter -W4 -w,$(1))) \
$(filter-out -W4 -w -arch:SSE -arch:SSE2 -arch:AVX -arch:AVX2 -Od -O2,$(1)) \
$(filter-out -W4 -w -arch:SSE -arch:SSE2 -arch:AVX -arch:AVX2 -Od -O2 -Zc:dllexportInlines -Zc:dllexportInlines-,$(1)) \
$(lastword $(filter -Od -O2,$(1))) \
$(lastword $(filter -arch:SSE -arch:SSE2 -arch:AVX -arch:AVX2,$(1)))
$(lastword $(filter -arch:SSE -arch:SSE2 -arch:AVX -arch:AVX2,$(1))) \
$(lastword $(filter -Zc:dllexportInlines -Zc:dllexportInlines-,$(1)))
# $(call gb_CObject__command_pattern,object,flags,source,dep-file,compiler-plugins,symbols,compiler)
define gb_CObject__command_pattern

View file

@ -158,6 +158,10 @@ gb_CFLAGS += \
endif
ifeq ($(HAVE_DLLEXPORTINLINES),TRUE)
gb_CXXFLAGS += -Zc:dllexportInlines-
endif
ifneq ($(COM_IS_CLANG),TRUE)
# clang-cl doesn't support -Wv:18 for now