Fix annocheck optimization issues.

Resolves: RHBZ#1630426
This commit is contained in:
Severin Gehwolf 2018-09-19 14:06:45 +02:00
parent 706e00d456
commit 0c4d834e94
6 changed files with 232 additions and 2 deletions

View File

@ -0,0 +1,57 @@
diff --git openjdk.orig/jdk/make/lib/CoreLibraries.gmk openjdk/jdk/make/lib/CoreLibraries.gmk
--- openjdk.orig/jdk/make/lib/CoreLibraries.gmk
+++ openjdk/jdk/make/lib/CoreLibraries.gmk
@@ -37,21 +37,32 @@ ifeq ($(OPENJDK_TARGET_OS), solaris)
endif
ifeq ($(OPENJDK_TARGET_OS), linux)
- ifeq ($(OPENJDK_TARGET_CPU), ppc64)
- BUILD_LIBFDLIBM_OPTIMIZATION := HIGH
- else ifeq ($(OPENJDK_TARGET_CPU), ppc64le)
- BUILD_LIBFDLIBM_OPTIMIZATION := HIGH
- else ifeq ($(OPENJDK_TARGET_CPU), aarch64)
- BUILD_LIBFDLIBM_OPTIMIZATION := HIGH
- endif
-endif
-
-ifneq ($(OPENJDK_TARGET_OS), macosx)
+ BUILD_LIBFDLIBM_OPTIMIZATION := HIGH
+ LIBFDLIBM_CFLAGS_LINUX := -ffp-contract=off
# Unfortunately, '-ffp-contract' is only available since gcc 4.6. For ppc64le
# that's no problem since ppc64le support only appeared in gcc 4.8.3. But on
# ppc64 (big endian) we traditionally compiled with gcc 4.3 which only knows
# '-mno-fused-madd'. However, that's still not enough to get the float
# computations right - we additionally have to supply '-fno-strict-aliasing'.
+ #
+ #
+ ifeq ($(TOOLCHAIN_TYPE), gcc)
+ CC_VER_MAJOR := $(shell $(CC) -dumpversion | cut -d'.' -f1)
+ CC_VER_MINOR := $(shell $(CC) -dumpversion | cut -d'.' -f2)
+ endif
+ # Only GCC 4.6 and better have machine independent -ffp-contract=off.
+ # For other versions we need to explicitly set arch specific machine
+ # flags or keep optimization off.
+ ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 6 \) \))" "0"
+ ifeq ($(OPENJDK_TARGET_CPU), ppc64)
+ LIBFDLIBM_CFLAGS_LINUX := -mno-fused-madd -fno-strict-aliasing
+ else
+ BUILD_LIBFDLIBM_OPTIMIZATION := NONE
+ endif
+ endif
+endif
+
+ifneq ($(OPENJDK_TARGET_OS), macosx)
$(eval $(call SetupNativeCompilation,BUILD_LIBFDLIBM, \
STATIC_LIBRARY := fdlibm, \
OUTPUT_DIR := $(JDK_OUTPUTDIR)/objs, \
@@ -62,9 +73,7 @@ ifneq ($(OPENJDK_TARGET_OS), macosx)
-I$(JDK_TOPDIR)/src/share/native/java/lang/fdlibm/include, \
CFLAGS_windows_debug := -DLOGGING, \
CFLAGS_aix := -qfloat=nomaf, \
- CFLAGS_linux_ppc64 := -mno-fused-madd -fno-strict-aliasing, \
- CFLAGS_linux_ppc64le := -ffp-contract=off, \
- CFLAGS_linux_aarch64 := -ffp-contract=off, \
+ CFLAGS_linux := $(LIBFDLIBM_CFLAGS_LINUX), \
ARFLAGS := $(ARFLAGS), \
OBJECT_DIR := $(JDK_OUTPUTDIR)/objs/libfdlibm, \
DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES)))

View File

