kohlschutter / junixsocket

Unix Domain Sockets in Java 7 and newer (AF_UNIX), AF_TIPC, AF_VSOCK, and more
Apache License 2.0
433 stars 114 forks source link

libjunixsocket-native-{version}.so not generated on s390x. #62

Closed imdurgadas closed 4 years ago

imdurgadas commented 5 years ago

I tried building junixsocket-native:2.0.4 from source by adding s390x specific details in the aol.properties. With this the build succeeded but i could not find libjunixsocket-native-2.0.4.so in the /target/nar/junixsocket-native- /lib/ /jni path. Note: .so file is created in x86(amd64) arch.

@kohlschuetter Any idea on what is preventing the .so files from getting generated ?

aol.properties

s390x.Linux.gpp.c.options=-Wall -Wno-long-long -Wpointer-arith -Wconversion -m64 -march=s390x
s390x.Linux.gpp.cpp.options=-Wall -Wno-long-long -Wpointer-arith -Wconversion -m64 -march=s390x
s390x.Linux.gpp.linker.options=-shared -shared-libgcc -fPIC -fexceptions -m64 -march=s390x
s390x.Linux.linker=gcc

Traces:

[INFO] ------------------------------------------------------------------------
[INFO] Building junixsocket-native 2.0.4
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) @ junixsocket-native ---
[INFO] Deleting /home/durgadas/installer-build/junixsocket/junixsocket-native/target
[INFO]
[INFO] --- nar-maven-plugin:3.2.0:nar-validate (default-nar-validate) @ junixsocket-native ---
[INFO] Using AOL: s390x-Linux-gcc
[INFO]
[INFO] --- nar-maven-plugin:3.2.0:nar-download (default-nar-download) @ junixsocket-native ---
[INFO] Preparing Nar dependencies
[INFO] Unpacking 0 dependencies to /home/durgadas/installer-build/junixsocket/junixsocket-native/target/nar
[INFO]
[INFO] --- nar-maven-plugin:3.2.0:nar-unpack (default-nar-unpack) @ junixsocket-native ---
[INFO] Unpacking 0 dependencies to /home/durgadas/installer-build/junixsocket/junixsocket-native/target/nar
[INFO]
[INFO] --- nar-maven-plugin:3.2.0:nar-gnu-configure (default-nar-gnu-configure) @ junixsocket-native ---
[INFO]
[INFO] --- nar-maven-plugin:3.2.0:nar-system-generate (default-nar-system-generate) @ junixsocket-native ---
[INFO] Generating /home/durgadas/installer-build/junixsocket/junixsocket-native/target/nar/nar-generated/org/newsclub/net/unix/NarSystem.java
[INFO] Using 'native-lib-loader'
[INFO]
[INFO] --- maven-dependency-plugin:2.9:unpack (unpack-coding-style) @ junixsocket-native ---
[INFO] Configured Artifact: com.kohlschutter:coding-style:files:1.0.1:zip
[INFO] Unpacking /root/.m2/repository/com/kohlschutter/coding-style/1.0.1/coding-style-1.0.1-files.zip to /home/durgadas/installer-build/junixsocket with includes "" and excludes ""
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ junixsocket-native ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/durgadas/installer-build/junixsocket/junixsocket-native/src/main/resources
[INFO]
[INFO] --- nar-maven-plugin:3.2.0:nar-resources (default-nar-resources) @ junixsocket-native ---
[INFO] Copied 0 resources
[INFO]
[INFO] --- nar-maven-plugin:3.2.0:nar-gnu-resources (default-nar-gnu-resources) @ junixsocket-native ---
[INFO]
[INFO] --- nar-maven-plugin:3.2.0:nar-vcproj (default-nar-vcproj) @ junixsocket-native ---
[INFO]
[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ junixsocket-native ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/durgadas/installer-build/junixsocket/junixsocket-native/target/classes
[INFO]
[INFO] --- nar-maven-plugin:3.2.0:nar-javah (default-nar-javah) @ junixsocket-native ---
[INFO] Running /usr/lib/jvm/java-8-openjdk-s390x/bin/javah compiler on 1 classes...
[INFO] + /usr/lib/jvm/java-8-openjdk-s390x/bin/javah -classpath /home/durgadas/installer-build/junixsocket/junixsocket-native/target/classes:/root/.m2/repository/org/scijava/native-lib-loader/2.0.2/native-lib-loader-2.0.2.jar:/root/.m2/repository/log4j/log4j/1.2.17/log4j-1.2.17.jar -d /home/durgadas/installer-build/junixsocket/junixsocket-native/target/nar/javah-include org.newsclub.net.unix.NarSystem
[ERROR] Picked up _JAVA_OPTIONS: -Xmx10g
[INFO]
[INFO] --- nar-maven-plugin:3.2.0:nar-gnu-make (default-nar-gnu-make) @ junixsocket-native ---
[INFO]
[INFO] --- nar-maven-plugin:3.2.0:nar-compile (default-nar-compile) @ junixsocket-native ---
[INFO] Preparing Nar dependencies
[INFO] Unpacking 0 dependencies to /home/durgadas/installer-build/junixsocket/junixsocket-native/target/nar
[INFO] Nothing to compile
[INFO]
[INFO] --- nar-maven-plugin:3.2.0:nar-gnu-process (default-nar-gnu-process) @ junixsocket-native ---
[INFO]
[INFO] --- nar-maven-plugin:3.2.0:nar-process-libraries (default-nar-process-libraries) @ junixsocket-native ---
[info] Running process libraries
[info] Processing library Library: type: jni
[INFO]
[INFO] --- nar-maven-plugin:3.2.0:nar-prepare-package (default-nar-prepare-package-1) @ junixsocket-native ---
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ junixsocket-native ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/durgadas/installer-build/junixsocket/junixsocket-native/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.2:testCompile (default-testCompile) @ junixsocket-native ---
[INFO] No sources to compile
[INFO]
[INFO] --- nar-maven-plugin:3.2.0:nar-testCompile (default-nar-testCompile) @ junixsocket-native ---
[INFO] Preparing Nar dependencies
[INFO] Unpacking 0 dependencies to /home/durgadas/installer-build/junixsocket/junixsocket-native/target/test-nar
[INFO] Unpacking 0 dependencies to /home/durgadas/installer-build/junixsocket/junixsocket-native/target/test-nar
[INFO]
[INFO] --- maven-surefire-plugin:2.18:test (default-test) @ junixsocket-native ---
[INFO] No tests to run.
[INFO]
[INFO] --- nar-maven-plugin:3.2.0:nar-test (default-nar-test) @ junixsocket-native ---
[INFO] Preparing Nar dependencies
[INFO] Unpacking 0 dependencies to /home/durgadas/installer-build/junixsocket/junixsocket-native/target/test-nar
[INFO]
[INFO] --- nar-maven-plugin:3.2.0:nar-prepare-package (default-nar-prepare-package) @ junixsocket-native ---
[INFO]
[INFO] --- maven-antrun-plugin:1.7:run (fix-jnilib) @ junixsocket-native ---
[INFO] Executing tasks

main:
[INFO] Executed tasks
[INFO]
[INFO] --- nar-maven-plugin:3.2.0:nar-package (default-nar-package) @ junixsocket-native ---
[INFO]
[INFO] --- maven-jar-plugin:2.5:jar (default-jar) @ junixsocket-native ---
[INFO] Building jar: /home/durgadas/installer-build/junixsocket/junixsocket-native/target/junixsocket-native-2.0.4.jar
[INFO]
[INFO] --- maven-source-plugin:2.4:jar-no-fork (attach-sources) @ junixsocket-native ---
[INFO] Building jar: /home/durgadas/installer-build/junixsocket/junixsocket-native/target/junixsocket-native-2.0.4-sources.jar
[INFO]
[INFO] --- maven-javadoc-plugin:2.10.1:jar (attach-javadocs) @ junixsocket-native ---
[INFO]
Loading source files for package org.newsclub.net.unix...
Constructing Javadoc information...
Standard Doclet version 1.8.0_191
Building tree for all the packages and classes...
Generating /home/durgadas/installer-build/junixsocket/junixsocket-native/target/apidocs/org/newsclub/net/unix/NarSystem.html...
Generating /home/durgadas/installer-build/junixsocket/junixsocket-native/target/apidocs/org/newsclub/net/unix/package-frame.html...
Generating /home/durgadas/installer-build/junixsocket/junixsocket-native/target/apidocs/org/newsclub/net/unix/package-summary.html...
Generating /home/durgadas/installer-build/junixsocket/junixsocket-native/target/apidocs/org/newsclub/net/unix/package-tree.html...
Generating /home/durgadas/installer-build/junixsocket/junixsocket-native/target/apidocs/constant-values.html...
Generating /home/durgadas/installer-build/junixsocket/junixsocket-native/target/apidocs/org/newsclub/net/unix/class-use/NarSystem.html...
Generating /home/durgadas/installer-build/junixsocket/junixsocket-native/target/apidocs/org/newsclub/net/unix/package-use.html...
Building index for all the packages and classes...
Generating /home/durgadas/installer-build/junixsocket/junixsocket-native/target/apidocs/overview-tree.html...
Generating /home/durgadas/installer-build/junixsocket/junixsocket-native/target/apidocs/index-all.html...
Generating /home/durgadas/installer-build/junixsocket/junixsocket-native/target/apidocs/deprecated-list.html...
Building index for all classes...
Generating /home/durgadas/installer-build/junixsocket/junixsocket-native/target/apidocs/allclasses-frame.html...
Generating /home/durgadas/installer-build/junixsocket/junixsocket-native/target/apidocs/allclasses-noframe.html...
Generating /home/durgadas/installer-build/junixsocket/junixsocket-native/target/apidocs/index.html...
Generating /home/durgadas/installer-build/junixsocket/junixsocket-native/target/apidocs/help-doc.html...
1 warning
[WARNING] Javadoc Warnings
[WARNING] Picked up _JAVA_OPTIONS: -Xmx10g
[WARNING] /home/durgadas/installer-build/junixsocket/junixsocket-native/target/nar/nar-generated/org/newsclub/net/unix/NarSystem.java:26: warning - Tag @author cannot be used in method documentation.  It can only be used in the following types of documentation: overview, package, class/interface.
[INFO] Building jar: /home/durgadas/installer-build/junixsocket/junixsocket-native/target/junixsocket-native-2.0.4-javadoc.jar
[INFO]
[INFO] --- nar-maven-plugin:3.2.0:nar-integration-test (default-nar-integration-test) @ junixsocket-native ---
[INFO] No tests to run.
[INFO]
[INFO] --- license-maven-plugin:2.6:check (default) @ junixsocket-native ---
[INFO] Checking licenses...
[INFO]
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ junixsocket-native ---
[INFO] Installing /home/durgadas/installer-build/junixsocket/junixsocket-native/target/junixsocket-native-2.0.4.jar to /root/.m2/repository/com/kohlschutter/junixsocket/junixsocket-native/2.0.4/junixsocket-native-2.0.4.nar
[INFO] Installing /home/durgadas/installer-build/junixsocket/junixsocket-native/pom.xml to /root/.m2/repository/com/kohlschutter/junixsocket/junixsocket-native/2.0.4/junixsocket-native-2.0.4.pom
[INFO] Installing /home/durgadas/installer-build/junixsocket/junixsocket-native/target/junixsocket-native-2.0.4-sources.jar to /root/.m2/repository/com/kohlschutter/junixsocket/junixsocket-native/2.0.4/junixsocket-native-2.0.4-sources.jar
[INFO] Installing /home/durgadas/installer-build/junixsocket/junixsocket-native/target/junixsocket-native-2.0.4-javadoc.jar to /root/.m2/repository/com/kohlschutter/junixsocket/junixsocket-native/2.0.4/junixsocket-native-2.0.4-javadoc.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:27 min
[INFO] Finished at: 2019-03-26T13:16:18+00:00
[INFO] Final Memory: 34M/83M
[INFO] ------------------------------------------------------------------------

CMD: root@d704538f7c93:/home/durgadas/installer-build/junixsocket/junixsocket-native# ls target/nar/ Result : javah-include/ nar-generated/

sriemer commented 5 years ago

Have you also hit any issues described in #63?

I think the junixsocket-native compilation is for Linux/macOS x86_64 only. The supported method should be using cross compilation with clang. I'm working on s390x support myself as well but with the clang cross compile method instead.

sriemer commented 5 years ago

I also had no luck with the clang cross compilation method. Linking fails due to missing elf64_s390 emulation in llvm. See: https://github.com/llvm/llvm-project/blob/cce47418c93bcd178379fa8c4df5c3327bc19802/lld/ELF/Driver.cpp#L125. Only little-endian architectures are supported.

sriemer commented 5 years ago

I have a LinuxONE Community Cloud z/VM 6.4 guest running on the mainframe of Marist College (see: https://developer.ibm.com/linuxone/). I chose SLES12-SP3 but llvm with clang is not supported/available. So I branched llvm 3.8.0 intended for SLES12-SP3 in OBS: https://build.opensuse.org/project/show/home:spars_instana:sle12sp3-llvm3.8 and installed it from there.

I've prepared two patches to compile junixsocket with clang on that s390x machine: https://github.com/sriemer/junixsocket/commits/s390x

It compiles fine with IBM Java 8, clang, llvm, and

mvn clean install -Dmaven.javadoc.skip=true -Dpmd.skip=true

now. The only disadvantage is that I cannot run the tests as those also require at least Java 9.

But I get:

./junixsocket-native/target/nar/junixsocket-native-2.2.1-SNAPSHOT-s390x-Linux-clang-jni/lib/s390x-Linux-clang/jni/libjunixsocket-native-2.2.1-SNAPSHOT.so

and build success. I guess this is the best we can get for now.

@imdurgadas Can you please test if this works for you as well? TIA

sriemer commented 5 years ago

@kohlschuetter Do you maybe have other ideas how to include s390x in the official build? Can we maybe just let it pick up the libraries which were natively built with clang on IBM LinuxONE Community Cloud? Can you please look at my patches? TIA

sriemer commented 5 years ago

The demo app is running with my s390x build and this has been confirmed working in customer environment by the way.

imdurgadas commented 5 years ago

@sriemer yup, steps you mentioned worked for me as well.


junixsocket/junixsocket-native/target/nar/junixsocket-native-2.2.1-SNAPSHOT-s390x-Linux-clang-jni/lib/s390x-Linux-clang/jni# ls
history.xml  libjunixsocket-native-2.2.1-SNAPSHOT.so
nealef commented 5 years ago

Would you like to add a s390x Jenkins slave so you can build this regularly? I have a server where you can build things natively so I assume that means you could use gcc as well as clang. This is also on the LinuxONE system but it's not subject to their 180 day limit. I use it to build a number of FOSS projects.

The builder uses the AdoptJDK rather than the rpm. The former has a JIT whereas the latter is still running in interpreter mode.

I'm trying to get it to build as part of Zimbra FOSS but I can't seem to get the jni portion built - no errors it just doesn't even try so I will try and build it standalone to see what I'm missing in Zimbra (which knows nothing about s390x).

sriemer commented 5 years ago

@nealef That would be perfect. My branch https://github.com/sriemer/junixsocket/commits/s390x also builds with java-1_8_0-openjdk-devel, maven 3.6.1, and llvm 3.8.0 from https://build.opensuse.org/project/show/home:spars_instana:sle12sp3-llvm3.8 on SLES12-SP3 s390x. Build command: mvn clean install -Dmaven.javadoc.skip=true -Dpmd.skip=true

clang has its advantages over gcc for portable builds. So the mainline build should always use clang. The junixsocket-native compile is not prepared for using a different linker than clang. Even the Windows build uses clang together with mingw-gcc. In junixsocket-native/crossclang/bin/, thegcc file is a symlink to clang.

nealef commented 5 years ago

I have two Jenkins slaves you can plug into: one running SLES15 and the other running a CentOS 7.6.1810 clone. I think the latter may be problematic as maven is lower than the level you specify - even the software collection is only at 3.5. LLVM is at the right level on both systems. Let me know how you want to proceed and I'll set things up.

sriemer commented 5 years ago

SLES15 sounds nice to me but actually only because I worked at SUSE before. :wink: Thanks! To apply my 2..4 patches for s390x on top, a git fetch upstream && git rebase upstream/master would be required, once a new master commit is available.

Still waiting how @kohlschuetter wants to integrate the s390x build. I'm a C developer and no Java/Maven expert. I think @kohlschuetter is the only person with all cross clang target-sdks installed. At Instana, we just extract (jar -xf ...) the lib/junixsocket-native-common-XXX.jar in the junixsocket-dist archive, add the s390x-Linux-clang/ directory to lib/ and compress (jar -cf ...) this again. Got no clue how to automate that in the release build @kohlschuetter is using.

nealef commented 5 years ago

Actually, rh-maven35 will be fine. It only seems to need maven >= 3.1.1 and llvm 3.4.2 so building on my CentOS clone works.

kohlschuetter commented 4 years ago

Fixed, please verify on junixsocket 2.3.0. Thanks!