RFR: JDK-8190284 link-time-opt should not be using -fwhole-program

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

RFR: JDK-8190284 link-time-opt should not be using -fwhole-program

Magnus Ihse Bursie
When building hotspot with link-time-opt, we are currently using
-fwhole-program to the linker. This causes all public symbols to be
removed. To counter this, the attribute "externally_visible" has been
added to JNIEXPORT for arm (the platform that traditionally has used
link-time-opt).

This is not an appropriate way of doing things.

The gcc documentation says about "-fwhole-program": "This option should
not be used in combination with -flto. Instead relying on a linker
plugin should provide safer and more precise information."

If we replace -fwhole-program with -fuse-linker-plugin, the need to use
externally_visible disappears.

I intend to push this to jdk10/hs. This is a blocker for JDK-8189610.

I have verified that with this change I can build a link-time-opt
libjvm.so on my linux-x64 workstation, that passes superficial tests,
and that is ~4% smaller in size than a non-lto build.

Bug: https://bugs.openjdk.java.net/browse/JDK-8190284
Patch inline:
diff --git a/make/hotspot/lib/JvmFeatures.gmk
b/make/hotspot/lib/JvmFeatures.gmk
--- a/make/hotspot/lib/JvmFeatures.gmk
+++ b/make/hotspot/lib/JvmFeatures.gmk
@@ -157,7 +157,7 @@
    # like the old build, but it's probably not right.
    JVM_OPTIMIZATION :=
    JVM_CFLAGS_FEATURES += -O3 -flto
-  JVM_LDFLAGS_FEATURES += -O3 -flto -fwhole-program -fno-strict-aliasing
+  JVM_LDFLAGS_FEATURES += -O3 -flto -fuse-linker-plugin
-fno-strict-aliasing
  endif

  ifeq ($(call check-jvm-feature, minimal), true)

/Magnus
Reply | Threaded
Open this post in threaded view
|

Re: RFR: JDK-8190284 link-time-opt should not be using -fwhole-program

David Holmes
Hi Magnus,

This seems okay for expediency.

LTO support is obsolete now and could be removed.

Thanks,
David

On 27/10/2017 10:52 PM, Magnus Ihse Bursie wrote:

> When building hotspot with link-time-opt, we are currently using
> -fwhole-program to the linker. This causes all public symbols to be
> removed. To counter this, the attribute "externally_visible" has been
> added to JNIEXPORT for arm (the platform that traditionally has used
> link-time-opt).
>
> This is not an appropriate way of doing things.
>
> The gcc documentation says about "-fwhole-program": "This option should
> not be used in combination with -flto. Instead relying on a linker
> plugin should provide safer and more precise information."
>
> If we replace -fwhole-program with -fuse-linker-plugin, the need to use
> externally_visible disappears.
>
> I intend to push this to jdk10/hs. This is a blocker for JDK-8189610.
>
> I have verified that with this change I can build a link-time-opt
> libjvm.so on my linux-x64 workstation, that passes superficial tests,
> and that is ~4% smaller in size than a non-lto build.
>
> Bug: https://bugs.openjdk.java.net/browse/JDK-8190284
> Patch inline:
> diff --git a/make/hotspot/lib/JvmFeatures.gmk
> b/make/hotspot/lib/JvmFeatures.gmk
> --- a/make/hotspot/lib/JvmFeatures.gmk
> +++ b/make/hotspot/lib/JvmFeatures.gmk
> @@ -157,7 +157,7 @@
>     # like the old build, but it's probably not right.
>     JVM_OPTIMIZATION :=
>     JVM_CFLAGS_FEATURES += -O3 -flto
> -  JVM_LDFLAGS_FEATURES += -O3 -flto -fwhole-program -fno-strict-aliasing
> +  JVM_LDFLAGS_FEATURES += -O3 -flto -fuse-linker-plugin
> -fno-strict-aliasing
>   endif
>
>   ifeq ($(call check-jvm-feature, minimal), true)
>
> /Magnus