adoptium / temurin-build

Eclipse Temurin™ build scripts - common across all releases/versions
Apache License 2.0
1.02k stars 249 forks source link

AIX builds have a dependency on libgcc_s.a for GUI apps #207

Open sxa opened 6 years ago

sxa commented 6 years ago

Although most operations work ok without the GNU runtime library, it would appear that libfontmanager.so is built with a dependency on libgcc_s.a. The result of this is that any GUI application will fail unless the libgcc package is installed on the box and added to the LIBPATH. This appears to affect all versions of the AdoptOpenJDK builds. IBM's AIX java does not have this dependency. I believe it's due to the libfreetype dependency. When the freetype2 package is installed through IBM's version of yum for AIX, a symlink /usr/lib/libfreetype.a is created to /opt/freeware/lib, so that is found correctly, however for the libgcc package, there is no such symlink so it is not in the default search PATH and LIBPATH has to be set to include /opt/freeware/lib64 for GUI apps to work. I'm not sure if there's any obvious way around this, but I'm opening this issue to at least have it documented for now.

AdoptOpenJDK8 (HotSpot)

$ jdk8u144-b01/bin/java -jar myguiapp.jar                            ar
Exception in thread "main" java.lang.UnsatisfiedLinkError: /home/jck/jdk8u144-b01/jre/lib/ppc64/libfontmanager.so: /home/jck/jdk8u144-b01/jre/lib/ppc64/libfontmanager.so, LIBPATH=/home/jck/jdk8u144-b01/jre/lib/ppc64/server:/home/jck/jdk8u144-b01/jre/lib/ppc64:/home/jck/jdk8u144-b01/jre/lib/ppc64/jli:/home/jck/jdk8u144-b01/jre/../lib/ppc64, LD_LIBRARY_PATH= :        0509-022 Cannot load module /usr/lib/libpng16.a(libpng16.so.16).
        0509-150   Dependent module libgcc_s.a(shr.o) could not be loaded.
        0509-022 Cannot load module libgcc_s.a(shr.o).
        0509-026 System error: A file or directory in the path name does not exist.
        0509-022 Cannot load module /home/jck/jdk8u144-b01/jre/lib/ppc64/libfontmanager.so.
        0509-150   Dependent module /usr/lib/libpng16.a(libpng16.so.16) could not be loaded.
        at java.lang.ClassLoader$NativeLibrary.load(Native Method)

AdoptOpenJDK8 with OpenJ9

$ jdk8u152-b16/bin/java -jar myguiapp.jar
Exception in thread "main" java.lang.UnsatisfiedLinkError: fontmanager (Not found in com.ibm.oti.vm.bootstrap.library.path)
        at java.lang.ClassLoader.loadLibraryWithPath(ClassLoader.java:1435)
        at java.lang.ClassLoader.loadLibraryWithClassLoader(ClassLoader.java:1400)
        at java.lang.System.loadLibrary(System.java:567)
        at sun.font.FontManagerNativeLibrary$1.run(FontManagerNativeLibrary.java:61)

AdoptOpenJDK9

$ jdk-9+181/bin/java -jar myguiapp.jar
Exception in thread "main" java.lang.UnsatisfiedLinkError: /home/jck/jdk-9+181/lib/libfontmanager.so: /home/jck/jdk-9+181/lib/libfontmanager.so, LIBPATH=/home/jck/jdk-9+181/lib/server:/home/jck/jdk-9+181/lib:/home/jck/jdk-9+181/lib/jli:/home/jck/jdk-9+181/../lib, LD_LIBRARY_PATH= :      0509-022 Cannot load module /usr/lib/libpng16.a(libpng16.so.16).
        0509-150   Dependent module libgcc_s.a(shr.o) could not be loaded.
        0509-022 Cannot load module libgcc_s.a(shr.o).
        0509-026 System error: A file or directory in the path name does not exist.
        0509-022 Cannot load module /home/jck/jdk-9+181/lib/libfontmanager.so.
        0509-150   Dependent module /usr/lib/libpng16.a(libpng16.so.16) could not be loaded.
        at java.base/java.lang.ClassLoader$NativeLibrary.load(Native Method)
        at java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2614)
        at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2520)
