Skip to content

Latest commit

 

History

History
142 lines (124 loc) · 6.69 KB

netty-tcnative-25-36移植文档.mkd

File metadata and controls

142 lines (124 loc) · 6.69 KB

netty-tcnative

netty-tcnative构建指导
构建版本:netty-tcnative-parent-2.0.25/36.Final

???+ note * 本文假设网络通畅,如遇网络问题请自行解决

项目信息

名称 描述
名称 netty-tcnative
版本 2.0.25.Final
项目地址 https://github.com/netty/netty-tcnative
官方指导 https://github.com/netty/netty-tcnative/blob/netty-tcnative-parent-2.0.25.Final/README.md

环境信息

c# 系统信息
[root@bdfffb2fc3db lib]#   cat /etc/os-release 
NAME="Loongnix-Server Linux"
VERSION="8"
ID="loongnix-server"
ID_LIKE="rhel fedora centos"
VERSION_ID="8"
PLATFORM_ID="platform:lns8"
PRETTY_NAME="Loongnix-Server Linux 8"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:loongnix-server:loongnix-server:8"
HOME_URL="http://www.loongnix.cn/"
BUG_REPORT_URL="http://bugs.loongnix.cn/"
CENTOS_MANTISBT_PROJECT="Loongnix-server-8"
CENTOS_MANTISBT_PROJECT_VERSION="8"

# 内核信息
[root@bdfffb2fc3db lib]# uname -r
4.19.0-19-loongson-3

移植步骤

编译环境和依赖

2.0.25、2.0.36需要软件包:apr-dev libssl-dev cmake ninja-build libunwind-dev golang-1.19-go
apr的编译构建过程:
- 安装apr apr[官方下载地址](http://apr.apache.org/download.cgi)
wget http://mirrors.cnnic.cn/apache/apr/apr-x.x.x.tar.gz
tar zxvf apr-1.4.8.tar.gz
cd apr-1.4.8
./configure --prefix=/usr/local/apr
make & make install
```
  • 安装apr-util
       wget http://mirrors.cnnic.cn/apache/apr/apr-util-1.x.x.tar.gz
    tar zxvf apr-util-1.5.2.tar.gz
    cd apr-util-1.5.2
    ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
    make & make install
    
  • 在构建其他项目使用apr时指定apr路径 ./configure --prefix=/usr/local/subversion --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util

源码修改

需要注意的是2.0.25修改遵循2.0.26文档,2.0.36修改时需要删除或注释掉: 2.0.36还需要进行的操作是在构建时创建boringssl-static、openssl-static、libressl-static的target目录,下载apr1.7.0的tar包并解压构建,构建过程上面已经给出

(1)boringssl-static/pom.xml

diff --git a/boringssl-static/pom.xml b/boringssl-static/pom.xml
index cc40c74..e91b434 100644
--- a/boringssl-static/pom.xml
+++ b/boringssl-static/pom.xml
@@ -79,7 +79,7 @@
                 <configuration>
                   <checkoutDirectory>${boringsslCheckoutDir}</checkoutDirectory>
                   <connectionType>developerConnection</connectionType>
-                  <developerConnectionUrl>scm:git:https://boringssl.googlesource.com/boringssl</developerConnectionUrl>
+                  <developerConnectionUrl>scm:git:https://github.com/Loongson-Cloud-Community/boringssl</developerConnectionUrl>
                   <scmVersion>${boringsslBranch}</scmVersion>
                   <scmVersionType>branch</scmVersionType>
                   <skipCheckoutIfExists>true</skipCheckoutIfExists>

(2) pom.xml

diff --git a/pom.xml b/pom.xml
index 2619560..18d3d01 100644
--- a/pom.xml
+++ b/pom.xml
@@ -90,7 +90,7 @@
       <extension>
         <groupId>kr.motd.maven</groupId>
         <artifactId>os-maven-plugin</artifactId>
-        <version>1.6.2</version>
+        <version>1.7.1</version>
       </extension>
     </extensions>
 
@@ -467,8 +467,8 @@
 
                         <property name="aprTarGzFile" value="apr-${aprVersion}.tar.gz" />
                         <property name="aprTarFile" value="apr-${aprVersion}.tar" />
-                        <get src="http://archive.apache.org/dist/apr/${aprTarGzFile}" dest="${project.build.directory}/${aprTarGzFile}" verbose="on" />
-                        <checksum file="${project.build.directory}/${aprTarGzFile}" algorithm="SHA-256" property="${aprSha256}" verifyProperty="isEqual" />
+                        <get src="https://github.com/Loongson-Cloud-Community/netty-tcnative/releases/download/netty-tcnative-parent-2.0.26.Final/la64-apr-1.6.5.tar.gz" dest="${project.build.directory}/${aprTarGzFile}" verbose="on" />
+                          <!-- <checksum file="${project.build.directory}/${aprTarGzFile}" algorithm="SHA-256" property="${aprSha256}" verifyProperty="isEqual" /> -->
                         <gunzip src="${project.build.directory}/${aprTarGzFile}" dest="${project.build.directory}" />
                         <!-- Use the tar command (rather than the untar ant task) in order to preserve file permissions. -->
                         <exec executable="tar" failonerror="true" dir="${project.build.directory}/" resolveexecutable="true">

编译

./mvnw install

说明 netty-tcnative-{os-arch}:动态连接到libapr-1和openssl,要使用该组件,系统必须同事安装和配置libapr-1和openssl,该组件管理员可以自由升级openssl而无需重新编译应用。
netty-tcnative-boringssl-static-{os-arch}: 静态链接到谷歌的boringssl,是openssl的一个分支,具有附加功能,静态链接使得在系统上使用tcnative变得更容易,该库不需要apr。 netty-tcnative-boringssl-static: 其中包含了所有受支持的netty-tcnative-boringssl-static-{os-arch},不需要关心平台架构。 netty-tcnative-openssl-static-{os-arch}: 静态链接到libapr-1和openssl

(1)若出现以下问题类似的是由于网络原因造成的:

     [echo] Downloading and unpacking APR
      [get] Getting: https://github.com/Loongson-Cloud-Community/netty-tcnative/releases/download/netty-tcnative-parent-2.0.26.Final/la64-apr-1.6.5.tar.gz
      [get] To: /home/zhaixiaojuan/workspace/netty-tcnative-test/libressl-static/target/apr-1.6.5.tar.gz
      [get] Error getting https://github.com/Loongson-Cloud-Community/netty-tcnative/releases/download/netty-tcnative-parent-2.0.26.Final/la64-apr-1.6.5.tar.gz to /home/zhaixiaojuan/workspace/netty-tcnative-test/libressl-static/target/apr-1.6.5.tar.gz

可以手动下载apr-1.6.5.tar.gz,然后将其复制到/xxxssl-static/target/apr-1.6.5.tar.gz并对其进行解压

(2) 以下两个连接是适配LA架构的,可直接下载使用(即可省略上面步骤”3源码修改“的内容)
https://github.com/Loongson-Cloud-Community/netty-tcnative/tree/loong64-netty-tcnative-parent-2.0.26.Final
https://github.com/Loongson-Cloud-Community/netty-tcnative/tree/loong64-netty-tcnative-parent-2.0.29.Final