config_host.mk.in                       |    1 +
 configure.ac                            |   15 +++++++++++++++
 cppu/Library_cppu.mk                    |    2 ++
 cppu/Library_purpenvhelper.mk           |    2 ++
 cppuhelper/Library_cppuhelper.mk        |    6 ++++--
 sal/Library_sal.mk                      |    2 ++
 salhelper/Library_salhelper.mk          |    2 ++
 solenv/gbuild/Library.mk                |    1 +
 solenv/gbuild/LinkTarget.mk             |   12 ++++++++++++
 solenv/gbuild/platform/com_MSC_class.mk |    6 ++++--
 solenv/gbuild/platform/com_MSC_defs.mk  |    7 +++++++
 11 files changed, 52 insertions(+), 4 deletions(-)

New commits:
commit 47a8a65022e3fd7624c95d0341b4809aad11fddb
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Mon Sep 20 01:44:17 2021 +0200
Commit:     Luboš Luňák <l.lu...@collabora.com>
CommitDate: Mon Sep 20 22:51:12 2021 +0200

    use MSVC's /Zc:inline option to reduce binary size
    
    If I'm getting it right, MSVC has a non-conforming feature
    that allows to declare a function as inline without defining its
    body in the header, and it'll work if the function is actually
    emitted elsewhere, and the linker will sort it out. This seems
    to be implemented by forcing emitting of out-of-line copies
    of all inline functions, which is wasteful. /Zc:inline disables
    this useless feature, which seems to save quite some space
    (optimized build, starmath's .o files 350k->220k, smlo.dll
    2.5M->2.2M).
    
    The docs don't say anything about binary compatibility,
    but treat it the same way as -Zc:dllexportInlines, just in case.
    
    This change also may help avoid the tdf#144598 problem for our
    AVX/etc. code, such as in Calc.
    
    Change-Id: I73cc5d46ba1e4245e8d3b6688804c2b9684d2f9a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122334
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>

diff --git a/cppuhelper/Library_cppuhelper.mk b/cppuhelper/Library_cppuhelper.mk
index 3c87054b45ab..5e131cb6c43e 100644
--- a/cppuhelper/Library_cppuhelper.mk
+++ b/cppuhelper/Library_cppuhelper.mk
@@ -12,6 +12,8 @@ $(eval $(call gb_Library_Library,cppuhelper))
 
 $(eval $(call 
gb_Library_set_soversion_script,cppuhelper,$(SRCDIR)/cppuhelper/source/gcc3.map))
 