karianna commented 5 years ago

@sxa555 Is this still an issue?

sxa commented 5 years ago

I believe @groeges has still been seeing issues with this.

groeges commented 5 years ago

@sxa555 Is this still an issue?

Not sure whether this is still a problem on the Adopt machines but I have been seeing issues on my local machine with running some of the JTReg tests. Setting LIBPATH and/or LD_LIBRARY_PATH didn't seem to resolve the issue, as the JTReg tests didn't see to pickup these environment variables. I had to either add -e:LIBPATH=/opt/freeware/lib64 to the JTReg command or add a symbolic link to the library ln -s /opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0/6.3.0/libgcc_s.a /usr/lib/libgcc_s.a in order to get the tests to work.

groeges commented 5 years ago

Having checked with the AIX guys in SAP, it seems that on the systems I was using we've installed the wrong libraries. We shouldn't use dependencies which are compiled with GCC and therefore rely on libgcc. Mixing xlc-compiled libraries with gcc-compiled ones is usually not a good idea.

A change, for the special "libfontmanager" case, we could simply build with "--with-freetype=bundled" which will use a freetype version which is bundled with OpenJDK. "--with-freetype=bundled" was introduced in OpenJDK 11.

Having changed to use this option the tests that were failing are now working correctly, without the need to update JTreg command or to add a symbolic link.

karianna commented 5 years ago

@sxa555 Are you happy to close this in that case?

sxa commented 5 years ago

I'll need to do further verification, plus what @groeges is saying above seems to be a JDK11+ specific solution

incyg commented 5 years ago

At @sxa555: Thank you for documenting this error :smile::+1:

I'd like to ask whether this problem is or will be fixed in an upcoming AdoptOpenJDK Java 11 LTS AIX release? Or maybe is it already fixed in a nightly build?

My motivation for asking is the unfortunate fact that two of my company's customers running a web application on their AIX system reported that one of its features stopped working using

openjdk version "11.0.2" 2019-01-15
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.2+9)
Eclipse OpenJ9 VM AdoptOpenJDK (build openj9-0.12.1, JRE 11 AIX ppc64-64-Bit Compressed References 20190204_121 (JIT enabled, AOT enabled)
OpenJ9   - 90dd8cb
OMR      - d2f4534
JCL      - 289c70b based on jdk-11.0.2+9)

reporting this error

java.lang.UnsatisfiedLinkError: fontmanager (Not found in com.ibm.oti.vm.bootstrap.library.path)
        at java.base/java.lang.ClassLoader.loadLibraryWithPath(ClassLoader.java:1678)
        at java.base/java.lang.ClassLoader.loadLibraryWithClassLoader(ClassLoader.java:1643)
        at java.base/java.lang.System.loadLibrary(System.java:559)
        at java.desktop/sun.font.FontManagerNativeLibrary$1.run(FontManagerNativeLibrary.java:57)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:647)
        at java.desktop/sun.font.FontManagerNativeLibrary.<clinit>(FontManagerNativeLibrary.java:32)
        at java.desktop/sun.font.SunFontManager$1.run(SunFontManager.java:270)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:647)
        at java.desktop/sun.font.SunFontManager.<clinit>(SunFontManager.java:266)
        at java.desktop/sun.font.FontDesignMetrics.getMetrics(FontDesignMetrics.java:265)
        at java.desktop/sun.java2d.SunGraphics2D.getFontMetrics(SunGraphics2D.java:864)

Although I pointed them to this issue and asked them to setup the mentioned dependencies and environment variables this seems cumbersome (and may also prove "too difficult" for them to do :expressionless:).

So having an AdoptOpenJDK build which works "out-of-the-box" on an AIX system would definitely be desirable.

M-Davies commented 4 years ago

@sxa Just to follow up on this, I see that we are setting the LIBPATH here and we also set FREETYPE to bundled here. Is there anything else that needs to be done for this issue?

sxa commented 4 years ago

It would need to be tested first to ensure the problem no longer occurs.