Hi Erik, yes it makes the build more chatty - our linux s390 product build log of jdk/jdk goes from ~ 60.000 lines to ~ 123.000 lines with the patch.
However the change is linux s390 only so I guess it will not disturb other people ( in case we bring it to more platforms later on, we could remove the printing or make it configurable ). Additionally the "chatty" output is used currently for eliminating unused functions + data cross-platform (see for example https://bugs.openjdk.java.net/browse/JDK-8234629 ). Best regards, Matthias > > Hello Matthias, > > This looks like an interesting change. If you want to enable this for > s390x, I'm ok with it. If it works out well, perhaps we can find a way > to expand this to other architectures. > > Do you really want to set --print-gc-sections by default? I would assume > that makes the build quite chatty. > > /Erik > > On 2019-11-21 00:54, Baesken, Matthias wrote: > > Hello, > > > > gcc and ld can be instructed to work together to "garbage collect" unused > input sections. > > This feature eliminates unused code from native libraries. As a prerequisite > to take full advantage of the feature, > > the source files need to be compiled with "-ffunction-sections -fdata- > sections". > > > > Details on what happens can be found in the ld documentation: > https://linux.die.net/man/1/ld . > > See the description of --gc-sections and --print-gc-sections therein. > > For more detailed insights there is a talk available from ELC2010: > https://elinux.org/images/2/2d/ELC2010-gc-sections_Denys_Vlasenko.pdf > > > > My change enables the unused code elimination on linux s390x . > > (on the other Linux platforms, there are still issues to be solved with the > serviceability agent, but we do not have the serviceability agent on linux > s390x). > > > > The change has 2 benefits : > > - native libs with unused code get smaller (some get alot smaller) > > some example lib sizes from linuxs390x (product build) : > > default settings / link-time gc-sections > > libmlib_image.so 556K 536K > > libjavajpeg.so 300K 292K > > libsplashscreen.so 412K 268K > > libfontmanager.so 1.4M 864K > > libjvm.so 19M 17M > > > > - the flag --print-gc-sections outputs the removed sections when calling > the linker; > > this helps a lot to find coding "waiting for" cross-platform removal. > > > > > > Here is an example output of --print-gc-sections for the libnet-build (linux > s390x) : > > > > /bin/ld: Removing unused section '.bss.my_gconf_init_func' in file > '/builddir/support/native/java.base/libnet/DefaultProxySelector.o' <--- > seems to be dead > > /bin/ld: Removing unused section '.text.NET_ReadV' in file > '/builddir/support/native/java.base/libnet/linux_close.o' > <--- seems > to be dead, I requested cross-platform removal with > https://bugs.openjdk.java.net/browse/JDK-8234501 > > /bin/ld: Removing unused section '.text.getInet6Address_scopeifname' in > file '/builddir/support/native/java.base/libnet/net_util.o' <--- seems to > be > dead > > /bin/ld: Removing unused section '.text.getInet6Address_scopeid_set' in > file '/builddir/support/native/java.base/libnet/net_util.o' <--- seems to > be > dead > > /bin/ld: Removing unused section '.text.getInetAddress_hostName' in file > '/builddir/support/native/java.base/libnet/net_util.o' <--- seems to be > dead > > /bin/ld: Removing unused section '.text.setDefaultScopeID' in file > '/builddir/support/native/java.base/libnet/net_util_md.o' <--- > seems to > be dead indeed > > /bin/ld: Removing unused section '.text.getDefaultScopeID' in file > '/builddir/support/native/java.base/libnet/net_util_md.o' <--- > seems to > be dead indeed > > /bin/ld: Removing unused section '.text.kernelIsV24' in file > '/builddir/support/native/java.base/libnet/net_util_md.o' <--- > seems to be dead indeed > > /bin/ld: Removing unused section '.bss.ni_defaultIndexID.8722' in file > '/builddir/support/native/java.base/libnet/net_util_md.o' <--- only used > in getDefaultScopeID , which is dead > > /bin/ld: Removing unused section '.bss.ni_class.8721' in file > '/builddir/support/native/java.base/libnet/net_util_md.o' <--- > only > used in getDefaultScopeID , which is dead > > /bin/ld: Removing unused section '.bss.vinit24' in file > '/builddir/support/native/java.base/libnet/net_util_md.o' > <--- > only used in kernelIsV24 which is dead > > /bin/ld: Removing unused section '.bss.kernelV24' in file > '/builddir/support/native/java.base/libnet/net_util_md.o' > <--- only > used in kernelIsV24 which is dead > > > > bug/webrev : > > https://bugs.openjdk.java.net/browse/JDK-8234525 > > > > http://cr.openjdk.java.net/~mbaesken/webrevs/8234525.1/ > > > > Thanks, Matthias > > > >