Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GR-41675] libmanagement_ext.a unconditionally being added when libawt_headless.a is linked in #5119

Closed
jerboaa opened this issue Sep 30, 2022 · 1 comment · Fixed by #5122

Comments

@jerboaa
Copy link
Collaborator

jerboaa commented Sep 30, 2022

Describe the issue
For an application, which doesn't use class com.sun.management.internal.OperatingSystemImpl, but does use ImageIO classes for example via libawt_headless, then libmanagement_ext.a static library ends up getting linked into the image no matter what.

Steps to reproduce the issue

  1. git clone --branch imageio-management-ext https://github.com/jerboaa/mandrel-integration-tests.git
  2. cd mandrel-integration-tests
  3. export JAVA_HOME=/path/to/graalvm; export GRAALVM_HOME=$JAVA_HOME; export PATH=$JAVA_HOME/bin:$PATH
  4. mvn clean verify -Dquarkus.version=2.12.3.Final -Ptestsuite -Dtest=AppReproducersTest#imageioAWTTest

Describe GraalVM and your environment:

  • GraalVM version: built from source, revision 59c0c26
  • JDK major version: 17
  • OS: Linux
  • Architecture: AMD64

More details
This code seems to add libmanagement_ext.a irrespective of it actually needed:

    @Override
    public void afterAnalysis(AfterAnalysisAccess access) {
        if (NativeLibrarySupport.singleton().isPreregisteredBuiltinLibrary("awt_headless")) {
            /*
             * Ensure that `management_ext` comes before `awt_headless` on the linker command line.
             * This is necessary to prevent linker errors such as JDK-8264047.
             */
            nativeLibraries.addStaticNonJniLibrary("management_ext", "awt_headless");
        }
    }

Originally found here: Karm/mandrel-integration-tests#117

@jerboaa jerboaa self-assigned this Sep 30, 2022
jerboaa added a commit to jerboaa/graal that referenced this issue Sep 30, 2022
On some systems/apps, libawt_headless gets pulled in. This currently
brings in libmanagement_ext unconditionally. However, libmanagement_ext
should only be present for linking iff
com.sun.management.internal.OperatingSystemImpl class becomes reachable.

Closes: oracle#5119
@jerboaa
Copy link
Collaborator Author

jerboaa commented Sep 30, 2022

For the linked sample app we see libmanagement_ext.a present:

$ strings target/imageio | grep com.oracle.svm.core.VM.Target.StaticLibraries | grep management_ext
com.oracle.svm.core.VM.Target.StaticLibraries=libnet.a|libjavajpeg.a|libnio.a|libmanagement_ext.a|liblibchelper.a|libjava.a|liblcms.a|libfontmanager.a|libawt_headless.a|libawt.a|libfdlibm.a|libzip.a|libjvm.a

yet, with -H:PrintAnalysisCallTreeType=CSV turned on and looking for OperatingSystemImpl class it turns up empty:

$ grep OperatingSystemImpl /disk/graal/upstream-sources/mandrel-integration-tests/apps/imageio/reports/used_classes_imageio_20220930_142603.txt
$ grep ImageIO /disk/graal/upstream-sources/mandrel-integration-tests/apps/imageio/reports/used_classes_imageio_20220930_142603.txt
javax.imageio.ImageIO
javax.imageio.ImageIO$CacheInfo
javax.imageio.ImageIO$CanDecodeInputFilter
javax.imageio.ImageIO$CanEncodeImageAndFormatFilter
javax.imageio.ImageIO$ContainsFilter
javax.imageio.ImageIO$ImageReaderIterator
javax.imageio.ImageIO$ImageWriterIterator

jerboaa added a commit to jerboaa/graal that referenced this issue Oct 3, 2022
On some systems/apps, libawt_headless gets pulled in. This currently
brings in libmanagement_ext unconditionally. However, libmanagement_ext
should only be present for linking iff
com.sun.management.internal.OperatingSystemImpl class becomes reachable.

Closes: oracle#5119
@fniephaus fniephaus changed the title libmanagement_ext.a unconditionally being added when libawt_headless.a is linked in [GR-41675] libmanagement_ext.a unconditionally being added when libawt_headless.a is linked in Oct 11, 2022
zakkak pushed a commit to zakkak/mandrel that referenced this issue Oct 18, 2022
On some systems/apps, libawt_headless gets pulled in. This currently
brings in libmanagement_ext unconditionally. However, libmanagement_ext
should only be present for linking iff
com.sun.management.internal.OperatingSystemImpl class becomes reachable.

Closes: oracle#5119
zakkak pushed a commit to graalvm/mandrel that referenced this issue Oct 18, 2022
On some systems/apps, libawt_headless gets pulled in. This currently
brings in libmanagement_ext unconditionally. However, libmanagement_ext
should only be present for linking iff
com.sun.management.internal.OperatingSystemImpl class becomes reachable.

Closes: oracle#5119
zakkak pushed a commit to zakkak/mandrel that referenced this issue Nov 1, 2022
On some systems/apps, libawt_headless gets pulled in. This currently
brings in libmanagement_ext unconditionally. However, libmanagement_ext
should only be present for linking iff
com.sun.management.internal.OperatingSystemImpl class becomes reachable.

Closes: oracle#5119
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant