Source Code Porting Modification Levels
Modification Level |
Description |
Example |
|
|---|---|---|---|
Rule |
To run your program on the Kunpeng platform, the code must be modified. |
Replace any -m64 compilation option with -mabi=lp64. Otherwise, the program cannot run on the Kunpeng platform. |
Example code: abc = -m64 Modify it as follows: abc = -mabi=lp64 |
Suggestion_Optimization |
The compilation may still succeed, but runtime performance or platform compatibility is affected. Decide whether to modify the code based on your requirements. |
The -march compilation option is not specified. The compiler uses only the basic instruction set and general optimizations, without leveraging any instruction set extensions. As a result, the hardware performance of the Kunpeng platform cannot be fully utilized. |
Example code: CFLAGS=-g3 -W -Wall -m3dnow -Wno-unused-but-set-variable -O4 -DVERSION="$(VERSION)" -DRELEASE="$(RELEASE)" -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -mpopcnt -msse4.2 Modify it as follows: CFLAGS=-g3 -W -Wall -m3dnow -Wno-unused-but-set-variable -O4 -DVERSION="$(VERSION)" -DRELEASE="$(RELEASE)" -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -mpopcnt -msse4.2 -march=armv8-a |
Suggestion_Standards |
The compilation may still succeed, but potential compatibility issues may exist in syntax, precision, or function usage. It is recommended that you check and adjust the code. |
To ensure that the default behavior of common characters on the Kunpeng platform is the same as that on the x86 platform, use -fsigned-char to explicitly specify these characters as a signed type. |
Example code: CFLAGS=-g3 -W -Wall -m32 -m3dnow -Wno-unused-but-set-variable -O0 -DDEBUG=1 -DVERSION="$(VERSION)" -DRELEASE="$(RELEASE)" -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -mpopcnt -msse4.2 Modify it as follows: CFLAGS=-g3 -W -Wall -m32 -m3dnow -Wno-unused-but-set-variable -O0 -DDEBUG=1 -DVERSION="$(VERSION)" -DRELEASE="$(RELEASE)" -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -mpopcnt -msse4.2 -fsigned-char |
Suggestion_General |
The compilation may still succeed. However, to improve code universality and platform compatibility, it is recommended that you modify the code based on the suggestions. |
The x86 and Kunpeng platforms differ in their registers, operand order, and constraints. The code may produce errors on a Kunpeng server, so it is recommended that you modify the code accordingly. |
Example code: _asm("crc32b %1, %0" : "+r"(crc) : "rm"(v));
Modify it as follows: #if defined(__x86_64__)
_asm("crc32b %1, %0" : "+r"(crc) : "rm"(v));
#elif defined(__aarch64__)
__asm__ __volatile__("crc32cb %w[c], %w[c], %w[v]":[c]"+r"(crc):[v]"r"(value));
#endif
|