Kunpeng Porting Advisor 2.3.T10

Common Operations

Date 2021-06-30 Kunpeng Porting Advisor Common Operations Contents

Contents

1 Configuring the Installation Environment...... 1 1.1 Configuring the OS Yum, APT, or Zypper Source...... 1 1.2 Upgrading Dependency Components of an Earlier OS...... 4 2 Importing the Root Certificate for Kunpeng Porting Advisor...... 8 3 Disabling SELinux...... 14 4 Common Container Operations...... 15 5 Changing the IP Address and Port Number of the Kunpeng Porting Advisor...... 17 6 Starting, Stopping, or Restarting Services...... 19 7 Exception Scenarios and Common Syntax Errors in Inline Assembly...... 20 7.1 Exception Scenarios...... 20 7.2 Common Syntax Errors...... 22 8 Identifying Compile Commands Using the Build Tool Configuration File...... 24 9 Querying OS Version Information...... 26

2021-06-30 ii Kunpeng Porting Advisor Common Operations 1 Configuring the Installation Environment

1 Configuring the Installation Environment

1.1 Configuring the OS Yum, APT, or Zypper Source 1.2 Upgrading Dependency Components of an Earlier OS

1.1 Configuring the OS Yum, APT, or Zypper Source

NO TICE

If the OS environment can access the Internet and the default Yum, APT, or Zypper source of the OS is available, skip this section.

Configuring the OS Yum Source (for CentOS/EulerOS/openEuler/RHEL/ NeoKylin/Kylin) The following describes how to configure the Yum source on CentOS 7.6. The configuration procedure is the same for other OSs.

Step 1 Download the CentOS image file CentOS-7-x86_64-Everything-1810.iso from the official CentOS website. Step 2 Use an SSH remote login tool to upload the CentOS 7.6 image to the /root directory. Step 3 Use the SSH remote login tool to log in to the CentOS CLI. Step 4 Run the following command to mount the CentOS 7.6 ISO image to a local directory: mount /root/CentOS-7-x86_64-Everything-1810.iso /media -o loop

NO TICE

If the OS is restarted, you need to mount the image file again.

2021-06-30 1 Kunpeng Porting Advisor Common Operations 1 Configuring the Installation Environment

Step 5 Run the following commands to back up the original Yum source. In the mv command, path indicates the backup directory. Replace it with the actual backup directory. cd /etc/yum.repos.d/ //Go to the Yum source configuration directory. mv ./* path //Back up the original Yum source configuration. Step 6 Configure the Yum source. 1. Run the following command to open the media.repo file. vi /etc/yum.repos.d/media.repo 2. Press i to make the media.repo file editable and add the following information to the file: [InstallMedia] name=CentOS7.6 metadata_expire=-1 gpgcheck=0 cost=500 baseurl=file:///media enabled=1 3. Press Esc, type :wq and press Enter to save the settings and exit. Step 7 Update the local cache information of the Yum source. yum clean all yum makecache

----End

