Re: JNA on PPC32/PPC64 AIX6.1: port complete

159 views
Skip to first unread message

ChenNam

unread,
Mar 8, 2012, 8:13:52 AM3/8/12
to Java Native Access
Hi Tim,

You are right. All my test failures for PPC32/PPC64 AIX are due to
libffi failure.
After two weeks' struggle, I managed to find out the bug in
aix_closure.S, and the original author has posted a fix for it. (see
libffi discussion group)
Now libffi (3.0.10, 3.0.11) passes through all tests for PPC32/PPC64
AIX suit.

I ported the fix to libffi within your JNA/native, all JNA tests
passes with only one failure: DirectTest.testRegisterMethod(). This is
because the standard AIX libm.a is a static library. An alternative to
pass this test is to use GCC libmpc.so.2 for AIX. But since it is not
a standard library installed on AIX, I hesitate to change
Platform.MATH_LIBRARY_NAME to point to it.

Below is a summary of the changed files: (all with very minor
additions)

Index: native/dispatch.c
Index: native/dispatch.h
Index: native/libffi/src/powerpc/aix_closure.S
Index: native/libffi/src/powerpc/ffi_darwin.c
Index: native/Makefile
Index: src/com/sun/jna/NativeLibrary.java
Index: src/com/sun/jna/Platform.java
Index: src/com/sun/jna/Structure.java

All of them and the test logs are available for your validation for
integration.
How do you want me to pass them to you?


Timothy Wall

unread,
Mar 8, 2012, 10:34:33 AM3/8/12
to jna-...@googlegroups.com
Separate the patches into distinct fixes for each issue addressed and push them via github. The final patch should include the aix binary itself.

Don't worry about the registerMethod failure on libm; just make a note why the test isn't appropriate for AIX.

ChenNam

unread,
Mar 12, 2012, 9:57:52 AM3/12/12
to jna-...@googlegroups.com
Just push in the modifications, and sent you a pull request.
Here is the archive of the reports (build/report/*, build-d64/reports/*)
reports.rar

Pavel

unread,
Mar 14, 2012, 6:38:56 AM3/14/12
to jna-...@googlegroups.com
Hi!

Just tried your port.
 

I replaced the jar and receive now

 

java.lang.UnsatisfiedLinkError: Unable to load library 'RoadRunner':    0509-022 Cannot load module .

        0509-026 System error: A file or directory in the path name does not exist.

        at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:169)

        at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:242)

        at com.sun.jna.Library$Handler.<init>(Library.java:140)

        at com.sun.jna.Native.loadLibrary(Native.java:368)


Is it related to the issue that it searches for .a instead of .so?

ChenNam

unread,
Mar 14, 2012, 7:04:06 AM3/14/12
to jna-...@googlegroups.com
It looks like JNA cannot find your specified library.
Check the following:

- Is the library name correct ? (what is the acutal library name you try to load or register ?)
- Is the library on jna.library.path ?
- Is the library on LIBPATH ?

Pavel

unread,
Mar 14, 2012, 10:42:33 AM3/14/12
to jna-...@googlegroups.com
The library is in LIBPATH as "so".
It was loaded only after I copied so to .a library (in the same directory)

Sit Chen Nam

unread,
Mar 14, 2012, 10:48:26 AM3/14/12
to jna-...@googlegroups.com

By convention, AIX has its lib named as libxyz.a

So if your original lib name is libxyz.a, just specify “xyz” as lib name

If your original lib is something other than this convention, say RoadRunner.so

Then use “RoadRunner.so”  as lib name in your program

Pavel

unread,
May 1, 2012, 7:57:26 AM5/1/12
to jna-...@googlegroups.com
I'm building now on AIX using the last JNA version from github (not your port, but the major version - I see that you merged your changes).

And I receive 1 test failed:

Testcase: testRegisterMethods(com.sun.jna.DirectTest):      Caused an ERROR
    [junit] Unable to load library 'm':         0509-022 Cannot load module /usr/lib/libm.a.
    [junit]     0509-103   The module has an invalid magic number.
    [junit] java.lang.UnsatisfiedLinkError: Unable to load library 'm':         0509-022 Cannot load module /usr/lib/libm.a.
    [junit]     0509-103   The module has an invalid magic number.
    [junit]     at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:169)
    [junit]     at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:242)
    [junit]     at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:205)
    [junit]     at com.sun.jna.Native.register(Native.java:1033)
    [junit]     at com.sun.jna.DirectTest$MathLibrary.<clinit>(DirectTest.java:55)
    [junit]     at java.lang.J9VMInternals.initializeImpl(Native Method)
    [junit]     at java.lang.J9VMInternals.initialize(J9VMInternals.java:196)
    [junit]     at java.lang.Class.forNameImpl(Native Method)
    [junit]     at java.lang.Class.forName(Class.java:163)
    [junit]     at com.sun.jna.DirectTest.testRegisterMethods(DirectTest.java:139)

I checked that /usr/lib/libm.a exists:
file /usr/lib/libm.a 
/usr/lib/libm.a: archive (big format)


If I try to use this version I see that C methods of callback registrations were not called.


Thank you!

Timothy Wall

unread,
May 1, 2012, 9:54:04 AM5/1/12
to jna-...@googlegroups.com
This is a known issue, and is due to the fact that the stock AIX libm.a does not include a shared library.

If you can show that libm.a is already linked within the JVM and thus doesn't need to be dynamically loaded, I suppose we could revise the test for AIX so that "null" is used for loading the math library (i.e. load from current process instead), but otherwise it's not worth spending much time on that particular test.

Sit Chen Nam

unread,
May 2, 2012, 3:23:55 AM5/2/12
to jna-...@googlegroups.com

I think Tim has already answered on this mail.

Below is the remarks I wrote when submitted the AIX port for validation by Tim.

 

>The port has been made with GCC v4.6.2 on AIX 6.1 PowerPC.

>Both aix-ppc and aix-ppc64 have been generated.

 

>All JUNIT test runs successfully, except DirectTest.registerMethod(),

>because the standard /usr/libm.a is a static library.

>You can install GCC libmpc.so.2 for AIX, and use it instead of libm.a, if

>you want to run this test.

 

 

From: jna-...@googlegroups.com [mailto:jna-...@googlegroups.com] On Behalf Of Pavel
Sent: Tuesday, May 01, 2012 1:57 PM
To: jna-...@googlegroups.com
Subject: Re: JNA on PPC32/PPC64 AIX6.1: port complete

 

I'm building now on AIX using the last JNA version from github (not your port, but the major version - I see that you merged your changes).

Reply all
Reply to author
Forward
0 new messages