From 36f76223193fb96df7b8cbc1a1ff30f739857189 Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Mon, 20 Sep 2021 00:53:33 +0000 Subject: use clang-cl's -Zc:dllexportInlines- for Skia (tdf#144598) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- external/skia/Library_skia.mk | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'external') diff --git a/external/skia/Library_skia.mk b/external/skia/Library_skia.mk index 60b8a3caccb1..b1b4f874f44a 100644 --- a/external/skia/Library_skia.mk +++ b/external/skia/Library_skia.mk @@ -59,6 +59,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 ifeq ($(OS),MACOSX) $(eval $(call gb_Library_use_system_darwin_frameworks,skia,\ @@ -830,20 +841,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 \ @@ -851,6 +867,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,\ -- cgit