+$(eval $(call 
gb_Library_set_precompiled_header,cppuhelper,cppuhelper/inc/pch/precompiled_cppuhelper))
+
 $(eval $(call gb_Library_use_internal_comprehensive_api,cppuhelper,\
        cppuhelper \
        udkapi \
@@ -24,8 +26,6 @@ $(eval $(call gb_Library_add_defs,cppuhelper,\
        -DCPPUHELPER_DLLIMPLEMENTATION \
 ))
 
-$(eval $(call 
gb_Library_set_precompiled_header,cppuhelper,cppuhelper/inc/pch/precompiled_cppuhelper))
-
 $(eval $(call gb_Library_use_libraries,cppuhelper,\
        cppu \
        reg \
diff --git a/solenv/gbuild/LinkTarget.mk b/solenv/gbuild/LinkTarget.mk
index 29924c9897e0..91dc20adc72f 100644
--- a/solenv/gbuild/LinkTarget.mk
+++ b/solenv/gbuild/LinkTarget.mk
@@ -2015,6 +2015,7 @@ endef # gb_LinkTarget_use_vclmain
 # break public ABI.
 # call gb_LinkTarget_set_is_ure_library,linktarget,,linktargetmakefilename
 define gb_LinkTarget_set_is_ure_library
+$(call gb_LinkTarget_add_cxxflags,$(1),$(gb_CXXFLAGS_ZCINLINE_OFF))
 ifeq ($(HAVE_DLLEXPORTINLINES),TRUE)
 $(call gb_LinkTarget_add_cxxflags,$(1),-Zc:dllexportInlines)
 endif
diff --git a/solenv/gbuild/platform/com_MSC_class.mk 
b/solenv/gbuild/platform/com_MSC_class.mk
index 80944fe70ba4..3ea82e6c4936 100644
--- a/solenv/gbuild/platform/com_MSC_class.mk
+++ b/solenv/gbuild/platform/com_MSC_class.mk
@@ -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 
-Zc:dllexportInlines -Zc:dllexportInlines-,$(1)) \
+    $(filter-out -W4 -w -arch:SSE -arch:SSE2 -arch:AVX -arch:AVX2 -Od -O2 
-Zc:inline -Zc:inline- -Zc:dllexportInlines -Zc:dllexportInlines-,$(1)) \
     $(lastword $(filter -Od -O2,$(1))) \
     $(lastword $(filter -arch:SSE -arch:SSE2 -arch:AVX -arch:AVX2,$(1))) \
+    $(lastword $(filter -Zc:inline -Zc:inline-,$(1))) \
     $(lastword $(filter -Zc:dllexportInlines -Zc:dllexportInlines-,$(1)))
 
 # $(call 
gb_CObject__command_pattern,object,flags,source,dep-file,compiler-plugins,symbols,compiler)
diff --git a/solenv/gbuild/platform/com_MSC_defs.mk 
b/solenv/gbuild/platform/com_MSC_defs.mk
index 273e17ea71f0..8dccadd1f743 100644
--- a/solenv/gbuild/platform/com_MSC_defs.mk
+++ b/solenv/gbuild/platform/com_MSC_defs.mk
@@ -133,6 +133,7 @@ gb_CXXFLAGS := \
        -Gs \
        -GS \
        -Gy \
+       -Zc:inline \
        $(if $(MSVC_USE_DEBUG_RUNTIME),-MDd,-MD) \
        -nologo \
        -W4 \
@@ -148,6 +149,8 @@ gb_CXXFLAGS := \
        -wd4706 \
        -bigobj \
 
+gb_CXXFLAGS_ZCINLINE_OFF := -Zc:inline-
+
 ifeq ($(CPUNAME),INTEL)
 
 gb_CXXFLAGS += \
commit c7c9f3f57a2feae5d3bc3c47104786883ed09e44
Author:     Luboš Luňák <l.lu...@centrum.cz>
AuthorDate: Mon Sep 20 10:31:40 2021 +0000
Commit:     Luboš Luňák <l.lu...@collabora.com>
CommitDate: Mon Sep 20 22:50:59 2021 +0200

    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.lu...@collabora.com>

diff --git a/config_host.mk.in b/config_host.mk.in
index 3aa51a3d638f..6ee6ad45f00f 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -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@
diff --git a/configure.ac b/configure.ac
index fde9600bab27..e592f6da8ce5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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 ===================================================================
diff --git a/cppu/Library_cppu.mk b/cppu/Library_cppu.mk
index 8031487af373..7158c2bb80e0 100644
--- a/cppu/Library_cppu.mk
+++ b/cppu/Library_cppu.mk
@@ -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 \
 ))
diff --git a/cppu/Library_purpenvhelper.mk b/cppu/Library_purpenvhelper.mk
index 42c03749a4b7..404a8dc23d74 100644
--- a/cppu/Library_purpenvhelper.mk
+++ b/cppu/Library_purpenvhelper.mk
@@ -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,\
diff --git a/cppuhelper/Library_cppuhelper.mk b/cppuhelper/Library_cppuhelper.mk
index 5741eea6476f..3c87054b45ab 100644
--- a/cppuhelper/Library_cppuhelper.mk
+++ b/cppuhelper/Library_cppuhelper.mk
@@ -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 \
 ))
diff --git a/sal/Library_sal.mk b/sal/Library_sal.mk
index d783c84e39e9..f7c7b3ab1764 100644
--- a/sal/Library_sal.mk
+++ b/sal/Library_sal.mk
@@ -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 \
diff --git a/salhelper/Library_salhelper.mk b/salhelper/Library_salhelper.mk
index a97666dafe2f..287c215158b5 100644
--- a/salhelper/Library_salhelper.mk
+++ b/salhelper/Library_salhelper.mk
@@ -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 \
 ))
diff --git a/solenv/gbuild/Library.mk b/solenv/gbuild/Library.mk
index a4f1fe7b376a..6562cbf41d34 100644
--- a/solenv/gbuild/Library.mk
+++ b/solenv/gbuild/Library.mk
@@ -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:
diff --git a/solenv/gbuild/LinkTarget.mk b/solenv/gbuild/LinkTarget.mk
index 9c7e9e3bceaf..29924c9897e0 100644
--- a/solenv/gbuild/LinkTarget.mk
+++ b/solenv/gbuild/LinkTarget.mk
@@ -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:
diff --git a/solenv/gbuild/platform/com_MSC_class.mk 
b/solenv/gbuild/platform/com_MSC_class.mk
index 0d35b7915999..80944fe70ba4 100644
--- a/solenv/gbuild/platform/com_MSC_class.mk
+++ b/solenv/gbuild/platform/com_MSC_class.mk
@@ -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
diff --git a/solenv/gbuild/platform/com_MSC_defs.mk 
b/solenv/gbuild/platform/com_MSC_defs.mk
index 07720dc2e2f1..273e17ea71f0 100644
--- a/solenv/gbuild/platform/com_MSC_defs.mk
+++ b/solenv/gbuild/platform/com_MSC_defs.mk
@@ -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

Reply via email to