@ -0,0 +1,83 @@
diff --git openjdk.orig/hotspot/make/linux/makefiles/amd64.make openjdk/hotspot/make/linux/makefiles/amd64.make
--- openjdk.orig/hotspot/make/linux/makefiles/amd64.make
+++ openjdk/hotspot/make/linux/makefiles/amd64.make
@@ -22,10 +22,13 @@
#
#
-# The copied fdlibm routines in sharedRuntimeTrig.o must not be optimized
-OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT)
-# The copied fdlibm routines in sharedRuntimeTrans.o must not be optimized
-OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT)
+ifeq ($(OPT_CFLAGS_NO_FMA),)
+ OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT)
+ OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT)
+else
+ OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/SPEED) $(OPT_CFLAGS_NO_FMA)
+ OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/SPEED) $(OPT_CFLAGS_NO_FMA)
+endif
# Must also specify if CPU is little endian
CFLAGS += -DVM_LITTLE_ENDIAN
diff --git openjdk.orig/hotspot/make/linux/makefiles/gcc.make openjdk/hotspot/make/linux/makefiles/gcc.make
--- openjdk.orig/hotspot/make/linux/makefiles/gcc.make
+++ openjdk/hotspot/make/linux/makefiles/gcc.make
@@ -225,6 +225,16 @@
OPT_CFLAGS/SIZE=-Os
OPT_CFLAGS/SPEED=-O3
+ifeq ($(USE_CLANG),)
+ # Only GCC 4.6 and better have machine independent -ffp-contract=off.
+ # For other versions we need to explicitly set arch specific machine
+ # flags or keep optimization off for them.
+ ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 6 \) \))" "1"
+ OPT_CFLAGS_NO_FMA = -ffp-contract=off
+ endif
+endif
+
+
# Hotspot uses very unstrict aliasing turn this optimization off
# This option is added to CFLAGS rather than OPT_CFLAGS
# so that OPT_CFLAGS overrides get this option too.
diff --git openjdk.orig/hotspot/make/linux/makefiles/i486.make openjdk/hotspot/make/linux/makefiles/i486.make
--- openjdk.orig/hotspot/make/linux/makefiles/i486.make
+++ openjdk/hotspot/make/linux/makefiles/i486.make
@@ -24,10 +24,13 @@
# TLS helper, assembled from .s file
-# The copied fdlibm routines in sharedRuntimeTrig.o must not be optimized
-OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT)
-# The copied fdlibm routines in sharedRuntimeTrans.o must not be optimized
-OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT)
+ifeq ($(OPT_CFLAGS_NO_FMA),)
+ OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT)
+ OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT)
+else
+ OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/SPEED) $(OPT_CFLAGS_NO_FMA)
+ OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/SPEED) $(OPT_CFLAGS_NO_FMA)
+endif
# Must also specify if CPU is little endian
CFLAGS += -DVM_LITTLE_ENDIAN
diff --git openjdk.orig/hotspot/make/linux/makefiles/ppc64.make openjdk/hotspot/make/linux/makefiles/ppc64.make
--- openjdk.orig/hotspot/make/linux/makefiles/ppc64.make
+++ openjdk/hotspot/make/linux/makefiles/ppc64.make
@@ -49,3 +49,17 @@
# Use Power8, this is the first CPU to support PPC64 LE with ELFv2 ABI.
CFLAGS += -mcpu=power7 -mtune=power8 -minsert-sched-nops=regroup_exact -mno-multiple -mno-string
endif
+
+ifeq ($(OPT_CFLAGS_NO_FMA),)
+ ifeq ($(OPENJDK_TARGET_CPU_ENDIAN),big)
+ OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/SPEED) -mno-fused-madd -fno-strict-aliasing
+ OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/SPEED) -mno-fused-madd -fno-strict-aliasing
+ else
+ OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT)
+ OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT)
+ endif
+else
+ OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/SPEED) $(OPT_CFLAGS_NO_FMA)
+ OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/SPEED) $(OPT_CFLAGS_NO_FMA)
+endif
+

View File

