Source Code Porting
The source code porting function checks and analyzes source files written in C, C++, ASM, Fortran, Go, Java, Python, or Scala, locates the code to be ported, and provides porting guidance.
Command Function
Analyzes the portability of software written in C/C++/ASM/Fortran/Go/Java/Python/Scala on a terminal.
Important Notes
The latest function of automatic assembly translation is not available if the
If you install the tool using the RPM installation package, PATH is /usr/local/devkit. If you install the tool by decompressing the package, PATH is the decompression path.
- With Internet connection: Run bash addAsmLibraries.sh in the PATH/porting/devkitplugins/all_asm/bin directory.
- Without Internet connection: Manually create a tmp/rpm directory, save the RPM package to the PATH/porting/devkitplugins/all_asm/tmp/rpm directory, and run bash addAsmLibraries.sh in the PATH/porting/devkitplugins/all_asm/bin directory.
Syntax
1 | devkit porting src-mig [-h | --help] {-i INPUT_PATH | --input INPUT_PATH} [-b {make,cmake,automake,go,bazel,blade,other} | --build-tool {make,cmake,automake,go,bazel,blade,other}] [-c 'command' | --cmd 'command'] [-s {c|c++|asm|fortran|go|java/python/scala}* | --source-type {c|c++|asm|fortran|go|java/python/scala}*] [-t target-os | --target-os target-os] [-p compiler-version | --compiler compiler-version] [-f fortran-compiler-version | --fortran-compiler fortran-compiler-version] [-o OUTPUT_PATH | --output OUTPUT_PATH] [--set-timeout TIMEOUT] [-l {0,1,2,3} | --log-level {0,1,2,3}] [-r {all,json,html,csv} | --report-type {all,json,html,csv}] [--ignore ignore_file] [--ignore-path IGNORE_PATH] [--macro MACRO] [--keep-going {True,False}] [-np number| --number-of-progress number] [--kp-compatibility] |
Parameter Description
Parameter |
Option |
Description |
|---|---|---|
-h/--help |
- |
Obtains help information. This parameter is optional. |
-i/--input-path |
- |
Path to the source folder or package to be scanned. Use spaces to separate multiple paths. This parameter is mandatory. Example: /home/test1 /home/test2 NOTICE:
If the path to a file to be scanned contains the following architecture-related keywords (which are case-insensitive and are placed after _ or / and before /_ or .), ignore the file, for example, /home/Arm_branch/test1. PPC, PPC64, s390, s390x, powerpc, alpha, MIPS, itanium, WIN64, WIN32, BOOST_COMP_MSVC, arm, aarch64, sparc, sparc64 |
-b/--build-tool |
make/cmake/automake/go/bazel/blade/other |
Build tool, which is make by default. This parameter is optional.
|
-c/--cmd |
- |
Source code build command, which must be enclosed in single or double quotation marks. This parameter is optional. If the command contains spaces, use single quotation marks (').
|
-s/--source-type |
c/c++/asm/fortran/go/java/python/scala |
Type of the source code to be scanned, which defaults to 'c,c++,asm'. This parameter is optional. |
-t/--target-os |
See the -h help information. |
Target OS. If this parameter is not set, the current OS is used by default. This parameter is optional. |
-p/--compiler |
See the -h help information. |
Compiler version. C, C++, ASM, and Go use the same compiler version. This parameter is optional. The default value is the compiler version included in the target OS. |
-f/--fortran-compiler |
flang2.1.0/flang2.3.0/flang2.4.0/flang2.5.0/flang2.5.0.1/flang3.0.0/flang3.1.0/flang3.2.0/flang4.0.0/flang4.1.0/gfortran7/gfortran8/gfortran9 |
Fortran code compiler version, which defaults to flang2.5.0.1. This parameter is optional. |
-o/--output |
- |
Path for storing scan reports. By default, scan reports are stored in the current execution path. A report name is the format of Feature-name_Timestamp. This parameter is optional. |
--set-timeout |
- |
Timeout interval of a task, in minutes. If the execution duration exceeds the timeout interval, the task exits. This parameter is optional. By default, there is no timeout interval. The task will be executed until it is complete. |
-l/--log-level |
0/1/2/3 |
Log level, which defaults to 1. This parameter is optional.
|
-r/--report-type |
all/json/html/csv |
Scan report format, which defaults to all. This parameter is optional.
|
--ignore |
{install_path}/porting/ignore_rules.json |
This parameter is optional. You can configure the masking rule file to mask scan items that will not affect the scan result. By default, the ignore_rules.json file in the tool path is read. For details about the file format, see Masking Rule File (--ignore). |
--ignore-path |
- |
Path to the source file or folder to be masked. If there are multiple paths, separate them with spaces. This parameter is optional. Example: /home/test /home/a.cpp |
--macro |
- |
Custom x86 platform macro. This parameter is optional. Separate multiple macros with semicolons (;). |
--keep-going |
True/False |
Indicates whether to continue the scan when the keyword arm, arm64, or aarch64 is found. This parameter is optional.
|
-np/--number-of-progress |
- |
Number of concurrent source code scan processes, which defaults to 1. This parameter is optional. If the configured value exceeds the number of CPU cores on the host, it is automatically reset to the number of CPU cores. |
--kp-compatibility |
- |
This parameter is optional. If you enable this option, the tool checks only the cross-generation compatibility check of the Kunpeng platform. The target platform is the new Kunpeng 920 processor model. You are advised to enable this option after the porting from x86 to Kunpeng is complete. NOTE:
C/C++/ASM, Fortran, and Go are supported. |
Example
The following demonstrates how to analyze the TestData project code and generate analysis reports in CSV, JSON, and HTML formats. Replace /home/TestData/wtdbg2-2.5 with the actual code path to be scanned.
1 | devkit porting src-mig -i /home/TestData/wtdbg2-2.5 -c "make" |
The following information is displayed and a report is generated:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | Using the local system as target os: openeuler20.03sp1 Current progress: ################################# [100%] [Phase 3/3] Scan completed. Generating reports. Scanned time: 2025/08/11 10:57:16 Configuration: Scan code path: /home/TestData/wtdbg2-2.5/ Compiler: GCC 4.8.5 Interpreted(Python, Java, Scala): False Go: False Target OS: openeuler20.03sp1, kernel: 4.19.90 Software make command: make Source Need Migrated: Need Migrated File scan statistics: Total files: 35 Scanned 34 C/C++ files, 1 Makefile/CMakeLists.txt/Automake related files, total 3 files need to be migrated. Scanned 0 pure assembly files, 0 pure assembly files to be migrated. Scanned 0 Go files, 0 Go files to be migrated. Scanned 0 python files, 0 python files to be migrated. Scanned 0 java files, 0 java files to be migrated. Scanned 0 scala files, 0 scala files to be migrated. Scanned 0 bazel files, 0 bazel files to be migrated. Scanned 0 blade files, 0 blade files to be migrated. Dependency file statistics: Adaptable for Compatibility: 1, To be Modified: 0, Total Dependencies: 1 Source file statistics: Files to be modified: 3 Lines to be modified: 17 Total 10 rules and 6 suggestions. Estimated transplant workload: 0.1 person/months.(C/C++/Fortran/Go, 500Line/PM; ASM, 250Line/PM) For the detailed information, please check: /home/DevKit_Software/Code_Porting_20250811025716_CLwu9d_zh.json /home/DevKit_Software/Code_Porting_20250811025716_CLwu9d_zh.csv /home/DevKit_Software/Code_Porting_20250811025716_CLwu9d.html |
The analysis reports vary with the target OS because different OSs support different SO libraries.
Masking Rule File (--ignore)
You can edit the ignore_rules.json file to configure what to mask in scans. After that, masked scan items will not be displayed in scan reports. See the example configuration:
1 2 3 4 5 6 7 8 9 | { "src_list": [ "-march", "-mpopcnt", ], "lib_list": [ "libz.so.1" ] } |
- lib_list: list of dependency files to be masked.
- src_list: list of source file keywords to be masked.
Output Report
Parameter |
Description |
|---|---|
Report Generated |
Time when the report is generated. |
Configuration |
Task name, report generation time, source file storage path, target OS, target OS kernel version, compiler version, build tool, compile command, whether an interpretative language or Go language is included, and user-defined x86 macro. |
File Scan Statistics |
Number of scanned files and the number of files to be ported. |
Dependency File Statistics |
Number of architecture-related files on which the source package depends. |
Source File Statistics |
Number of files to be modified, number of code lines, total number of rule items, total number of suggestion items, and estimated manpower for source code porting. |
Architecture-related Dependencies |
Details about the dependency files related to the architecture.
|
Source File Scan Details |
Details about the source file analysis report:
|
- INVALID_CATEGORY: invalid porting option type
- INTRINSICS_INCLUDE: # intrinsics inline function in the header file
- INTRINSICS: intrinsic inline function
- COMPILER_MACRO: compiler macro
- ATTRIBUTE: compiler attribute
- COMPILER_BUILTIN: compiler built-in function
- COMPILER_OPTION: compiler option
- BUILTIN_ASSEMBLES: built-in assembly
- LIBS: dynamic link libraries
- COMPILER_OPTION_SPECIAL: special compiler option
- MODULE_FUNCTION: module function
- AARCH_SPECIFIC: specific to the AArch platform (the value of keep-going is used to determine whether to end the scan earlier than expected)
- PURE_ASSEMBLES: pure assembly file
- AUTOMAKE_FILE: Automake file
- FORTRAN_COMPILER_OPTION: GFortran compilation option
- FORTRAN_BUILTIN: Fortran built-in function
- FORTRAN_GRAMMAR: Fortran syntax
- PRECOMPILED_MACRO: precompiled macro
- PYTHON_LIBRARY: SO files detected from the Python file
- PYTHON_LOAD_LIBRARY: lines of the SO files detected from the Python file
- JAVA_LIBRARY: SO files detected from the Java file
- JAVA_LOAD_LIBRARY: lines of the SO files detected from the Java file
- SCALA_LIBRARY: SO files detected from the Scala file
- SCALA_LOAD_LIBRARY: lines of the SO files detected from the Scala file
- FORTRAN_MODULE_FILE: .mod file compiled from the Fortran module file
- MIX_FUNCTION_NOT_MATCH: mismatch between the intermodulation parameters and return values of the C and Fortran functions
- INTRINSICS_LIBRARY: SO link library of intrinsic functions added to build file prompts
- TEE_UNSUPPORTED_API: POSIX APIs not supported by TEEs
- JAVA_MATH_LIBRARY: location of the math library detected in the Java file
1 2 3 4 5 6 7 | current usage: add_library(test1 STATIC attr_gcc5.1.c builtin_gcc5.1.c ) The general signature is: add_library(<name> [STATIC | SHARED | MODULE] [EXCLUDE_FROM_ALL] [source1] [source2 ...]) For details: https://cmake.org/cmake/help/v3.13/command/add_library.html |
- current usage: function usage in the current file
- The general signature is: usage of the official general function
- For details: link to the official help document of the module function