summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@centrum.cz>2021-09-20 00:53:33 +0000
committerMichael Stahl <michael.stahl@allotropia.de>2021-09-21 10:24:57 +0200
commit11f3ed0ca9f87da6ef5b24f6cb4f58335b78ff7d (patch)
tree62c046f26f4e9a597156252b95f99c8c529ffc73
parent754a28a5a0e4cb3eb7ab98dd9d45c992caa0a51f (diff)
use clang-cl's -Zc:dllexportInlines- for Skia (tdf#144598)
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. As an additional effect, this disables emitting copies of inlines functions in every .o file where the function is called (even if inlined), which means that it hopefully avoids the problem of SkOpts_avx.cpp generating a copy of SkRect::round() which would include AVX code, and the linker might select this as the instance of SkRect::round() to keep, thus making SSE2 code call AVX code without checking for AVX availability first. Change-Id: I97541ae11d05f489894bc9233271eb21fd520f43 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122335 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com> (cherry picked from commit 36f76223193fb96df7b8cbc1a1ff30f739857189) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122285 Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
-rw-r--r--config_host.mk.in1
-rw-r--r--configure.ac20
-rw-r--r--external/skia/Library_skia.mk17
-rw-r--r--solenv/gbuild/LinkTarget.mk2
4 files changed, 38 insertions, 2 deletions
diff --git a/config_host.mk.in b/config_host.mk.in
index 29626ec9fc42..d6edba704b21 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -262,6 +262,7 @@ export USING_X11=@USING_X11@
export HAMCREST_JAR=@HAMCREST_JAR@
export HAVE_BROKEN_GCC_WMAYBE_UNINITIALIZED=@HAVE_BROKEN_GCC_WMAYBE_UNINITIALIZED@
export HAVE_CLANG_DEBUG_INFO_KIND_CONSTRUCTOR=@HAVE_CLANG_DEBUG_INFO_KIND_CONSTRUCTOR@
+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@
export HAVE_GCC_FNO_ENFORCE_EH_SPECS=@HAVE_GCC_FNO_ENFORCE_EH_SPECS@
diff --git a/configure.ac b/configure.ac
index a9241848fdd0..83b67fd34d50 100644
--- a/configure.ac
+++ b/configure.ac
@@ -11731,6 +11731,7 @@ LO_CLANG_CXXFLAGS_INTRINSICS_AVX2=
LO_CLANG_CXXFLAGS_INTRINSICS_AVX512=
LO_CLANG_CXXFLAGS_INTRINSICS_F16C=
LO_CLANG_CXXFLAGS_INTRINSICS_FMA=
+HAVE_LO_CLANG_DLLEXPORTINLINES=
if test "$ENABLE_SKIA" = TRUE -a "$COM_IS_CLANG" != TRUE -a ! \( "$_os" = "WINNT" -a "$CPUNAME" = "ARM64" \); then
if test -n "$LO_CLANG_CC" -a -n "$LO_CLANG_CXX"; then
@@ -11762,6 +11763,24 @@ if test "$ENABLE_SKIA" = TRUE -a "$COM_IS_CLANG" != TRUE -a ! \( "$_os" = "WINNT
LO_CLANG_CXX=
fi
fi
+ if test -n "$LO_CLANG_CC" -a -n "$LO_CLANG_CXX" -a "$_os" = "WINNT"; then
+ save_CXX="$CXX"
+ CXX="$LO_CLANG_CXX"
+ AC_MSG_CHECKING([whether $CXX supports -Zc:dllexportInlines-])
+ AC_LANG_PUSH([C++])
+ save_CXXFLAGS=$CXXFLAGS
+ CXXFLAGS="$CXXFLAGS -Werror -Zc:dllexportInlines-"
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE()], [
+ HAVE_LO_CLANG_DLLEXPORTINLINES=TRUE
+ AC_MSG_RESULT([yes])
+ ], [AC_MSG_RESULT([no])])
+ CXXFLAGS=$save_CXXFLAGS
+ AC_LANG_POP([C++])
+ CXX="$save_CXX"
+ if test -z "$HAVE_LO_CLANG_DLLEXPORTINLINES"; then
+ AC_MSG_ERROR([Clang compiler does not support -Zc:dllexportInlines-. The Skia library needs to be built using a newer Clang version, or use --disable-skia.])
+ fi
+ fi
if test -z "$LO_CLANG_CC" -o -z "$LO_CLANG_CXX"; then
# Skia is the default on Windows, so hard-require Clang.
# Elsewhere it's used just by the 'gen' VCL backend which is rarely used.
@@ -12032,6 +12051,7 @@ AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_AVX512)
AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_F16C)
AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_FMA)
AC_SUBST(CLANG_USE_LD)
+AC_SUBST([HAVE_LO_CLANG_DLLEXPORTINLINES])
SYSTEM_GPGMEPP=
diff --git a/external/skia/Library_skia.mk b/external/skia/Library_skia.mk
index 87ae0c64552f..fc59c3ebfe1e 100644
--- a/external/skia/Library_skia.mk
+++ b/external/skia/Library_skia.mk
@@ -57,6 +57,17 @@ $(eval $(call gb_Library_use_system_win32_libs,skia,\
usp10 \
gdi32 \
))
+
+# cl.exe (and thus clang-cl) likes to emit copies of inline functions even when not needed,
+# which means that for e.g. AVX-compiled sources the .o may contain a copy of an inline
+# function built using AVX, and the linker may select that copy as the one to keep, thus
+# introducing AVX code into generic code. Avoid generating such inlines. The flag currently
+# cannot be used for the whole Skia, because code built without the flag cannot use
+# libraries built with the flag, so cl.exe-built VCL would have undefined references.
+ifeq ($(HAVE_LO_CLANG_DLLEXPORTINLINES),TRUE)
+LO_SKIA_AVOID_INLINE_COPIES := -Zc:dllexportInlines-
+endif
+
else
$(eval $(call gb_Library_use_externals,skia,\
freetype \
@@ -802,20 +813,25 @@ $(eval $(call gb_Library_add_generated_exception_objects,skia,\
$(eval $(call gb_Library_add_generated_exception_objects,skia,\
UnpackedTarball/skia/src/opts/SkOpts_avx, $(CXXFLAGS_INTRINSICS_AVX) $(LO_CLANG_CXXFLAGS_INTRINSICS_AVX) \
+ $(LO_SKIA_AVOID_INLINE_COPIES) \
))
$(eval $(call gb_Library_add_generated_exception_objects,skia,\
UnpackedTarball/skia/src/opts/SkOpts_hsw, \
$(CXXFLAGS_INTRINSICS_AVX2) $(CXXFLAGS_INTRINSICS_F16C) $(CXXFLAGS_INTRINSICS_FMA) \
$(LO_CLANG_CXXFLAGS_INTRINSICS_AVX2) $(LO_CLANG_CXXFLAGS_INTRINSICS_F16C) $(LO_CLANG_CXXFLAGS_INTRINSICS_FMA) \
+ $(LO_SKIA_AVOID_INLINE_COPIES) \
))
$(eval $(call gb_Library_add_generated_exception_objects,skia,\
UnpackedTarball/skia/src/opts/SkOpts_sse41, $(CXXFLAGS_INTRINSICS_SSE41) $(LO_CLANG_CXXFLAGS_INTRINSICS_SSE41) \
+ $(LO_SKIA_AVOID_INLINE_COPIES) \
))
$(eval $(call gb_Library_add_generated_exception_objects,skia,\
UnpackedTarball/skia/src/opts/SkOpts_sse42, $(CXXFLAGS_INTRINSICS_SSE42) $(LO_CLANG_CXXFLAGS_INTRINSICS_SSE42) \
+ $(LO_SKIA_AVOID_INLINE_COPIES) \
))
$(eval $(call gb_Library_add_generated_exception_objects,skia,\
UnpackedTarball/skia/src/opts/SkOpts_ssse3, $(CXXFLAGS_INTRINSICS_SSSE3) $(LO_CLANG_CXXFLAGS_INTRINSICS_SSSE3) \
+ $(LO_SKIA_AVOID_INLINE_COPIES) \
))
$(eval $(call gb_Library_add_generated_exception_objects,skia,\
UnpackedTarball/skia/src/opts/SkOpts_crc32 \
@@ -823,6 +839,7 @@ $(eval $(call gb_Library_add_generated_exception_objects,skia,\
$(eval $(call gb_Library_add_generated_exception_objects,skia,\
UnpackedTarball/skia/src/opts/SkOpts_skx, $(CXXFLAGS_INTRINSICS_AVX512) $(LO_CLANG_CXXFLAGS_INTRINSICS_AVX512)\
+ $(LO_SKIA_AVOID_INLINE_COPIES) \
))
$(eval $(call gb_Library_add_generated_exception_objects,skia,\
diff --git a/solenv/gbuild/LinkTarget.mk b/solenv/gbuild/LinkTarget.mk
index 6cd8719f91b7..90c7a12baffb 100644
--- a/solenv/gbuild/LinkTarget.mk
+++ b/solenv/gbuild/LinkTarget.mk
@@ -1625,7 +1625,6 @@ endef
# call gb_LinkTarget_set_clang_precompiled_header,linktarget,pchcxxfile,,linktargetmakefilename
define gb_LinkTarget_set_clang_precompiled_header
$(call gb_LinkTarget_set_precompiled_header,$(1),$(2),$(3),$(4),$(LO_CLANG_CXX))
-
endef
# call gb_LinkTarget__reuse_precompiled_header_impl,linktarget,pchcxxfile,pchtarget,linktargetmakefilename
@@ -1786,7 +1785,6 @@ define gb_LinkTarget_use_clang
$(call gb_LinkTarget_get_target,$(1)) : T_CC := $(LO_CLANG_CC)
$(call gb_LinkTarget_get_target,$(1)) : T_CXX := $(LO_CLANG_CXX)
$(call gb_LinkTarget_get_target,$(1)) : T_USE_LD := $(or $(CLANG_USE_LD),$(USE_LD))
-
endef