@ -0,0 +1,22 @@
diff --git openjdk.orig/hotspot/make/linux/makefiles/aarch64.make openjdk/hotspot/make/linux/makefiles/aarch64.make
index 3d17326..7cdb498 100644
--- openjdk.orig/hotspot/make/linux/makefiles/aarch64.make
+++ openjdk/hotspot/make/linux/makefiles/aarch64.make
@@ -22,10 +22,13 @@
#
#
-# The copied fdlibm routines in sharedRuntimeTrig.o must not be optimized
-OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT)
-# The copied fdlibm routines in sharedRuntimeTrans.o must not be optimized
-OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT)
+ifeq ($(OPT_CFLAGS_NO_FMA),)
+ OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT)
+ OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT)
+else
+ OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/SPEED) $(OPT_CFLAGS_NO_FMA)
+ OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/SPEED) $(OPT_CFLAGS_NO_FMA)
+endif
# Must also specify if CPU is little endian
CFLAGS += -DVM_LITTLE_ENDIAN

View File

@ -0,0 +1,23 @@
diff --git openjdk.orig/hotspot/make/linux/makefiles/saproc.make openjdk/hotspot/make/linux/makefiles/saproc.make
--- openjdk.orig/hotspot/make/linux/makefiles/saproc.make
+++ openjdk/hotspot/make/linux/makefiles/saproc.make
@@ -59,6 +59,11 @@
SA_DEBUG_CFLAGS = -g
endif
+# Optimize saproc lib at level -O3 unless it's a slowdebug build
+ifneq ($(DEBUG_LEVEL), slowdebug)
+ SA_OPT_FLAGS = $(OPT_CFLAGS)
+endif
+
# if $(AGENT_DIR) does not exist, we don't build SA
# also, we don't build SA on Itanium or zero.
@@ -95,6 +100,7 @@
$(SASRCFILES) \
$(SA_LFLAGS) \
$(SA_DEBUG_CFLAGS) \
+ $(SA_OPT_FLAGS) \
$(EXTRA_CFLAGS) \
-o $@ \
-lthread_db

View File

@ -0,0 +1,20 @@
diff --git openjdk.orig/hotspot/make/linux/makefiles/jsig.make openjdk/hotspot/make/linux/makefiles/jsig.make
--- openjdk.orig/hotspot/make/linux/makefiles/jsig.make
+++ openjdk/hotspot/make/linux/makefiles/jsig.make
@@ -51,10 +51,15 @@ ifeq ($(DEBUG_BINARIES), true)
JSIG_DEBUG_CFLAGS = -g
endif
+# Optimize jsig lib at level -O3 unless it's a slowdebug build
+ifneq ($(DEBUG_LEVEL), slowdebug)
+ JSIG_OPT_FLAGS = $(OPT_CFLAGS)
+endif
+
$(LIBJSIG): $(JSIGSRCDIR)/jsig.c $(LIBJSIG_MAPFILE)
@echo Making signal interposition lib...
$(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) $(SHARED_FLAG) $(PICFLAG) \
- $(LFLAGS_JSIG) $(JSIG_DEBUG_CFLAGS) $(EXTRA_CFLAGS) -o $@ $< -ldl
+ $(LFLAGS_JSIG) $(JSIG_DEBUG_CFLAGS) $(JSIG_OPT_FLAGS) $(EXTRA_CFLAGS) -o $@ $< -ldl
ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJSIG_DEBUGINFO)
ifeq ($(STRIP_POLICY),all_strip)

View File

