On 1/27/21 10:35 AM, Magnus Ihse Bursie wrote: > On 2021-01-26 17:08, Matthias Klose wrote: >> Several Linux distros now build with link time optimizations (-flto=auto) by >> default. It looks like 15 and newer versions can be built with -flto. I >> haven't >> yet checked test results for LTO/non-LTO builds. I also only tried building >> with >> GCC 10. >> >> 11 still fails with >> /usr/bin/ld: /tmp/libjvm.so.xGmnnW.ltrans45.ltrans.o: in function >> `G1CMOopClosure::do_oop(oopDesc**)': >> /<<BUILDDIR>>/openjdk-lts-11.0.9.1+1/make/hotspot/./src/hotspot/share/gc/g1/g1OopClosures.hpp:176: >> >> undefined reference to `void >> G1CMOopClosure::do_oop_work<oopDesc*>(oopDesc**)' >> [...] >> >> However this might be just the first build failure. > > Is this when building with --enable-jvm-feature-link-time-opt on linux-x64?
No, just passing -flto=auto in CFLAGS, CXXFLAGS, and LDFLAGS, and configuring with --with-extra-*flags here's a build log for such kind of build: https://launchpad.net/ubuntu/+archive/test-rebuild-20201216-hirsute-lto/+build/20573901 > When I try that (with gcc-10 on Ubuntu) on the mainline, I get: [...] these seem to be warnings "only". A 16+33 build configured with --enable-jvm-feature-link-time-opt also succeeds for me. at least for GCC, the LTO streaming format doesn't collect warning options, so maybe these should be passed to the linker explicitly when configuring with the lto option. > I don't think anyone used LTO seriously since the old Oracle arm-32 port. The > major blocker is the added linking time spent for hotspot, I think. Patches to > fix this is more than welcome, though! currently --enable-jvm-feature-link-time-opt only builds with -flto, and therefore sequentially. An obvious thing to do is either to build with -flto=auto or -flto=jobserver to use all available cores for the link. I also saw in the link: /usr/bin/nm: bytecodeHistogram.o: no symbols /usr/bin/nm: c1_Defs.o: no symbols /usr/bin/nm: instanceOop.o: no symbols /usr/bin/nm: oopsHierarchy.o: no symbols /usr/bin/nm: operator_new.o: no symbols /usr/bin/nm: register.o: no symbols /usr/bin/nm: vm_version_linux_x86.o: no symbols /usr/bin/nm: weakProcessorPhases.o: no symbols Creating mapfile Linking libjvm.so if something relies on the object code, then maybe use -ffat-lto-objects, although this will slow down the build of the object files. Matthias