8234525: enable link-time section-gc for linux s390x to remove unused code
authormbaesken
Wed, 27 Nov 2019 10:07:29 +0100
changeset 59287 c04fa10636fd
parent 59286 a2441ac23eeb
child 59289 c887851da33d
8234525: enable link-time section-gc for linux s390x to remove unused code Reviewed-by: erikj, mdoerr
make/autoconf/flags-cflags.m4
make/autoconf/flags-ldflags.m4
--- a/make/autoconf/flags-cflags.m4	Tue Nov 26 13:55:11 2019 +0100
+++ b/make/autoconf/flags-cflags.m4	Wed Nov 27 10:07:29 2019 +0100
@@ -532,6 +532,11 @@
   if test "x$TOOLCHAIN_TYPE" = xgcc; then
     TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM -fcheck-new -fstack-protector"
     TOOLCHAIN_CFLAGS_JDK="-pipe -fstack-protector"
+    # reduce lib size on s390x in link step, this needs also special compile flags
+    if test "x$OPENJDK_TARGET_CPU" = xs390x; then
+      TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM -ffunction-sections -fdata-sections"
+      TOOLCHAIN_CFLAGS_JDK="$TOOLCHAIN_CFLAGS_JDK -ffunction-sections -fdata-sections"
+    fi
     # technically NOT for CXX (but since this gives *worse* performance, use
     # no-strict-aliasing everywhere!)
     TOOLCHAIN_CFLAGS_JDK_CONLY="-fno-strict-aliasing"
--- a/make/autoconf/flags-ldflags.m4	Tue Nov 26 13:55:11 2019 +0100
+++ b/make/autoconf/flags-ldflags.m4	Wed Nov 27 10:07:29 2019 +0100
@@ -72,6 +72,11 @@
     # Add -z defs, to forbid undefined symbols in object files.
     # add relro (mark relocations read only) for all libs
     BASIC_LDFLAGS="$BASIC_LDFLAGS -Wl,-z,defs -Wl,-z,relro"
+    # s390x : remove unused code+data in link step
+    if test "x$OPENJDK_TARGET_CPU" = xs390x; then
+      BASIC_LDFLAGS="$BASIC_LDFLAGS -Wl,--gc-sections -Wl,--print-gc-sections"
+    fi
+
     BASIC_LDFLAGS_JVM_ONLY="-Wl,-O1"
 
   elif test "x$TOOLCHAIN_TYPE" = xclang; then