@ -104,8 +104,8 @@
# Filter out flags from the optflags macro that cause problems with the OpenJDK build # Filter out flags from the optflags macro that cause problems with the OpenJDK build
# We filter out -O flags so that the optimization of HotSpot is not lowered from O3 to O2
# We filter out -Wall which will otherwise cause HotSpot to produce hundreds of thousands of warnings (100+mb logs) # We filter out -Wall which will otherwise cause HotSpot to produce hundreds of thousands of warnings (100+mb logs)
# We filter out -O flags so that the optimization of HotSpot is not lowered from O3 to O2
# We replace it with -Wformat (required by -Werror=format-security) and -Wno-cpp to avoid FORTIFY_SOURCE warnings # We replace it with -Wformat (required by -Werror=format-security) and -Wno-cpp to avoid FORTIFY_SOURCE warnings
# We filter out -fexceptions as the HotSpot build explicitly does -fno-exceptions and it's otherwise the default for C++ # We filter out -fexceptions as the HotSpot build explicitly does -fno-exceptions and it's otherwise the default for C++
%global ourflags %(echo %optflags | sed -e 's|-Wall|-Wformat -Wno-cpp|' | sed -r -e 's|-O[0-9]*||') %global ourflags %(echo %optflags | sed -e 's|-Wall|-Wformat -Wno-cpp|' | sed -r -e 's|-O[0-9]*||')
@ -961,7 +961,7 @@ Provides: java-%{javaver}-%{origin}-accessibility = %{epoch}:%{version}-%{releas
Name: java-%{javaver}-%{origin} Name: java-%{javaver}-%{origin}
Version: %{javaver}.%{updatever}.%{buildver} Version: %{javaver}.%{updatever}.%{buildver}
Release: 3%{?dist} Release: 4%{?dist}
# java-1.5.0-ibm from jpackage.org set Epoch to 1 for unknown reasons # java-1.5.0-ibm from jpackage.org set Epoch to 1 for unknown reasons
# and this change was brought into RHEL-4. java-1.5.0-ibm packages # and this change was brought into RHEL-4. java-1.5.0-ibm packages
# also included the epoch in their virtual provides. This created a # also included the epoch in their virtual provides. This created a
@ -1126,6 +1126,18 @@ Patch576: 8064786-pr3599.patch
Patch577: 8062808-pr3548.patch Patch577: 8062808-pr3548.patch
# s390: JDK-8203030, Type fixing for s390 # s390: JDK-8203030, Type fixing for s390
Patch102: 8203030-size_t-fixes.patch Patch102: 8203030-size_t-fixes.patch
# 8210761: libjsig is being compiled without optimization
Patch620: 8210761-rh1630426-jsig-opt-fix.patch
# 8210647: libsaproc is being compiled without optimization
Patch621: 8210647-rh1630426-saproc-opt-fix.patch
# 8210416: [linux] Poor StrictMath performance due to non-optimized compilation
Patch622: 8210416-rh1630426-strict-math-opt.patch
# 8210425: [x86] sharedRuntimeTrig/sharedRuntimeTrans compiled without optimization
# Upstream 8u part.
Patch623: 8210425-01-rh1630426-hotspot-opt-fix.patch
# 8210425: [x86] sharedRuntimeTrig/sharedRuntimeTrans compiled without optimization
# Aarch64-port 8u local part
Patch624: 8210425-02-rh1630426-hotspot-opt-fix-aarch64.patch
############################################# #############################################
# #
@ -1613,6 +1625,11 @@ sh %{SOURCE12}
%patch579 %patch579
%patch580 %patch580
%patch581 %patch581
%patch620
%patch621
%patch622
%patch623
%patch624
# RPM-only fixes # RPM-only fixes
%patch525 %patch525
@ -2268,6 +2285,14 @@ require "copy_jdk_configs.lua"
%endif %endif
%changelog %changelog
* Thu Sep 27 2018 Severin Gehwolf <sgehwolf@redhat.com> - 1:1.8.0.181.b15-4
- Add fixes for optimization gaps (annocheck issues):
- 8210761: libjsig is being compiled without optimization
- 8210647: libsaproc is being compiled without optimization
- 8210416: [linux] Poor StrictMath performance due to non-optimized compilation
- 8210425: [x86] sharedRuntimeTrig/sharedRuntimeTrans compiled without optimization
8u upstream and aarch64/jdk8u upstream versions.
* Wed Sep 26 2018 Severin Gehwolf <sgehwolf@redhat.com> - 1:1.8.0.181.b15-3 * Wed Sep 26 2018 Severin Gehwolf <sgehwolf@redhat.com> - 1:1.8.0.181.b15-3
- Renamed more patches for clarity: - Renamed more patches for clarity:
include-all-srcs.patch => 8044235-include-all-srcs.patch include-all-srcs.patch => 8044235-include-all-srcs.patch