我要评分
获取效率
正确性
完整性
易理解

Compiling Conscrypt

  1. Go to the /home directory on the server and download the Conscrypt source code.
    1
    2
    cd /home
    wget https://github.com/google/conscrypt/archive/2.1.0.zip --no-check-certificate
    
  2. Decompress the Conscrypt source package.
    1
    unzip 2.1.0.zip
    
  3. Rename conscrypt-2.1.0 to conscrypt.
    1
    mv conscrypt-2.1.0 conscrypt
    
  4. Obtain the Conscrypt dependency package.

    In this step, gradle-4.8.1-all is automatically downloaded from /root/.gradle/wrapper/dists.

    1
    2
    cd /home/conscrypt
    ./gradlew
    

    If a proxy is used, run the following commands. Configure the host name, port number, user name, and password of the proxy based on the actual proxy environment.

    ./gradlew -Dhttp.proxyHost=proxysg.huawei.com -Dhttp.proxyPort=8080 -Dhttps.proxyHost=proxysg.huawei.com -Dhttps.proxyPort=8080  -Dhttps.proxyUser= -Dhttps.proxyPassword=  -Dhttp.proxyUser= -Dhttp.proxyPassword=

    If the following error message is displayed when you run ./gradlew:

    use the following method to resolve the problem:

    1. Go to the /root/.gradle/wrapper/dists/gradle-4.8.1-all/6fmj4nezasjg1b7kkmy10xgo2 directory.
      cd /root/.gradle/wrapper/dists/gradle-4.8.1-all/6fmj4nezasjg1b7kkmy10xgo2

      Note: The 6fmj4nezasjg1b7kkmy10xgo2 directory may be different. Replace the directory with the actual one.

    2. Download the Gradle source code.
      1
      wget https://services.gradle.org/distributions/gradle-4.8.1-all.zip --no-check-certificate
      
    3. Decompress the gradle-4.8.1-all.zip package.
      1
      unzip gradle-4.8.1-all.zip
      
    4. Go to the /home/conscrypt directory.
      1
      cd /home/conscrypt
      
    5. Perform the compilation again (set the proxy host, port, user name, and password based on the actual environment):
      ./gradlew -Dhttp.proxyHost=proxysg.huawei.com -Dhttp.proxyPort=8080 -Dhttps.proxyHost=proxysg.huawei.com -Dhttps.proxyPort=8080  -Dhttps.proxyUser= -Dhttps.proxyPassword=  -Dhttp.proxyUser= -Dhttp.proxyPassword=
  5. Copy the gradle-platform-native-4.8.1.jar package compiled in 9 to the local repository directory.
    1
    cp /home/gradle/subprojects/platform-native/build/libs/gradle-platform-native-4.8.1.jar  /root/.gradle/wrapper/dists/gradle-4.8.1-all/6fmj4nezasjg1b7kkmy10xgo2/gradle-4.8.1/lib/plugins
    
  6. Restart the server. After Gradle is compiled, the Gradle in use is still the old version. The compiled Gradle takes effect only after the server is restarted.
    1
    reboot
    
  7. Go to the conscrypt directory and delete the sub-module openjdk-integ-tests.
    1
    2
    cd /home/conscrypt
    rm -rf openjdk-integ-tests
    
  8. Go to the openjdk directory.
    1
    cd openjdk
    
  9. Modify the build.gradle file in the openjdk directory.
    1. Open the build.gradle file.
      1
      vim build.gradle
      
    2. Press i to enter the insert mode and add aarch64 to the file name extension of the original 64-bit build file.
      • Add the following code to line 12:
            arm64 = 'aarch64'

      • Modify line 21.
                nativeClassifier64Bit = classifierFor(osName, arm64)

    3. Add the platform configuration to line 291.
              linux_aarch64 {
                   architecture "aarch64"
                   operatingSystem "linux"
              }

    4. Change the 64-bit architecture to linux_aarch64 when building jni-library.
      • Comment out line 304 and change arch64Name in line 305 to linux_aarch64.
                    //if (build32Bit) { targetPlatform arch32Name }
                   if (build64Bit) { targetPlatform "linux_aarch64" }

      • Modify the content in line 326 to aarch64.

    5. Add the address of the specified header file to args during Clang or GCC compilation.

      Modify lines 339 and 342 to ensure that they are consistent with the GCC path.

      On CentOS, modify the file as follows:

                                      "-I$jniSourceDir/main/include",
                                      "-I$jniSourceDir/unbundled/include",
                                      "-I/usr/include/c++/4.8.2",
                                      "-I/usr/include/c++/4.8.2/aarch64-redhat-linux",

      On openEuler, modify the file as follows:

      "-I$jniSourceDir/main/include",
      "-I$jniSourceDir/unbundled/include",
      "-I/usr/include/c++/7.3.0",
      "-I/usr/include/c++/7.3.0/aarch64-linux-gnu",

    6. Modify the code for generating library information.
      • Modify lines 419 to line 428.
                    def archName = binary.targetPlatform.architecture.name
                    def archNameR = archName
                    if(archName == 'aarch64'){
                      archNameR = 'aarch_64'
                    }
                    archName = archName.replaceAll('-','_')
                    def classifier = classifierFor(osName, archName)
                    def classifierR = classifierFor(osName,archNameR)
                    def sourceSetName = sourceSetName("$classifier")
                    def source = binary.sharedLibraryFile

      • Change the content in lines 435 and 437 to classifierR.

    7. Press Esc, type :wq!, and press Enter to save the file and exit.
  10. Return to the upper-level directory and modify the build.gradle file in the conscrypt directory.
    1. Open the build.gradle file.
      1
      vim build.gradle
      
    2. Press i to enter the insert mode, modify line 39, and add lines 40 to 43.
                       gcc(Gcc){
                        target("linux_aarch64") {
                        cppCompiler.executable = "/usr/bin/gcc"
                        }
                      }

    3. Add the following code to lines 160 to 162:
          dependencies {
              errorprone("com.google.errorprone:error_prone_core:2.3.3")
          }

    4. Press Esc, type :wq!, and press Enter to save the file and exit.
  11. Configure a Gradle proxy.
    1. Create a gradle.properties file.
      1
      touch gradle.properties
      
    2. Add the following content to the file, save the file, and exit. Configure the host name, port number, user name, and password of the proxy based on the actual proxy environment.
      org.gradle.jvmargs=-Xmx2500m -XX:MaxPermSize=256m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
      org.gradle.parallel=true
      systemProp.http.auth.ntlm.domain=CHINA
      systemProp.http.proxyHost=proxysg.huawei.com
      systemProp.http.proxyUser = Actual proxy user name
      systemProp.http.proxyPassword = Actual proxy user password
      systemProp.http.proxyPort=8080
      systemProp.http.nonProxyHosts=*.huawei.com|localhost|127.0.0.1
      systemProp.https.proxyHost=proxysg.huawei.com
      systemProp.https.proxyUser = Actual proxy user name
      systemProp.https.proxyPassword = Actual proxy user password
      systemProp.https.proxyPort=8080
      systemProp.https.nonProxyHosts=*.huawei.com|localhost|127.0.0.1
      systemProp.javax.net.ssl.trustStore=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.272.b10-7.oe1.aarch64/jre/lib/security/cacerts
      systemProp.javax.net.ssl.trustStorePassword=changeit
  12. Build Conscrypt.
    1
    2
    cd /home/conscrypt
    ./gradlew clean build --stacktrace -x :conscrypt-openjdk:linux_aarch64Test -Dorg.conscrypt.openjdk.buildUberJar=true
    

  13. Go to the openjdk-uber/build/libs directory.
    1
    cd openjdk-uber/build/libs
    
  14. Decompress the conscrypt-openjdk-uber-2.1.0.jar package.
    1
    jar xvf conscrypt-openjdk-uber-2.1.0.jar
    
  15. Place the libconscrypt_openjdk_jni-linux-aarch_64.so file in the /home/conscrypt/openjdk/build/linux_aarch_64/native-resources/META-INF/native\ directory to the META-INF/native directory in the conscrypt-open-uber-2.1.0.jar package.
    1
    cp /home/conscrypt/openjdk/build/linux_aarch_64/native-resources/META-INF/native/libconscrypt_openjdk_jni-linux-aarch_64.so META-INF/native
    
  16. Pack the JAR file. The porting is complete.
    1
    jar cvf conscrypt-openjdk-uber-2.1.0.jar META-INF/ org