Configuring the APT Source (for ///Linx/UOS) The following describes how to configure the APT source on Ubuntu 18.04.1. The configuration procedure is the same for other OSs.

Step 1 Download the Ubuntu image file ubuntu-18.04.1-server-amd64.iso from the Ubuntu official website. Step 2 Use the SSH remote login tool to upload the Ubuntu 18.04.1 image to the /root directory. Step 3 Use the SSH remote login tool to log in to the Ubuntu CLI. Step 4 Run the following command to mount the Ubuntu 18.04.1 ISO image file to a local directory: mount /root/ubuntu-18.04.1-server-amd64.iso /media -o loop

NO TICE

● If the OS is restarted, you need to mount the image file again. ● Some installation packages are missing in the local image sources of Debian OSs. Download the required installation packages from the Internet or using a proxy. The dependencies are listed as follows: expect GCC make zlib1g zlib1g-dev libpcre3 libpcre3-dev OpenSSL libssl-dev If the OS cannot access the Internet or have a proxy configured, check, download, and install the dependencies manually. You can run the following commands to query and install dependency packages: -l Installation package name dpkg -i Installation package name

2021-06-30 2 Kunpeng Porting Advisor Common Operations 1 Configuring the Installation Environment

Step 5 Back up the original APT source: cd /etc/ //Go to the APT source configuration directory. mv -v sources.list{,.bak} //Back up the original APT source configuration. Step 6 Configure the APT source. 1. Run the following command to open the source.list file. vim sources.list 2. Add the following information to the source.list file: deb file:///media wheezy main

NO TE

In the preceding command, wheezy main is the directory in which Packages is located. Replace it with the actual directory. 3. Press Esc, type :wq, and press Enter to save the settings and exit. Step 7 Update the local cache information of the APT source. apt update

----End

Configuring the Zypper Source (for SUSE)

Step 1 Download the SUSE image file SLE-15-SP1-Packages-x86_64-GM-DVD1.iso from the SUSE official website. Step 2 Use an SSH remote login tool to upload the SUSE image to the /root directory. Step 3 Use the SSH remote login tool to log in to the SUSE CLI. Step 4 Run the following command to mount the SUSE ISO image file to a local directory: mount /root/SLE-15-SP1-Packages-x86_64-GM-DVD1.iso /media -o loop

NO TICE

If the OS is restarted, you need to mount the image file again.

Step 5 Run the following command to add the local Zypper source ("local" is the local source name in the following example): zypper ar file:///media/ local Step 6 Check whether the local source is configured successfully: zypper lr If command output is displayed, the local source is configured successfully.

Repository priorities are without effect. All enabled repositories share the same priority. # | Alias | Name | Enabled | GPG Check | Refresh --+------+------+------+------+------1 | local | local | Yes | ( p) Yes | No Step 7 Clear the local cache and refresh the image source. zypper clean zypper ref

----End

2021-06-30 3 Kunpeng Porting Advisor Common Operations 1 Configuring the Installation Environment

1.2 Upgrading Dependency Components of an Earlier OS

Upgrading glibc

This procedure applies to the following OSs:

● CentOS 6.5/6.9/6.10 ● RHEL 6.5/6.9/6.10 ● Deepin 15.2 x86

Step 1 Download the following glibc-related RPM packages: ● glibc-common-2.17-55.el6.x86_64.rpm ● glibc-utils-2.17-55.el6.x86_64.rpm ● glibc-headers-2.17-55.el6.x86_64.rpm ● glibc-static-2.17-55.el6.x86_64.rpm ● glibc-devel-2.17-55.el6.x86_64.rpm ● glibc-2.17-55.el6.x86_64.rpm ● nscd-2.17-55.el6.x86_64.rpm

URL: https://copr-be.cloud.fedoraproject.org/results/mosquito/myrepo-el6/ epel-6-x86_64/glibc-2.17-55.fc20/

Step 2 Upload the related RPM packages to a directory on the server and run the cd command to switch to the directory.

Step 3 Run the following commands to install glibc: rpm -ivh glibc-common-2.17-55.el6.x86_64.rpm rpm -ivh glibc-utils-2.17-55.el6.x86_64.rpm rpm -ivh glibc-headers-2.17-55.el6.x86_64.rpm rpm -ivh glibc-static-2.17-55.el6.x86_64.rpm rpm -ivh glibc-devel-2.17-55.el6.x86_64.rpm rpm -ivh glibc-2.17-55.el6.x86_64.rpm rpm -ivh nscd-2.17-55.el6.x86_64.rpm

NO TE

If dependencies need to be installed, run the following command to install dependencies first: yum install After the dependencies are installed, run the following commands to install glibc: rpm -ivh glibc-common-2.17-55.el6.x86_64.rpm --force --nodeps rpm -ivh glibc-utils-2.17-55.el6.x86_64.rpm --force --nodeps rpm -ivh glibc-headers-2.17-55.el6.x86_64.rpm --force --nodeps rpm -ivh glibc-static-2.17-55.el6.x86_64.rpm --force --nodeps rpm -ivh glibc-devel-2.17-55.el6.x86_64.rpm --force --nodeps rpm -ivh glibc-2.17-55.el6.x86_64.rpm --force --nodeps rpm -ivh nscd-2.17-55.el6.x86_64.rpm --force --nodeps

Step 4 After the installation is complete, run the following command to check the glibc version: ldd --version

2021-06-30 4 Kunpeng Porting Advisor Common Operations 1 Configuring the Installation Environment

If the displayed version is the same as the version you installed, glibc is upgraded successfully.

----End

Upgrading glibcxx This procedure applies to the following OSs:

● CentOS 6.5/6.9/6.10 ● RHEL 6.5/6.9/6.10 ● Deepin 15.2 x86

Step 1 Download the following RPM packages related to glibcxx: ● libstdc++-4.8.2-16.3.el6.x86_64.rpm ● libstdc++-devel-4.8.2-16.3.el6.x86_64.rpm ● libstdc++-static-4.8.2-16.3.el6.x86_64.rpm

URL: https://copr-be.cloud.fedoraproject.org/results/mosquito/myrepo-el6/ epel-6-x86_64/glibc-2.17-55.fc20/

Step 2 Upload the related RPM packages to a directory on the server and run the cd command to switch to the directory.

Step 3 Run the following commands to install glibcxx: rpm -ivh libstdc++-4.8.2-16.3.el6.x86_64.rpm rpm -ivh libstdc++-devel-4.8.2-16.3.el6.x86_64.rpm rpm -ivh libstdc++-static-4.8.2-16.3.el6.x86_64.rpm

NO TE

If dependencies need to be installed, run the following command to install dependencies first: yum install After the dependencies are installed, run the following commands to install glibcxx: rpm -ivh libstdc++-4.8.2-16.3.el6.x86_64.rpm --force --nodeps rpm -ivh libstdc++-devel-4.8.2-16.3.el6.x86_64.rpm --force --nodeps rpm -ivhlibstdc++-static-4.8.2-16.3.el6.x86_64.rpm --force --nodeps

Step 4 After the installation is complete, run the following command to check the glibcxx version: strings /usr/lib64/libstdc++.so.6.0.19 | grep GLIBCXX_3.4.19

If the version displayed is the same as the version you installed, glibcxx is upgraded successfully.

----End

Upgrading OpenSSL This procedure applies to the following OSs:

● CentOS 6.5/6.9/6.10/7.2/7.3 ● RHEL 6.5/6.9/6.10/7.2/7.3 ● Deepin 15.2 x86

2021-06-30 5 Kunpeng Porting Advisor Common Operations 1 Configuring the Installation Environment

Step 1 Download the following OpenSSL-related RPM packages: ● openssl-libs-1.0.2k-19.el7.x86_64.rpm ● openssl-devel-1.0.2k-19.el7.x86_64.rpm ● openssl-1.0.2k-19.el7.x86_64.rpm

Step 2 Upload the related RPM packages to a directory on the server and run the cd command to switch to the directory.

Step 3 Run the following commands to install OpenSSL. rpm -ivh openssl-libs-1.0.2k-19.el7.x86_64.rpm rpm -ivh openssl-devel-1.0.2k-19.el7.x86_64.rpm rpm -ivh openssl-1.0.2k-19.el7.x86_64.rpm

NO TE

If dependencies need to be installed, run the following command to install dependencies first: yum install After the dependencies are installed, run the following commands to install OpenSSL: rpm -ivh openssl-libs-1.0.2k-19.el7.x86_64.rpm --force --nodeps rpm -ivh openssl-devel-1.0.2k-19.el7.x86_64.rpm --force --nodeps rpm -ivh openssl-1.0.2k-19.el7.x86_64.rpm --force --nodeps

Step 4 After the installation is complete, run the following command to check the OpenSSL version: openssl version

If the following content is displayed, OpenSSL is upgraded successfully.

OpenSSL 1.0.2k-fips

----End

Upgrading libffi

This procedure applies to the following OSs:

● CentOS 6.5/6.9/6.10 ● RHEL 6.5/6.9/6.10 ● Deepin 15.2 x86

Step 1 Download the libffi installation package libffi-3.0.13-18.el7.x86_64.rpm.

Step 2 Upload the RPM package to a directory on the server and run the cd command to switch to the directory.

Step 3 Run the following command to install libffi. rpm -ivh libffi-3.0.13-18.el7.x86_64.rpm

NO TE

If dependencies need to be installed, run the following command to install dependencies first: yum install After the dependencies are installed, run the following commands to install libffi: rpm -ivh libffi-3.0.13-18.el7.x86_64.rpm

2021-06-30 6 Kunpeng Porting Advisor Common Operations 1 Configuring the Installation Environment

Step 4 After the installation is complete, run the following command to check the libffi version: rpm -qa | grep libffi If the version displayed is the same as the version you installed, libffi is upgraded successfully.

----End

2021-06-30 7 Kunpeng Porting Advisor 2 Importing the Root Certificate for Kunpeng Common Operations Porting Advisor

2 Importing the Root Certificate for Kunpeng Porting Advisor

If a security alert is displayed when you use a browser to log in to the Kunpeng Porting Advisor, you can import a root certificate for the tool to shield the security alert. The following uses Chrome 72.0 as an example to describe how to import a root certificate for the Kunpeng Porting Advisor.

Step 1 Log in to the Kunpeng Porting Advisor WebUI, click in the upper right corner, choose Web Server Certificate, and click Download Root Certificate. Step 2 Open the browser and choose Settings > Privacy and security > Security > Manage certificates. Step 3 In the Certificates dialog box displayed, select the Trusted Root Certification Authorities tab and click Import, as shown in Figure 2-1.

2021-06-30 8 Kunpeng Porting Advisor 2 Importing the Root Certificate for Kunpeng Common Operations Porting Advisor

Figure 2-1 Certificates

Step 4 In the Certificate Import Wizard dialog box displayed, click Next, as shown in Figure 2-2.

2021-06-30 9 Kunpeng Porting Advisor 2 Importing the Root Certificate for Kunpeng Common Operations Porting Advisor

Figure 2-2 Welcome to the Certificate Import Wizard

Step 5 In the File to Import dialog box displayed, click Browse, as shown in Figure 2-3.

2021-06-30 10 Kunpeng Porting Advisor 2 Importing the Root Certificate for Kunpeng Common Operations Porting Advisor

Figure 2-3 Importing the certificate

Step 6 Select the certificate to be imported and click Next. Step 7 Click Next. In the Certificate Store dialog box displayed, set the certificate store as shown in Figure 2-4, and click Next.

2021-06-30 11 Kunpeng Porting Advisor 2 Importing the Root Certificate for Kunpeng Common Operations Porting Advisor

Figure 2-4 Specifying a location for the certificate

Step 8 Click Finish. The Security Warning dialog box is displayed. Step 9 Click Yes. "The import was successful" is displayed. Step 10 Click OK. Step 11 Modify the mapping between the server IP address and the tool in the local hosts file. 1. Open the hosts file in C:\Windows\System32\drivers\etc.

2021-06-30 12 Kunpeng Porting Advisor 2 Importing the Root Certificate for Kunpeng Common Operations Porting Advisor

Figure 2-5 hosts file

2. Add the following content in the hosts file, save the changes, and exit. Server IP address Porting-advisor For example: 10.175.119.171 Porting-advisor Step 12 Open the browser, enter https://porting-advisor:port number (for example: https:/porting-advisor:8084) in the address box, and click Enter.

----End

2021-06-30 13 Kunpeng Porting Advisor Common Operations 3 Disabling SELinux

3 Disabling SELinux

By default, the SELinux enforcing mode is enabled for openEuler, EulerOS, and CentOS 8.0 or later. This will cause an installation failure of the tool. To disable the SELinux enforcing mode, perform the following operations:

● Disabling SELinux temporarily a. Run the following command to query the SELinux status: sestatus If the value of Current mode is enforcing, the SELinux enforcing mode is enabled. b. Run the following command to set the SELinux mode to permissive: setenforce 0 c. Query the SELinux status again. If the value of Current mode is permissive, the SELinux enforcing mode is disabled temporarily.

NO TICE

The settings become invalid after the server is restarted. When the tool is used, service exceptions may occur.

● Disabling SELinux permanently a. Run the following command to query the SELinux status: sestatus If SELinux status is enabled, SELinux is enabled. b. Run the following command to open the /etc/selinux/config file: vi /etc/selinux/config c. Press i to enter the edit mode and change SELINUX=enforcing to SELINUX=disabled. d. Press Esc, type :wq, and press Enter to save the settings and exit. e. Run the following command to restart the server: reboot f. Query the SELinux status again. If SELinux status is disabled, SELinux is disabled.

2021-06-30 14 Kunpeng Porting Advisor Common Operations 4 Common Container Operations

4 Common Container Operations

The following describes the common operations for the tool deployed on a Docker container.

● Create a Docker container in port mapping mode. docker run --privileged -p 8084:8084 -p 7998:7998 --name containername IMAGE:TAG /usr/sbin/init

NO TE

● --name specifies the name of the container to be created. ● -p specifies the port mapping in the Host (host) port: Container port format. ● 8084 is the default HTTPS port number of the Kunpeng Porting Advisor, and 7998 is the default tool port number. You need to enter the mapped container port number during the tool installation. Specify the actual port numbers. ● IMAGE indicates the path of the imported Docker image, and TAG indicates the tag of the image. You can run the following command to query related information: docker images ● Access a Docker container. docker exec -it containerID /bin/bash

NO TE

In this command, containerID indicates the container ID. You can run the following command on the host machine to query it: docker ps ● Copy software packages to a Docker container. scp root@serverIP:serverpath dockerpath

NO TE

● root is the user name of the host machine. ● serverIP specifies the IP address of the host machine. ● serverpath specifies the path of the software packages on the host machine. ● dockerpath specifies the path of the software packages on the container. ● During the installation, the local IP address must be the container IP address. You can run the following command to query the IP address: docker inspect containerID ● After the installation is successful, the tool login address displayed is the address for directly accessing the container. To access the tool outside the

2021-06-30 15 Kunpeng Porting Advisor Common Operations 4 Common Container Operations

container, replace the container IP address with the host IP address and replace the container port number with the host port number.

2021-06-30 16 Kunpeng Porting Advisor 5 Changing the IP Address and Port Number of the Common Operations Kunpeng Porting Advisor

5 Changing the IP Address and Port Number of the Kunpeng Porting Advisor

In the following commands, /opt/portadv is the tool installation directory. Replace it with the actual directory.

Step 1 Use an SSH remote login tool to log in to the CLI. Step 2 Stop the Kunpeng Porting Advisor.

Table 5-1 Commands for stopping the Kunpeng Code Scanner on different OSs OS Command

CentOS 6.x/RHEL 6.x service nginx_port stop

CentOS 7.x/CentOS 8.x/EulerOS/ systemctl stop nginx_port openEuler/RHEL 7.x/ NeoKylin/Kylin/ SUSE/Debian/Ubuntu/Deepin/ Linx/UOS

NO TICE

Before changing the IP address and port number, you must stop the Kunpeng Porting Advisor.

Step 3 Run the following commands to change the IP address and port number: cd /opt/portadv/tools bash change_ip_port.sh The command output is as follows:

Ip address list: sequence_number ip_address device [1] 10.254.206.190 eth0Enter Enter the sequence number of listed ip as web server ip: 1 Set the web server IP address 10.254.206.190 Please enter HTTPS port(default: 8084): The HTTPS port 8084 is valid. Set the HTTPS port to 8084 (y/n default: y):n Please enter HTTPS port(default: 8084):8088

2021-06-30 17 Kunpeng Porting Advisor 5 Changing the IP Address and Port Number of the Common Operations Kunpeng Porting Advisor

The HTTPS port 8088 is valid. Set the HTTPS port to 8088 (y/n default: y):y Set the HTTPS port 8088 Web console is now running, go to:https://10.254.206.190:8088.

NO TE

● Before modifying the IP address and port number, go to the /opt/portadv/tools directory. ● After the command is executed, available IP addresses will be listed. You can select an IP address. ● If the specified port number is in use, the system automatically increments the port number by 1 until an available port number is found. If no port is available, the installation stops. ● If the OS firewall of the server is enabled, the tool automatically checks whether the configured port is enabled. If the port is enabled, the installation continues. If the port is not enabled, you are prompted to enable the port. If you select y, the tool automatically enables the port. When the tool is uninstalled, the port will be restored to the original status. If you do not enable the port, the tool installation is not affected, but the web access will fail. If you want to access the tool using a web browser, you need to enable the firewall port of the server OS. For details, see Installing the Kunpeng Porting Advisor. ● After the port number is changed, the Kunpeng Porting Advisor automatically starts.

----End

2021-06-30 18 Kunpeng Porting Advisor Common Operations 6 Starting, Stopping, or Restarting Services

6 Starting, Stopping, or Restarting Services

The commands for starting, stopping, restarting, and querying services vary with the . ● CentOS 6.x/RHEL 6.x service nginx_port start/stop/restart/status service gunicorn_port start/stop/restart/status ● CentOS 7.x/CentOS 8.x/EulerOS/openEuler/RHEL 7.x/ NeoKylin/Kylin/SUSE/ Debian/Ubuntu/Deepin/Linx/UOS systemctl start/stop/restart/status nginx_port.service systemctl start/stop/restart/status gunicorn_port.service

NO TE

If the tool is installed on a container, the commands for starting and stopping the applications are as follows (/opt/portadv is the tool installation directory. Replace it with the actual directory.): Start, stop, restart, or query Nginx: cd /opt/portadv/tools&&./docker_service.sh start/stop/restart/status nginx_port Start, stop, restart, or query Gunicorn: cd /opt/portadv/tools&&./docker_service.sh start/stop/restart/status gunicorn_port

2021-06-30 19 Kunpeng Porting Advisor 7 Exception Scenarios and Common Syntax Errors in Common Operations Inline Assembly

7 Exception Scenarios and Common Syntax Errors in Inline Assembly

7.1 Exception Scenarios 7.2 Common Syntax Errors

7.1 Exception Scenarios

Using the Mixed Intel and AT&T Syntaxes GCC supports different assembly syntaxes in inline assembly. The assembly syntaxes of different types are separated by {... |...}. In the following example, Intel and AT&T syntaxes are used. The tool, however, supports only the AT&T syntax. Table 7-1 lists the differences between the AT&T syntax and Intel syntax.

Table 7-1 Differences between AT&T and Intel syntaxes Category AT&T Intel Description

Registers %eax eax The register names in AT&T syntax must be prefixed with %.

Immediat mov $imm, mov ebx, The immediates in AT&T syntax es %eax imm must be prefixed with $.

Source/ movl %eax, mov ebx, eax In AT&T syntax, the destination Destinatio %ebx operand follows the source operand. n operand sequence

Memory disp (base, base - addressin index, scale) +index*scale g mode +disp

void multiple_assembler_dialects() {

2021-06-30 20 Kunpeng Porting Advisor 7 Exception Scenarios and Common Syntax Errors in Common Operations Inline Assembly

int a = 10; int b = 101; __asm__( "add{l %[int_b], %[out_a] | %[out_a], %[int_b]}" :[out_a]"+r"(a) :[int_b]"r"(b): ); }

Using the goto Label The following is an example of an inline assembly code block that uses the goto label:

int goto_label(int a, int b) { __asm__ goto( "cmp %0, %1\n\t" "jb %l[label]\n\t" : : "r"(a), "r"(b) : : label ); return a; label: return b; }

Using Segment Registers The following is an example of an inline assembly code block that uses the ds segment register:

void segment_register(unsigned int *base, unsigned long index) { int output = 0; __asm__( "movl %%ds:%c4(%1, %3, 4), %0\n\t" :"=r"(output) :"r"(base), "r"(output), "r"(index), "i"(4) :"eax" ); }

Using a Physical Register with No Value In the following example, the eax register is not assigned a value before being used. As a result, the result is unknown.

void unassigned_register() { int output = 0; __asm__( "movl %%eax, %0\n\t" :"=r"(output) : ); }

Using Global Symbols In the following example, the global variable Foo and the external label out_label are global symbols for the first assembly code block.

2021-06-30 21 Kunpeng Porting Advisor 7 Exception Scenarios and Common Syntax Errors in Common Operations Inline Assembly

int Foo[] = {100, 101, 102}; void global_symbol() { int output = 0; __asm__( "movl 4+Foo, %0\n\t" "jmp out_label\n\t" :"=r"(output) : ); __asm__( "out_label:\n\t" ); }

Input and Output Variables Greater Than 128 Bits

In the following example, the type of the output variable (result) is __m256i, and the bit width is 256 bits. The ARM architecture does not have registers greater than 128 bits. If variables greater than 128 bits are used, the assembler cannot transfer parameters properly. The tool cannot handle the parameter transfer difference between the x86 and Kunpeng platforms.

void variable_width(unsigned int *ymmData) { __m256i result; __asm__( "vmovups %1, %%ymm1\n\t" "vmovups %%ymm1, %0 \n\t" :"=m"(result) :"m"(ymmData) :"ymm1" ); }

7.2 Common Syntax Errors

Immediate Constraint Error

In the following example, the input variable (12345) is an immediate, which should use the i or other immediate constraint. If it uses the r constraint, the GCC processes it as a 32-bit number by default and cannot assign the value to the 64- bit register corresponding to the output variable (output).

void imm_value_constraint_error() { unsigned long long output = 0; __asm__( "mov %1, %0\n\t" :"=r"(output) :"r"(12345) ); }

Assembly Instruction Error

In the following example, the mov instruction is incorrectly used. The mov instruction does not apply to the scenario where memory operands are converted to memory operands. The input variable (input) and output variable (output) cannot use the memory constraint m at the same time.

2021-06-30 22 Kunpeng Porting Advisor 7 Exception Scenarios and Common Syntax Errors in Common Operations Inline Assembly

void instruction_op_use_error() { unsigned long long input = 0x11223344; unsigned long long output = 0; __asm__( "movq %1, %0\n\t" :"=m"(output) :"m"(input) ); }

2021-06-30 23 Kunpeng Porting Advisor 8 Identifying Compile Commands Using the Build Common Operations Tool Configuration File

8 Identifying Compile Commands Using the Build Tool Configuration File

Symptom If analysis of build file configuration is involved, the Compile Command may not be the default make or cmake command. You need to identify the compile command in the build configuration file and then input the command.

Reference ● If Build Tool is make, the default value is make. You can also customize a compile command starting with "make". make supports -C and -f parameters. -C specifies the working directory. -f specifies the makefile. If labels are used in your makefile, you need to identify the compile command based on the used labels. – Usually the clean and all labels are used in the makefile, as shown in Figure 8-1.

Figure 8-1 Scenario 1

make clean means to run the compile commands labeled with clean, and make means to run the compile command labeled with all or other associated labels. In this case, you only need to enter make in the Compile Command text box. – If you add the mpp label, see Figure 8-2.

2021-06-30 24 Kunpeng Porting Advisor 8 Identifying Compile Commands Using the Build Common Operations Tool Configuration File

Figure 8-2 Scenario 2

make mpp means to run the compile commands labeled with mpp. In this case, you need to enter make mpp in the Compile Command text box. For details, see Figure 8-3.

Figure 8-3 make mpp

● If Build Tool is cmake, the default value is cmake. You can also customize a compile command starting with "cmake". For details about the parameters supported by CMake, see the CMake 3.13.4 user guide on the official website. ● If Build Tool is set automake, the default value is make and cannot be changed. The automake tool does not support any parameter. When using the automake tool, ensure that the makefile exists in the project source code. Upload the makefile together with the source code file. Alternatively, you can run the automake commands after uploading the software to be analyzed, and change the owner of the generated makefile to porting, in this way, the tool can read makefile normally.

2021-06-30 25 Kunpeng Porting Advisor Common Operations 9 Querying OS Version Information

9 Querying OS Version Information

Run the uname -r command to query the CPU hardware architecture. The tool supports only x86 servers or servers powered by Kunpeng 916 or 920 processors. Query the OS version information. ● If you do not know the OS type, try the following commands one by one to check the OS version:

NO TE

According to Table 9-1, the query tool is compatible with the following commands for querying the version information of four OS types: – cat /etc/os-release – cat /etc/issue – cat /etc/redhat-release – nkvers ● If you know the OS type, find the corresponding command in Table 9-1, and then run the command to query the OS version.

Table 9-1 Compatible OS types and the version query commands Compatible OS Version Full Name of the OS Query Command

BC-Linux 7.6/7.7 cat /etc/os- BCLinux 7.6: BigCloud Enterprise Linux 7.6 release (Core) BCLinux 7.7: BigCloud Enterprise Linux 7.7 (AltArch)

2021-06-30 26 Kunpeng Porting Advisor Common Operations 9 Querying OS Version Information

Compatible OS Version Full Name of the OS Query Command

CentOS cat /etc/ CentOS 7.4: CentOS Linux release 7.4.1708 7.4/7.5/7.6/7.7/8. redhat- (AltArch) 0/8.1/8.2 release CentOS 7.5: CentOS Linux release 7.5.1804 (AltArch) CentOS 7.6: CentOS Linux release 7.6.1810 (AltArch) CentOS 7.7: CentOS Linux release 7.7.1908 (AltArch) CentOS 8.0: CentOS Linux release 8.0.1905 (Core) CentOS 8.1: CentOS Linux release 8.1.1911 (Core) CentOS 8.2: CentOS Linux release 8.2.2001 (Core)

Deepin V15.2 cat /etc/ Deepin GNU/Linux 15.2 issue

Debian 10 cat /etc/os- Debian GNU/Linux 10 (buster) release

EulerOS 2.8 cat /etc/ EulerOS release 2.0 (SP8) redhat- release

iSoft 5.1 cat /etc/os- iSoft Server OS V5.1 (aarch64) release

Kylin V10 SP1 cat /etc/os- Kylin Linux Advanced Server V10 (Tercel) release

LinxOS 6.0.90 cat /etc/os- Linx GNU/Linux 6.0.90 (stretch) release

Neokylin V7U5/ nkvers Neokylin V7U5: NeoKylin Linux Advanced V7U6 Server release V7Update5 (Vanadium) Neokylin V7U6: NeoKylin Linux Advanced Server release V7Update6 (Chromium)

openEuler 20.03 cat /etc/os- openEuler release 20.03 (LTS) release

SLES 15.1 cat /etc/os- SUSE Linux Enterprise Server 15 SP1 release

Ubuntu 18.04.x/ cat /etc/ Ubuntu 18.04.x: Ubuntu 18.04.x LTS 20.04.x issue Ubuntu 20.04.x: Ubuntu 20.04.x LTS

2021-06-30 27 Kunpeng Porting Advisor Common Operations 9 Querying OS Version Information

Compatible OS Version Full Name of the OS Query Command

UOS 20 SP1 cat /etc/os- UOS 20 SP1 release

uosEuler 20 cat /etc/os- UOS Server Euler 20 release

2021-06-30 28