From 660611c4507def91ffd6bf13f294e21826b584a5 Mon Sep 17 00:00:00 2001 From: wangxiyuan Date: Thu, 23 Apr 2020 19:58:08 +0800 Subject: [PATCH] Add epoll aarch64 maven config and Dockerfile (#9804) Motivation: `transport-native-epoll` doesn't have ARM release package. Modification: This PR added cross compile profile for epoll. Then we can easily build aarch64 package on X86 machine. Result: Fixes #8279 --- all/pom.xml | 16 +++ docker/Dockerfile.cross_compile_aarch64 | 18 +++ docker/README.md | 7 ++ docker/docker-compose.yaml | 20 ++++ transport-native-epoll/pom.xml | 148 ++++++++++++++++++++++++ transport-native-unix-common/pom.xml | 65 +++++++++++ 6 files changed, 274 insertions(+) create mode 100644 docker/Dockerfile.cross_compile_aarch64 diff --git a/all/pom.xml b/all/pom.xml index 1fc0343a5c..21b92bfd29 100644 --- a/all/pom.xml +++ b/all/pom.xml @@ -57,6 +57,14 @@ compile true + + ${project.groupId} + netty-transport-native-epoll + ${project.version} + linux-aarch_64 + compile + true + ${project.groupId} netty-transport-native-kqueue @@ -89,6 +97,14 @@ compile true + + ${project.groupId} + netty-transport-native-epoll + ${project.version} + linux-aarch_64 + compile + true + ${project.groupId} netty-transport-native-kqueue diff --git a/docker/Dockerfile.cross_compile_aarch64 b/docker/Dockerfile.cross_compile_aarch64 new file mode 100644 index 0000000000..077e46262a --- /dev/null +++ b/docker/Dockerfile.cross_compile_aarch64 @@ -0,0 +1,18 @@ +FROM centos:7.6.1810 + +ARG gcc_version=4.9-2016.02 +ENV GCC_VERSION $gcc_version + +# Install requirements +RUN yum install -y wget tar git make redhat-lsb-core autoconf automake libtool glibc-devel libaio-devel openssl-devel apr-devel lksctp-tools + +# Install Java +RUN yum install -y java-1.8.0-openjdk-devel + +# Install aarch64 gcc toolchain +RUN set -x && \ + wget https://releases.linaro.org/components/toolchain/binaries/$GCC_VERSION/aarch64-linux-gnu/gcc-linaro-$GCC_VERSION-x86_64_aarch64-linux-gnu.tar.xz && \ + tar xvf gcc-linaro-$GCC_VERSION-x86_64_aarch64-linux-gnu.tar.xz + +ENV PATH="/gcc-linaro-$GCC_VERSION-x86_64_aarch64-linux-gnu/bin:${PATH}" +ENV JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk/" diff --git a/docker/README.md b/docker/README.md index d96242b321..378c673c84 100644 --- a/docker/README.md +++ b/docker/README.md @@ -16,4 +16,11 @@ docker-compose -f docker/docker-compose.yaml -f docker/docker-compose.centos-6.1 docker-compose -f docker/docker-compose.yaml -f docker/docker-compose.centos-7.111.yaml run test ``` +## aarch64 cross compile for transport-native-epoll on X86_64 + +``` +docker-compose -f docker/docker-compose.yaml run cross-compile-aarch64 +``` +The default version of aarch64 gcc is `4.9-2016.02`. Update the parameter `gcc_version` in `docker-compose.yaml` to use a version you want. + etc, etc diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index 5d9ec200ae..f56cb53aaa 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -40,3 +40,23 @@ services: - ..:/code:delegated - ~/.m2:/root/.m2:delegated entrypoint: /bin/bash + + cross-compile-aarch64-runtime-setup: + image: netty:cross_compile_aarch64 + build: + context: . + dockerfile: Dockerfile.cross_compile_aarch64 + args: + gcc_version : "4.9-2016.02" + + cross-compile-aarch64: + image: netty:cross_compile_aarch64 + depends_on: [cross-compile-aarch64-runtime-setup] + volumes: + - ~/.ssh:/root/.ssh:delegated + - ~/.gnupg:/root/.gnupg:delegated + - ..:/code:delegated + - ~/.m2:/root/.m2:delegated + # Since we are cross compiling netty-transport-native-epoll as aarch64 which cannot be loaded on x86_64, we add `skipTests` here to skip the test. + command: /bin/bash -cl "pushd ./transport-native-unix-common && ../mvnw clean install -Plinux-aarch64 && popd && pushd ./transport-native-epoll && ../mvnw clean install -Plinux-aarch64 -DskipTests && popd" + working_dir: /code diff --git a/transport-native-epoll/pom.xml b/transport-native-epoll/pom.xml index d23e032ed8..8a6554aaaf 100644 --- a/transport-native-epoll/pom.xml +++ b/transport-native-epoll/pom.xml @@ -196,6 +196,154 @@ + + + io.netty + netty-transport-native-unix-common + ${project.version} + ${jni.classifier} + + true + + + + + linux-aarch64 + + ${os.detected.name}-aarch64 + + + + + + maven-enforcer-plugin + 1.4.1 + + + + com.ceilfors.maven.plugin + enforcer-rules + 1.2.0 + + + + + + + + maven-enforcer-plugin + + + enforce-release-environment + + enforce + + + + + + Cross compile and Release process must be performed on linux-x86_64. + + os.detected.classifier + ^linux-x86_64.* + + + + Cross compile and Release process must be performed on RHEL 7.6 or its derivatives. + + + /etc/redhat-release + + release 7.6 + + + + + + + + maven-dependency-plugin + + + + unpack + generate-sources + + unpack-dependencies + + + ${project.groupId} + netty-transport-native-unix-common + ${jni.classifier} + ${unix.common.lib.dir} + META-INF/native/** + false + true + + + + + + + org.fusesource.hawtjni + maven-hawtjni-plugin + + + build-native-lib + + netty_transport_native_epoll_aarch_64 + ${nativeSourceDirectory} + ${project.build.outputDirectory} + + . + + ${jni.compiler.args.ldflags} + ${jni.compiler.args.cflags} + --libdir=${project.build.directory}/native-build/target/lib + --host=aarch64-linux-gnu + + + + generate + build + + + + + + maven-jar-plugin + + + + native-jar + + jar + + + + + true + + + META-INF/native/libnetty_transport_native_epoll_aarch_64.so; osname=Linux; processor=aarch_64,* + ${javaModuleName} + + true + ${project.build.outputDirectory}/META-INF/MANIFEST.MF + + ${jni.classifier} + + + + + + + io.netty diff --git a/transport-native-unix-common/pom.xml b/transport-native-unix-common/pom.xml index 75f20982df..d6ad19cebd 100644 --- a/transport-native-unix-common/pom.xml +++ b/transport-native-unix-common/pom.xml @@ -207,6 +207,71 @@ + + linux-aarch64 + + ${os.detected.name}-aarch64 + linux + aarch64-linux-gnu-gcc + aarch64-linux-gnu-ar + + + + + maven-antrun-plugin + + + + native-jar + package + + run + + + + + + + + + + + + + + + + + + + + + + build-native-lib + generate-sources + + run + + + + + + + + + + + + + + + + + + + + + freebsd