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

Setting Up the Environment

Hardware Environment

Table 1 shows the compiler hardware configurations.

Table 1 Recommended hardware configurations for the compiler

Item

Requirement

Processor

Kunpeng processor

Memory size

32 GB or above

Drive

480 GB or above

Software Environment

Table 2 shows the compiler software configurations.

Table 2 Recommended software configurations for the compiler

Item

Software Version

OS

openEuler-20.03-LTS-SP1

JDK

OpenJDK 1.8.0_282

Maven

3.6.3

Scala

2.12.11

GCC

7.3.0

CMake

3.16.5

Installing JDK

  1. Download the JDK installation package and decompress it to the installation directory.
    1
    2
    wget https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u282-b08/OpenJDK8U-jdk_aarch64_linux_hotspot_jdk8u282-b08.tar.gz
    tar -zxf OpenJDK8U-jdk_aarch64_linux_hotspot_jdk8u282-b08.tar.gz -C /usr/local
    
  2. Configure the JDK environment variables.
    1
    vim /etc/profile
    

    Add the JDK path to the profile file.

    1
    2
    export JAVA_HOME=/usr/local/jdk8u282-b08
    export PATH=$JAVA_HOME/bin:${PATH}
    
  3. Make the environment variables take effect.
    1
    source /etc/profile
    
  4. Check the JDK version.
    1
    java -version
    

Installing Maven

  1. Download and install the installation package to a directory (for example, /opt/tools/installed).
    1
    2
    3
    wget https://archive.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
    tar -zxf apache-maven-3.6.3-bin.tar.gz
    mv apache-maven-3.6.3 /opt/tools/installed/
    
  2. Modify the Maven environment variables.
    1
    vim /etc/profile
    
    Add the following code at the end of the /etc/profile file:
    1
    2
    export MAVEN_HOME=/opt/tools/installed/apache-maven-3.6.3
    export PATH=$MAVEN_HOME/bin:$PATH
    
  3. Make the environment variables take effect.
    1
    source /etc/profile
    
  4. Check whether the configuration takes effect.
    1
    mvn -v
    

  5. Modify the local repository path and remote repository in the Maven configuration file.

    Configuration file path: /opt/tools/installed/apache-maven-3.6.3/conf/settings.xml

    The default local repository directory is ~/.m2/. If you want to change the directory, modify the localRepository tag. You do not need to modify this parameter unless otherwise specified.

    Add the following content to the <mirrors> tag to configure the remote repository (change the repository to the Maven repository that you have built. If the Maven repository does not exist, configure it based on the following example):

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
      <mirrors>
          <id>mirrors.huaweicloud.com</id>
          <url>https://mirrors.huaweicloud.com/kunpeng/maven</url>
          <name>mirrors huaweicloud com</name>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </mirrors>
      <mirrors>
          <id>repository.huaweicloud.com</id>
          <url>https://mirrors.huaweicloud.com/repository/maven</url>
          <name>repository huaweicloud com</name>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
       </mirrors>
    

    If a proxy is used, add the proxy configuration to the settings.xml file. The details are as follows:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    <proxies>
      <proxy>
        <id>optional</id>
        <active>true</active>
        <protocol>http</protocol>
        <username>[Username]</username>
        <password>[Password]</password>
        <host>[Proxy server URL]</host>
        <port>[Proxy server port]</port>
        <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
      </proxy>
    </proxies>
    

When Maven is used for build, you are advised to use mvn installed by the local Maven instead of build/mvn, because build/mvn will run the zinc service, which may expose the build machine information.

Installing GCC-7.3.0

  1. Download the installation package and install Maven to a directory (for example, /opt/tools/installed/).
    cd /opt/tools/installed/
  2. Download the GCC-7.3.0 source package.
    wget https://ftp.gnu.org/gnu/gcc/gcc-7.3.0/gcc-7.3.0.tar.gz
  3. Decompress the source package.
    tar -xf gcc-7.3.0.tar.gz
  4. Go to the source code directory.
    cd gcc-7.3.0
  5. Install bzip2.
    yum install -y bzip2
  6. Download the dependency.
    ./contrib/download_prerequisites

    Ensure that the network is connected. If the download fails, you can manually download the file.

    wget http://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2 
    wget http://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2 
    wget http://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz 
    wget http://gcc.gnu.org/pub/gcc/infrastructure/isl-0.16.1.tar.bz2

    After the manual download is complete, run the script again.

    ./contrib/download_prerequisites
  7. Edit the configuration.
    ./configure --enable-languages=c,c++ --disable-multilib --with-system-zlib --prefix=/usr/local/gcc7.3.0
  8. Perform compilation and installation.
    make -j15
    make install
  9. Configure environment variables in the /etc/profile file.
    vim /etc/profile
  10. Add the following content to the last line of the file:
    export LD_LIBRARY_PATH=/usr/local/gcc7.3.0/lib64:${LD_LIBRARY_PATH}
    export CC=/usr/local/gcc7.3.0/bin/gcc
    export CXX=/usr/local/gcc7.3.0/bin/g++
  11. Press Esc to exit the edit mode and save the modification.
    :wq
  12. Make the environment variables take effect.
    source /etc/profile
  13. Verify the installation.
    gcc -v

    g++ -v

    The installation path depends on the preceding configurations. You only need to pay attention to the version number.