hyperxpro / Brotli4j

Brotli4j provides Brotli compression and decompression for Java.
Apache License 2.0
102 stars 35 forks source link

Not able to load brotli native library on ppc64le architecture #115

Closed Balavva-Mirji closed 10 months ago

Balavva-Mirji commented 10 months ago

Hello, we are trying to provide ppc64le support for this repo. We are getting below error while testing it on ppc64le.

To Reproduce Steps to reproduce the behavior:

  1. Go to 'https://github.com/Balavva-Mirji/Brotli4j/tree/ppc64le'
  2. Install required dependencies like java & maven
  3. mvn clean package
  4. See the error: Brotli4jLoaderTest.load:29 Unexpected exception thrown: java.lang.UnsatisfiedLinkError: Failed to load Brotli native library

Note: After building brotli native library on ppc64le, we have set LD_LIBRARY_PATH.

Expected behavior It should not thrown the above error which I mentioned as we built brotli native on ppc64le.

Logs

[ERROR] com.aayushatharva.brotli4j.decoder.BrotliInputStreamTest Time elapsed: 0.03 s <<< ERROR! java.lang.UnsatisfiedLinkError: Failed to load Brotli native library at com.aayushatharva.brotli4j.Brotli4jLoader.ensureAvailability(Brotli4jLoader.java:109) at com.aayushatharva.brotli4j.decoder.BrotliInputStreamTest.load(BrotliInputStreamTest.java:35) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) Caused by: java.lang.UnsupportedOperationException: Unsupported OS and Architecture: Linux, ppc64le at com.aayushatharva.brotli4j.Brotli4jLoader.getPlatform(Brotli4jLoader.java:146) at com.aayushatharva.brotli4j.Brotli4jLoader.(Brotli4jLoader.java:53) ... 3 more [INFO] Running com.aayushatharva.brotli4j.decoder.DecoderTest [ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.002 s <<< FAILURE! - in com.aayushatharva.brotli4j.decoder.DecoderTest [ERROR] com.aayushatharva.brotli4j.decoder.DecoderTest Time elapsed: 0.002 s <<< ERROR! java.lang.UnsatisfiedLinkError: Failed to load Brotli native library at com.aayushatharva.brotli4j.Brotli4jLoader.ensureAvailability(Brotli4jLoader.java:109) at com.aayushatharva.brotli4j.decoder.DecoderTest.load(DecoderTest.java:35) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) Caused by: java.lang.UnsupportedOperationException: Unsupported OS and Architecture: Linux, ppc64le at com.aayushatharva.brotli4j.Brotli4jLoader.getPlatform(Brotli4jLoader.java:146) at com.aayushatharva.brotli4j.Brotli4jLoader.(Brotli4jLoader.java:53) at com.aayushatharva.brotli4j.decoder.BrotliInputStreamTest.load(BrotliInputStreamTest.java:35) ... 2 more

Platform (please complete the following information):

Additional context We have replicated this PR changes on ppc64le local machine.

Kindly let me know if I am missing anything here or if you need any other information on this, I am exploring further on this. Any suggestions/comments are highly appreciated. Thanks in advance!

Balavva-Mirji commented 10 months ago

Native library is able to build locally:

file libbrotli.so libbrotli.so: ELF 64-bit LSB shared object, 64-bit PowerPC or cisco 7500, version 1 (SYSV), dynamically linked, BuildID[sha1]=8492ac089bfeacce07e548ac68bd3a82f8238447, not stripped

hyperxpro commented 10 months ago

Most likely this is due to wrong architecture name. Try to print the os.arch value and see.

hyperxpro commented 10 months ago

Do a PR so I can see the build logs.

Balavva-Mirji commented 10 months ago

Most likely this is due to wrong architecture name. Try to print the os.arch value and see.

it's ppc64le

Balavva-Mirji commented 10 months ago

@hyperxpro Thanks for pointing it out. It' working fine now. Will come up with PR.

hyperxpro commented 10 months ago

Perfect! Sorry, I forgot to follow up since I was on vacation. Looking forward to your PR. :)

Balavva-Mirji commented 10 months ago

@hyperxpro I need a assistance from you before raising the PR. Like do we need to provide any ppc64le machine? Could you please confirm on this..

hyperxpro commented 10 months ago

https://github.com/hyperxpro/Brotli4j/pull/102

Check this. You need to provide CI build, native module directory and add new architecture type in main module to auto load.

Balavva-Mirji commented 10 months ago

@hyperxpro thanks for the reply. I have gone through above PR. Made the changes on my forked repo. Reference: https://github.com/Balavva-Mirji/Brotli4j/commit/bbcc352ba5b6ea556693766118086f27f072d76f And it works perfectly on ppc64le local machine. Just curious on which machine s390x native builds are running? Because in the above PR, I don't see any VM providing which is specific to s390x.

hyperxpro commented 10 months ago

You need to add it to CI like this:

https://github.com/hyperxpro/Brotli4j/blob/e37831bdc7ff12244561df4d9e984293b71a93e5/.github/workflows/maven.yml#L350

Balavva-Mirji commented 10 months ago

@hyperxpro can we connect on this? if you have sometime

hyperxpro commented 10 months ago

Sure, hit me on Discord: hyperx_pro

Balavva-Mirji commented 10 months ago

I am sorry, didn't get you

hyperxpro commented 10 months ago

Mhmm, are you looking to DM for help? If yes then Discord.

Balavva-Mirji commented 10 months ago

Yes, I got that. Not getting that Discord thing

hyperxpro commented 10 months ago

Looks like you're not familiar with Discord 😅

Nvm, Just do a PR with whatever you have and I will take care of CI builds.