Skip to content

Building netty tcnative

aborkar-ibm edited this page Dec 16, 2021 · 51 revisions

Building netty-tcnative

ATTENTION: Please note that the verified version of this package is currently using an older version of log4j which has the security vulnerabilities. Please see here for more details.

Below versions of netty-tcnative are available in respective distributions at the time of creation of these build instructions:

  • SLES (15 SP2, 15 SP3) has 1.1.33

The instructions provided below specify the steps to build netty-tcnative v2.0.46 on Linux on IBM Z for following distributions:

  • RHEL (7.8, 7.9, 8.2, 8.4, 8.5)
  • SLES (12 SP5, 15 SP2, 15 SP3)
  • Ubuntu (18.04, 20.04, 21.04, 21.10)

General Notes:

  • When following the steps below please use a standard permission user unless otherwise specified

  • A directory /<source_root>/ will be referred to in these instructions, this is a temporary writable directory anywhere you'd like to place it

Step 1: Build using script

If you want to build netty-tcnative using manual steps, go to STEP 2.

Use the following commands to build netty-tcnative using the build script. Please make sure you have wget installed.

wget -q https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/netty-tcnative/2.0.46/build_netty.sh

# Build netty-tcnative
bash build_netty.sh [Provide -h to see a list of supported Java JDK variant]

If the build completes successfully, go to STEP 5. In case of error, check logs for more details or go to STEP 2 to follow manual build steps.

Step 2: Install dependencies

export SOURCE_ROOT=/<source_root>/
  • RHEL (7.8, 7.9)

    sudo subscription-manager repos --enable=rhel-7-server-for-system-z-rhscl-rpms
    sudo yum install -y perl devtoolset-7-gcc-c++ devtoolset-7-gcc openssl-devel apr-devel autoconf automake libtool make tar git wget golang
  • RHEL (8.2, 8.4, 8.5)

    sudo yum install -y ninja-build cmake perl gcc gcc-c++ libarchive openssl-devel apr-devel autoconf automake libtool make tar git wget maven golang
  • SLES 12 SP5

    sudo zypper install -y cmake perl libopenssl-devel libapr1-devel autoconf automake libtool make tar git wget gcc7 gcc7-c++
    sudo ln -sf /usr/bin/gcc-7 /usr/bin/gcc
    sudo ln -sf /usr/bin/g++-7 /usr/bin/g++
    sudo ln -sf /usr/bin/gcc /usr/bin/cc
  • SLES (15 SP2, 15 SP3)

    sudo zypper install -y awk ninja cmake perl libopenssl-devel apr-devel autoconf automake libtool make tar git wget gcc gcc-c++ gzip
  • Ubuntu (18.04, 20.04, 21.04, 21.10)

    sudo apt-get update
    sudo apt-get install -y ninja-build cmake perl golang libssl-dev libapr1-dev autoconf automake libtool make tar git wget maven curl
2.1) Install Java
  • With IBM Semeru Runtime (previously known as AdoptOpenJDK openj9).

    • Download and install IBM Semeru Runtime (Java 11) from here.
  • With Eclipse Adoptium Temurin Runtime (previously known as AdoptOpenJDK hotspot)

    • Download and install Eclipse Adoptium Temurin Runtime (Java 11) from here.
  • With OpenJDK 11

    • RHEL (7.8, 7.9, 8.2, 8.4, 8.5)
      sudo yum install -y java-11-openjdk-devel
    • SLES (12 SP5, 15 SP2, 15 SP3)
      sudo zypper install -y java-11-openjdk java-11-openjdk-devel
    • Ubuntu (18.04, 20.04, 21.04, 21.10)
      sudo apt-get install -y openjdk-11-jdk

Note: Version jdk-11.0.13+8 was used for Eclipse Adoptium Temurin Runtime & IBM Semeru Runtime while verifying these instructions.

2.2) Set JAVA_HOME
 export JAVA_HOME=/<path to java>/
 export PATH=$JAVA_HOME/bin:$PATH
2.3) Enable Software Collections: (Only for RHEL 7.x)

netty requires GCC 7. It is available on RHEL 7.x via the 'Software Collections' packaging system. You can find out more about Software Collections here: https://www.softwarecollections.org/en/.

Following command will enable GCC 7. The changes are not persistent and these commands will need to be re-run every time a new terminal session is started.

scl enable devtoolset-7 bash
2.4) Install ninja (Only for SLES 12-SP5 and RHEL 7.x)
 cd $SOURCE_ROOT
 git clone https://github.com/ninja-build/ninja
 cd ninja
 git checkout v1.8.2
 ./configure.py --bootstrap
 export PATH=$SOURCE_ROOT/ninja:$PATH
2.5) Install maven (Only for SLES and RHEL 7.x)
 cd $SOURCE_ROOT
 wget https://archive.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
 tar -xvzf apache-maven-3.6.3-bin.tar.gz
 export PATH=$PATH:$SOURCE_ROOT/apache-maven-3.6.3/bin/
2.6) Install Go (Only for SLES)
 cd $SOURCE_ROOT
 wget https://storage.googleapis.com/golang/go1.16.3.linux-s390x.tar.gz
 sudo tar -C /usr/local -xzf go1.16.3.linux-s390x.tar.gz
 export PATH=/usr/local/go/bin:$PATH
 export GOROOT=/usr/local/go
 export GOPATH=/usr/local/go/bin
2.7) Install CMake 3.7.2 (Only for RHEL 7.x)
 cd $SOURCE_ROOT
 wget https://cmake.org/files/v3.7/cmake-3.7.2.tar.gz
 tar xzf cmake-3.7.2.tar.gz
 cd cmake-3.7.2
 ./configure --prefix=/usr/local
 make && sudo make install

Step 3: Download source code

 cd $SOURCE_ROOT
 git clone https://github.com/netty/netty-tcnative.git
 cd netty-tcnative
 git checkout netty-tcnative-parent-2.0.46.Final

Step 4: Build netty-tcnative

 cd $SOURCE_ROOT/netty-tcnative
 #Replace boringssl source code link to the one supported on s390x.
 sed -i '62,62 s/chromium-stable/patch-s390x-Jan2021/g' pom.xml
 sed -i '66,66 s/1607f54fed72c6589d560254626909a64124f091/d83fd4af80af244ac623b99d8152c2e53287b9ad/g' pom.xml
 sed -i '54,54 s/boringssl.googlesource.com/github.com\/linux-on-ibm-z/g' boringssl-static/pom.xml
 sed -i '55,55 s/chromium-stable/patch-s390x-Jan2021/g' boringssl-static/pom.xml
  • Add GCC patch (Only for UBUNTU 21.10)
curl -o gcc_patch.diff https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/BoringSSL/Jan2021/patch/gcc_patch.diff 
cp gcc_patch.diff /tmp/gcc_patch.diff

sed -i "184i <exec executable=\"git\" failonerror=\"true\" dir=\"\${boringsslSourceDir}\" resolveexecutable=\"true\">"  boringssl-static/pom.xml
sed -i "185i      <arg value=\"apply\" /> "  boringssl-static/pom.xml
sed -i "186i   <arg value=\"/tmp/gcc_patch.diff\" />"  boringssl-static/pom.xml
sed -i "187i   </exec>"  boringssl-static/pom.xml
  • Build netty-tcnative
./mvnw clean install

Step 5: Set LD_LIBRARY_PATH

export LD_LIBRARY_PATH=$SOURCE_ROOT/netty-tcnative/openssl-dynamic/target/native-build/.libs/:$LD_LIBRARY_PATH

References:

Clone this wiki locally