This is an automated email from the ASF dual-hosted git repository.

truckman pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/openoffice.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 87b5bd1523 Avoid compiling with -Os optimization
87b5bd1523 is described below

commit 87b5bd1523182d511fe508ae9f84c948f97f0721
Author: Don Lewis <truck...@apache.org>
AuthorDate: Sun Nov 17 04:41:25 2024 -0800

    Avoid compiling with -Os optimization
    
    Clang's -Os optimiation appears to be somewhat buggy.  Different
    versions generate code that crashes in different ways.  Try to
    avoid this by switching to the more exercised -O2 optimization.
    To conserve address space on 32-bit Intel, disable inlining and
    loop unrolling.
---
 main/solenv/gbuild/platform/freebsd.mk | 28 +++++++++++++++++-----------
 main/solenv/inc/unxfbsdi.mk            | 11 ++++-------
 2 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/main/solenv/gbuild/platform/freebsd.mk 
b/main/solenv/gbuild/platform/freebsd.mk
index 6fa486e0e2..92b651c799 100644
--- a/main/solenv/gbuild/platform/freebsd.mk
+++ b/main/solenv/gbuild/platform/freebsd.mk
@@ -153,17 +153,23 @@ ifeq ($(gb_DEBUGLEVEL),2)
 gb_COMPILEROPTFLAGS := -O0
 gb_COMPILEROPT1FLAGS := -O0
 else
-# Clang versions 3.6.x and 3.7.x generate bad DWARF CFI for stack unwinding
-# on 32-bit Intel when compiling with -Os optimization.  See
-# <https://llvm.org/bugs/show_bug.cgi?id=24792>
-# Work around this by using "-O2 -fno-unroll-loops" instead.
-ifeq ($(COM)$(CPUNAME)$(shell expr $(CCNUMVER) '>=' 000300060000 '&' 
$(CCNUMVER) '<' 000300080000),CLANGINTEL1)
-gb_COMPILEROPTFLAGS := -O2 -fno-unroll-loops
+# Clang -Os seems to be buggy
+# Reduce code size on i386
+ifeq ($(CPUNAME),INTEL)
+ifeq ($(COM),CLANG)
+gb_COMPILEROPTFLAGS := -O2 -fno-unroll-loops -fno-inline
+gb_COMPILEROPT1FLAGS := -O1 -fno-unroll-loops -fno-inline
 else
-gb_COMPILEROPTFLAGS := -Os
+# gcc
+gb_COMPILEROPTFLAGS := -O2 -fno-unroll-loops -finline-limit=0 -fno-inline 
-fno-default-inline
+gb_COMPILEROPT1FLAGS := -O1 -fno-unroll-loops -finline-limit=0 -fno-inline 
-fno-default-inline
 endif
+else
+# X86_X4
+gb_COMPILEROPTFLAGS := -O2
 gb_COMPILEROPT1FLAGS := -O1
 endif
+endif
 
 gb_COMPILERNOOPTFLAGS := -O0
 
@@ -266,15 +272,15 @@ endif
 
 ifeq ($(COM),CLANG)
 ifeq ($(ENABLE_SYMBOLS),SMALL)
-gb_DEBUG_CFLAGS := -ggdb1 -fno-inline
+gb_DEBUG_CFLAGS := -ggdb1
 else
-gb_DEBUG_CFLAGS := -ggdb3 -fno-inline
+gb_DEBUG_CFLAGS := -ggdb3
 endif
 else
 ifeq ($(ENABLE_SYMBOLS),SMALL)
-gb_DEBUG_CFLAGS := -ggdb1 -finline-limit=0 -fno-inline -fno-default-inline
+gb_DEBUG_CFLAGS := -ggdb1
 else
-gb_DEBUG_CFLAGS := -ggdb3 -finline-limit=0 -fno-inline -fno-default-inline
+gb_DEBUG_CFLAGS := -ggdb3
 endif
 endif
 
diff --git a/main/solenv/inc/unxfbsdi.mk b/main/solenv/inc/unxfbsdi.mk
index 5d99f051c8..1767eff36e 100644
--- a/main/solenv/inc/unxfbsdi.mk
+++ b/main/solenv/inc/unxfbsdi.mk
@@ -33,14 +33,11 @@ ARCH_FLAGS*=-mtune=pentiumpro
 
 # Compiler flags for enabling optimizations
 .IF "$(PRODUCT)"!=""
-# Clang versions 3.6.x and 3.7.x generate bad DWARF CFI for stack unwinding
-# on 32-bit Intel when compiling with -Os optimization.  See
-# <https://llvm.org/bugs/show_bug.cgi?id=24792>
-# Work around this by using "-O2 -fno-unroll-loops" instead.
-.IF "$(COM)"=="CLANG" && "$(CCNUMVER)">="000300060000" && 
"$(CCNUMVER)"<="000300079999"
-CFLAGSOPT=-O2 -fno-unroll-loops -fno-strict-aliasing   # optimizing for 
products
+# Clang -Os optimization seems to be buggy, use -O2
+.IF "$(COM)"=="CLANG"
+CFLAGSOPT=-O2 -fno-unroll-loops -fno-inline -fno-strict-aliasing       # 
optimizing for products
 .ELSE
-CFLAGSOPT=-Os -fno-strict-aliasing             # optimizing for products
+CFLAGSOPT=-O2 -fno-unroll-loops -finline-limit=0 -fno-inline 
-fno-default-inline -fno-strict-aliasing          # optimizing for products
 .ENDIF
 .ELSE  # "$(PRODUCT)"!=""
 CFLAGSOPT=                                     # no optimizing for non products

Reply via email to