A method, apparatus and system for compiling

By identifying target compilation files with the same version across multiple compilation files for inlining optimization, the problem of inlining optimization failure caused by compiler version inconsistencies is resolved, improving compilation flexibility and performance.

CN122111439APending Publication Date: 2026-05-29HUAWEI TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HUAWEI TECH CO LTD
Filing Date
2024-11-28
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

The compiler versions used to generate object files and binary library files are often inconsistent, leading to a discrepancy in the globally used compiler version. This makes it difficult to successfully implement inlining optimizations and affects program performance.

Method used

By obtaining multiple second-compiled files, it was determined that the version of the target second-compiled file was the same as the version of the first compiler, and inlining optimization was performed. This solved the problem of inconsistent compiler versions, improved the flexibility of compilation, and increased the success rate of inlining optimization.

Benefits of technology

It enables inlining optimization across different compiler versions, improving compilation flexibility and the success rate of inlining optimization, and avoiding performance impact caused by version inconsistencies.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122111439A_ABST
    Figure CN122111439A_ABST
Patent Text Reader

Abstract

The application relates to the computer technology field and provides a compiling method, device and system, a plurality of second compiling files are generated through a plurality of second compilers of second versions, and the subsequent inline optimization through different version compilers is facilitated. In the application, the consistency of the compiler versions used globally does not need to be ensured, the target second compiling file is determined from the generated plurality of second compiling files in the compiling process, the subsequent inline optimization of the first compiling file can be performed, the compiling flexibility is improved, and the problems that the inline optimization cannot be performed or the inline optimization exposes the function file source code when the first compiler and the second compiler are of different versions are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and more specifically to a compilation method, apparatus, and system. Background Technology

[0002] To protect the security of source code, the source code of functions, variables, classes, etc., can be released and used externally in the form of binary libraries. That is, the source code is compiled into binary library files (such as static library files) by a compiler. Then, the source files that use the source code of the functions, variables, classes, etc. are compiled into object files (such as .o files) by a compiler. Finally, the object files and binary library files are linked to obtain the required compiled files, such as computer executable files (such as exe files) and dynamic library files (such as .dll files / .so files).

[0003] However, during the execution of the compiled files (such as executable files and dynamic library files) obtained by the aforementioned methods, frequent function calls to the binary library files occur, impacting program performance. The compiler performs inlining optimization on object files and binary library files, inserting function code directly into the call points, thus eliminating the overhead of function calls. However, it is difficult to maintain consistency between the compiler versions that generate object files and binary library files; inconsistent compiler versions used globally make it difficult to successfully achieve inlining optimization. Summary of the Invention

[0004] This application provides a compilation method, apparatus, and system that can solve the problem that it is difficult to maintain consistency in the versions of compilers that generate object files and binary library files, and that it is difficult to successfully implement inlining optimization when the versions of compilers used globally are inconsistent.

[0005] Firstly, a compilation method is provided, comprising: obtaining a first compiled file, wherein the first compiled file is obtained by compiling a source file using a first compiler; obtaining multiple second compiled files, wherein the multiple second compiled files are obtained by compiling a function file using multiple versions of a second compiler, and the function file is associated with a source file; then, determining a target second compiled file from the multiple second compiled files, wherein the version of the second compiler that generated the target second compiled file is the same as the version of the first compiler; finally, performing inlining optimization based on the target second compiled file and the first compiled file to generate a target compiled file of the source file.

[0006] In this embodiment, multiple second compiled files are generated using multiple second versions of a second compiler, which facilitates subsequent inlining optimization using different compiler versions. In this application, it is not necessary to ensure that the globally used compiler version is consistent. During the compilation process, the target second compiled file is determined from the generated multiple second compiled files, allowing for subsequent inlining optimization of the first compiled file. This improves compilation flexibility and solves the problems of being unable to perform inlining optimization or exposing function file source code when the first and second compiler versions are different.

[0007] In some implementations, the first compiled file carries first version information of the first compiler, and each second compiled file carries second version information of the second compiler that generated the second compiled file; the target second compiled file is determined from the multiple second compiled files based on the first version information and the second version information.

[0008] In this embodiment, the target second compilation file used for subsequent inlining optimization of the first compilation file is determined by using the first version information carried by the first compilation file and the second version information carried by the second compilation file, thereby improving the efficiency of determining the target second compilation file.

[0009] In some implementations, the first compiled file includes target symbols; at least one candidate second compiled file including the target symbols is determined from a plurality of second compiled files. Then, a target second compiled file is determined from the at least one candidate second compiled file based on first version information and second version information.

[0010] In this embodiment, candidate second compiled files are first determined based on the target symbols. These candidate second compiled files contain information about the target symbols. The target second compiled file is then determined from these candidate second compiled files. This eliminates the need to determine the target second compiled file from all second compiled files based on both first and second version information, thus improving the efficiency of target second compiled file determination. Furthermore, it resolves the issue of mismatch between the second and first version information of the determined target second compiled file and the first version information when multiple second compiled files contain target symbols, leading to errors in subsequent inlining optimizations. This improves the accuracy of target second compiled file determination.

[0011] In some implementations, the first compiled file includes a third compiled file and a fourth compiled file. The third compiled file is obtained by compiling the main program file in the source file using the first compiler, and the fourth compiled file is obtained by compiling the subroutine files in the source file using the first compiler. First, the third and fourth compiled files are merged to obtain a preprocessed compiled file. Then, if there is a conflict between the compilation options of the third and fourth compiled files, the compilation options of the fourth compiled file are adjusted to be compatible with those of the third compiled file, resulting in an adjusted preprocessed compiled file. The compilation options indicate the compilation requirements of the compiled file. Finally, inlining optimization is performed based on the target second compiled file and the adjusted preprocessed compiled file to generate the target compiled file of the source file.

[0012] In this embodiment, by adjusting the compilation options of the fourth compilation file to be compatible with those of the third compilation file when there is a conflict between the compilation options of the third compilation file, cross-compilation file merging can be achieved, solving the problem that inlining optimization cannot succeed due to compilation option conflicts and improving the success rate of inlining optimization.

[0013] In some implementations, if the compilation options included in the first compilation file do not meet the target format requirements, a new target compilation option is added to the first compilation file, which indicates the target format requirements.

[0014] In this embodiment, by adding target compilation options to the first compilation file when the compilation options included in the first compilation file do not meet the target format requirements, the problem that the obtained target compilation file cannot be used due to the failure to meet the target format requirements is solved.

[0015] In some implementations, if the compilation options of the target second compiled file conflict with those of the first compiled file, the compilation options of the target second compiled file are adjusted to be compatible with those of the first compiled file, resulting in an adjusted target second compiled file. Then, inlining optimization is performed based on the adjusted target second compiled file and the first compiled file to generate the target compiled file of the source files.

[0016] In this embodiment, by adjusting the compilation options of the target second compiled file to be compatible with those of the first compiled file when there is a conflict between the compilation options of the target second compiled file and the compilation options of the first compiled file, the problem of inlining optimization failing due to compilation option conflicts is solved, and the success rate of inlining optimization is improved.

[0017] In some implementations, a fifth compiled file is obtained, which is a non-linked optimized compiled file obtained by compiling the function file. If the target second compiled file cannot be determined from multiple second compiled files, inlining optimization is performed based on the fifth compiled file and the first compiled file to generate the target compiled file for the source file.

[0018] In this embodiment, a fifth compiled file is also generated for the function file. The fifth compiled file is an optimized compiled file when not linked, and it includes general symbols. This allows the inlining optimization process to be executed normally without affecting the compilation process if the target second compiled file cannot be determined from multiple second compiled files.

[0019] In some implementations, a compilation prompt is generated that instructs the target compiled file to be generated based on the non-linking optimized compiled file.

[0020] In this implementation, inlining optimizations performed during non-linking are indicated by compilation prompts, so that developers are aware of them and can take appropriate action.

[0021] In some implementations, in response to a version matching operation, a target second compilation file is determined from a plurality of second compilation files.

[0022] In this implementation, version matching of the second compiled file can only be initiated through a version matching operation. That is, if there is no version matching operation, multi-version matching of the second compiled file will not be performed by default to avoid affecting other processes.

[0023] Secondly, a compilation device is provided, including a data acquisition module and a processing module.

[0024] The data acquisition module is used to acquire the first compiled file of the source file. The first compiled file is obtained by compiling the program file in the source file using the first compiler. The data acquisition module is also used to acquire multiple second compiled files of the source file. These multiple second compiled files are obtained by compiling the function files in the source file using multiple versions of the second compiler. The processing module is used to determine the target second compilation file that matches the first compilation file from multiple second compilation files, and the version of the second compiler that generates the target second compilation file is the same as the version of the first compiler; The processing module is also used to perform inlining optimization based on the target second compiled file and the first compiled file to generate the target compiled file of the source file.

[0025] In some implementations, the first compiled file carries first version information of the first compiler, and each second compiled file carries second version information of the second compiler that generated the second compiled file; the processing module is further configured to determine the target second compiled file from the multiple second compiled files based on the first version information and the second version information.

[0026] In some implementations, the first compiled file includes target symbols; the processing module is further configured to determine at least one candidate second compiled file including the target symbols from a plurality of second compiled files; and to determine the target second compiled file from at least one candidate second compiled file based on first version information and second version information.

[0027] In some implementations, the first compiled file includes a third compiled file and a fourth compiled file. The third compiled file is obtained by compiling the main program file in the source file using the first compiler, and the fourth compiled file is obtained by compiling the subroutine files in the source file using the first compiler. The processing module is also used to merge the third compiled file and the fourth compiled file to obtain a preprocessed compiled file. If there is a conflict between the compilation options of the third compiled file and the compilation options of the fourth compiled file, the compilation options of the fourth compiled file are adjusted to be compatible with the compilation options of the third compiled file to obtain an adjusted preprocessed compiled file. The compilation options indicate the compilation requirements of the compiled file. Inline optimization is performed based on the target second compiled file and the adjusted preprocessed compiled file to generate the target compiled file of the source file.

[0028] In some implementations, the processing module is further configured to add target compilation options to the first compilation file if the compilation options included in the first compilation file do not meet the target format requirements. The target compilation options indicate the target format requirements.

[0029] In some implementations, the processing module is further configured to adjust the compilation options of the target second compiled file to be compatible with the compilation options of the first compiled file when there is a conflict between the compilation options of the target second compiled file and the compilation options of the first compiled file, thereby obtaining an adjusted target second compiled file; and to perform inlining optimization based on the adjusted target second compiled file and the first compiled file to generate the target compiled file of the source file.

[0030] In some implementations, the data acquisition module is further configured to acquire a fifth compilation file, which is a non-linked optimized compilation file obtained by compiling the function file; the processing module is further configured to perform inlining optimization based on the fifth compilation file and the first compilation file to generate a target compilation file of the source file if the target second compilation file cannot be determined from multiple second compilation files.

[0031] In some implementations, the processing module is also used to generate compilation prompts that instruct the target compiled file to be generated based on the non-linking optimized compiled file.

[0032] In some implementations, the processing module is also configured to determine a target second compilation file from a plurality of second compilation files in response to a version matching operation.

[0033] Thirdly, a compilation system is provided, the system comprising at least one means for performing the compilation method as described in the first aspect.

[0034] Fourthly, a computing device is provided, comprising a processor and a memory. The processor executes instructions stored in the memory to cause the computing device to perform the compilation method as described in the first aspect.

[0035] Fifthly, a chip system is provided, comprising a processor and a power supply circuit. The power supply circuit supplies power to the processor, which executes operational steps as described in the compilation method of the first aspect.

[0036] In a sixth aspect, a computer program product containing instructions is provided, which, when executed by at least one computing device, cause the at least one computing device to perform a compilation as described in the first aspect.

[0037] Based on the embodiments provided in the above aspects, this application can be further combined to provide more embodiments.

[0038] The following description includes further details regarding the implementation methods provided in the above aspects. Attached Figure Description

[0039] Figure 1 A schematic diagram of an inline optimization is shown; Figure 2 A schematic diagram of an LTO inline optimization is shown; Figure 3 This paper illustrates a schematic diagram of the architecture of a compilation system provided in an embodiment of this application. Figure 4 A flowchart illustrating a compilation method provided in an embodiment of this application is shown; Figure 5 A flowchart illustrating another compilation method provided in an embodiment of this application is shown; Figure 6 A flowchart illustrating another compilation method provided in an embodiment of this application is shown; Figure 7 A flowchart illustrating another compilation method provided in an embodiment of this application is shown; Figure 8A schematic diagram of a static library file generation process in an embodiment of this application is shown; Figure 9 A schematic diagram of a target compilation file generation process in an embodiment of this application is shown; Figure 10 This illustration shows a schematic diagram of inlining optimization performed on the entire source code of an application in an embodiment of this application; Figure 11 This paper shows a schematic diagram of the structure of a compiler apparatus provided in an embodiment of this application; Figure 12 A schematic diagram of the structure of a computing device provided in an embodiment of this application is shown. Detailed Implementation

[0040] To facilitate understanding, the terminology used in this application will be introduced first.

[0041] Inlining optimization, also known as function inlining, refers to replacing function calls directly with the function body itself during the compilation process, thereby eliminating the overhead caused by function calls. This includes parameter passing, stack operations, saving and restoring return addresses, etc. In other words, it replaces function calls in the source file that uses the source code of the function, variable, class, etc. with the function, variable, class, etc. in the binary library itself.

[0042] Link-time optimization (LTO) is a program optimization performed during the linking process. It preserves the intermediate files (.o files) generated during compilation from various compiled files (e.g., source files) and brings them to the linking stage. The linker then merges these intermediate files into a unified program, ensuring that subsequent optimizations are performed across the entire program, rather than being limited to a single compiled file. LTO optimizations typically include inlining, loop optimization, and constant propagation. After optimization, an optimized object file is generated. This object file can be a dynamic library file (.dll / .so file), a static library file (.a file), or a computer executable file (.exe), etc.

[0043] To protect the security of source code, the source code of functions, variables, classes, etc., can be released and used externally in the form of binary libraries. That is, the source code is compiled into binary library files (such as static library files) by a compiler. Then, the source files that use the source code of the function, variable, class, etc. are compiled into object files (such as .o files) by a compiler. Then, the object files and binary library files are linked to obtain the required compiled files, such as computer executable files (such as exe files) and dynamic library files (such as .dll files / .so files).

[0044] As an example, during the development of many applications, due to the widespread use of the x86 architecture in the desktop and server fields and its relatively mature ecosystem, developers often design code based on the characteristics of the x86 platform. Then, they use acceleration libraries to optimize and adapt the code originally designed for the x86 platform, enabling it to run efficiently on new architectures (such as ARM architecture). To protect the security of the acceleration library's source code, it can be released and used as a binary library. This involves compiling the acceleration library's source code into binary library files (such as static library files) using a compiler, then compiling the source files using the acceleration library into object files (such as .o files) using the compiler, and finally linking the object files and binary library files to obtain the required compiled files, such as executable files (such as .exe files) or dynamic library files (such as .dll files / .so files).

[0045] During the execution of the compiled files (such as executable files and dynamic library files) obtained by the aforementioned methods, function calls from the binary library files will frequently occur, impacting program performance. The compiler performs inlining optimization on the object files and binary library files, directly inserting the function code from the binary library files into the corresponding call points in the object files, thus eliminating the overhead of function calls.

[0046] For example, see Figure 1 , Figure 1 A schematic diagram of an inline optimization is shown. For example... Figure 1 As shown, firstly, the source code of the acceleration library is protected and converted into a binary library. Then, the business code (such as the code for x86 open-source applications) is compiled based on the binary library. During the binary library linking stage, the business code undergoes binary library inlining optimization, including: firstly, parsing the binary library to obtain its symbol file, which contains information such as the names, types, and locations of functions and variables in the binary library; secondly, inlining optimization is performed, specifically selecting functions from multiple functions in the binary library for inlining based on selection criteria (such as function body size, call frequency, etc.) and inserting their code into the call points; finally, global optimization is performed on the code. During the runtime phase, the business code linked with the binary library is executed.

[0047] In some implementations, LTO inlining optimization differs from regular inlining optimization during the LTO compilation process.

[0048] For example, see Figure 2 , Figure 2 A schematic diagram of LTO inline optimization is shown. For example... Figure 2 As shown, LTO inlining optimization includes: modifying function files (using the LTO compiler) Figure 2 Compile the file shown in func_a.c to obtain an intermediate file ( Figure 2 The file func_a.o shown is then accessed through the library manager ( Figure 2 The ar file shown will package the intermediate files into a static library file. Figure 2 As shown in func_a.a), the source file is finally compiled using the LTO compiler, and the compiled source file is then optimized using LTO inlining based on the static library file.

[0049] However, the conditions for successfully implementing LTO inlining optimization are quite strict. If the globally used LTO compiler versions are not consistent, it is difficult to achieve successful inlining optimization. For example, the aforementioned method of inlining optimization using LTO requires that the versions of the LTO compilers used to compile function files and source files be the same. However, it is difficult to keep the versions of the compilers that generate object files and static library files consistent, which limits the scope of inlining optimization and reduces its flexibility.

[0050] This application provides a compilation method, including: obtaining a first compiled file, wherein the first compiled file is obtained by compiling a source file using a first compiler; obtaining multiple second compiled files, wherein the multiple second compiled files are obtained by compiling a function file using multiple versions of a second compiler, and the function file is associated with the source file; then, determining a target second compiled file from the multiple second compiled files, wherein the version of the second compiler that generated the target second compiled file is the same as the version of the first compiler; finally, performing inlining optimization based on the target second compiled file and the first compiled file to generate a target compiled file of the source file.

[0051] Source files refer to source program files (such as code written in assembly language or a high-level language). These can be all the program files of an application / acceleration library, or only a portion of the program files of an application / acceleration library. Both the first and second compilers are LTO compilers.

[0052] In this embodiment, the source file may refer to the main file (such as the main.c file). The association of the function file with the source file means that the function file includes information about the variables, functions, classes, and other symbols defined in the source file, and may also include the location of these symbols in the source code. The function file may refer to the func file (such as the func_a.c file), and the function file may be the source code file of the acceleration library associated with the source file.

[0053] The target compiled file can be a computer executable file (.exe), a dynamic library file (.dll / .so), etc. The resulting target compiled file in dynamic library file (.dll / .so) format can also be used as an acceleration library to speed up and migrate code.

[0054] In this embodiment, multiple second compiled files are generated using multiple second versions of a second compiler, which facilitates subsequent inlining optimization using different compiler versions. In this application, it is not necessary to ensure that the globally used compiler version is consistent. During the compilation process, the target second compiled file is determined from the generated multiple second compiled files, allowing for subsequent inlining optimization of the first compiled file. This improves compilation flexibility and solves the problems of being unable to perform inlining optimization or exposing function file source code when the first and second compiler versions are different.

[0055] Figure 3 This is a schematic diagram of the architecture of the compilation system provided in an embodiment of this application. Figure 3 As shown, the compilation system 100 includes a first computing device 110 and a second computing device 120. The first computing device 110 and the second computing device 120 are connected in communication.

[0056] The first computing device 110 is used to interact with the second computing device 120, such as sending files to the second computing device 120. The first computing device 110 includes multiple second compilers 111 ( Figure 3 Three secondary compilers and a library manager 112 are illustrated as an example. The versions of the secondary compilers are different, and all are LTO compilers with LTO functionality enabled. The version of the LTO functionality matches the version of the compiler.

[0057] Multiple second compilers 111 are used to compile function files to obtain multiple versions of LTO symbol files (such as multiple versions of second compilation files) and one non-LTO symbol file (such as the fifth compilation file). Both LTO symbol files and non-LTO symbol files are .o files.

[0058] Non-LTO symbol files can be obtained from any version of a second compiler among multiple second compilers. Non-LTO symbol files contain symbol information from function files. LTO symbol files not only contain symbol information from function files but also additional information that can be used for cross-compilation file optimization (such as the number of function calls, the size of the function body, etc.). The symbol information contained in different versions of LTO symbol files may be different.

[0059] In some implementations, multiple second compilers can be as follows: Figure 3 The diagram shows multiple second compilers in one computing device, but it can also show multiple second compilers in multiple computing devices; there is no limitation on this.

[0060] Library Manager 112 is used to compress and package multiple versions of LTO symbol files and non-LTO symbol files into static library files (.a files).

[0061] The second computing device 120 is used to receive multiple versions of LTO symbol files and non-LTO symbol files sent by the first computing device 110. The second computing device 120 includes a first compiler 121 and a linker 122. The first compiler 121 is an LTO compiler with LTO functionality enabled, used to compile source files to obtain intermediate files (.o files, such as the first compiled file), and to perform inlining optimization on the intermediate files according to the LTO symbol files or non-LTO symbol files to obtain the target compiled file.

[0062] Linker 122 is used to match LTO symbol files from multiple versions that are the same as the version of the first compiler. The LTO symbol files that the first compiler 121 optimizes by inlining the intermediate files are the LTO symbol files generated by the second compiler that are the same version as the first compiler and matched by the linker.

[0063] In some implementations, the multiple second compilers may also be compilers in different first computing devices. The non-LTO symbol files may be generated by any of the computing devices, and after obtaining the LTO symbol files and non-LTO symbol files, they are sent to the second computing devices.

[0064] It is worth noting that, Figure 3 This is merely a schematic diagram of the architecture of a compilation system provided in an embodiment of this application. Figure 3 The positional relationships between the devices, components, modules, etc. shown do not constitute any limitation.

[0065] The compilation method provided in the embodiments of this application is described in detail below. Figure 4 This is a flowchart illustrating a compilation method provided in an embodiment of this application. Figure 4 The method shown can be executed by a computing device, such as the processor of the first computing device. The method includes the following steps: S410. Obtain the first compiled file, which is obtained by compiling the source file using the first compiler.

[0066] The first compiled file is a .o file.

[0067] If the source file is divided into multiple program files (such as the main program file, subroutine files, etc.), the first compiled file also includes multiple compiled files.

[0068] S420. Obtain multiple second compilation files. These second compilation files are obtained by compiling the function file using multiple versions of the second compiler. The function file is associated with the source file.

[0069] The second compiled file is a .o file. One version of the second compiler compiles to obtain one second compiled file. There can be multiple function files. For example, if a function file does not include information about all variables, functions, classes and other symbols defined in the source file, multiple function files are needed to include information about all variables, functions, classes and other symbols defined in the source file. Correspondingly, multiple second compiled files are generated for each function file.

[0070] In some implementations, the function file can be the complete source code file of the acceleration library associated with the source file, or it can be a partial source code file of the acceleration library associated with the source file.

[0071] After compiling the function files using multiple versions of a second compiler to obtain multiple second compiled files, the library manager compresses these files into binary files in a specified order to obtain a static library file (.a file). The specified order can be based on the version of the second compiler that generated the second compiled files from high to low, low to high, or according to the frequency of use of the second compiler from high to low, low to high.

[0072] When there are multiple function files, a second compiler of a certain version will generate a second compilation file for each function file. Multiple second compilation files generated by the same compiler version can be placed in the same compilation file set, and then binary compression is performed in a specified order to obtain a static library file (.a file).

[0073] It is worth mentioning that during the compilation of function files by the second compiler, it is necessary to add compilation options (such as -flto, which enables LTO functionality, executes the output of the LTO information segment, and includes function symbols containing the compiled LTO intermediate representation information), which is beneficial for subsequent LTO inlining optimization.

[0074] Among them, multiple versions of the second compiler can be different versions of the compiler that come with the operating system that supports the acceleration library.

[0075] Correspondingly, in the process of obtaining multiple second compilation files, it is necessary to parse the static library file to obtain multiple second compilation files.

[0076] S430. Determine the target second compilation file from multiple second compilation files.

[0077] The version of the second compiler that generates the target second compiled file is the same as the version of the first compiler.

[0078] In some implementations, the compiler version includes a major version (major_version) and a minor version (minor_version). The second compiler version that generates the target second compiled file is the same as the first compiler version, meaning that both the major and minor versions of the second compiler that generates the target second compiled file are the same as those of the first compiler.

[0079] In some implementations, in response to a version matching operation, a target second compilation file is determined from a plurality of second compilation files.

[0080] The version matching operation can be either an action triggered by a staff member on the display page, or an action triggered by a staff member detecting a version matching command entered by another staff member.

[0081] Without version matching operations, normal inline optimization can be achieved through steps S450-S460.

[0082] In this implementation, version matching of the second compiled file can only be initiated through a version matching operation. That is, if there is no version matching operation, multi-version matching of the second compiled file will not be performed by default to avoid affecting other processes.

[0083] In step S430, the target second compiled file can be determined from multiple second compiled files using various feasible methods. This application provides an implementation method, which can be found in the following examples. Figure 5 And its related descriptions.

[0084] S440. Perform inlining optimization based on the target second compilation file and the first compilation file to generate the target compilation file of the source file.

[0085] The inlining optimization performed here is LTO inlining optimization, which inserts functions that are frequently called or have small function bodies in the target second compiled file from the first compiled file into the call points in the first compiled file.

[0086] In some implementations, inline optimization is performed based on the target second compiled file and the first compiled file to generate the target compiled file of the source file. This includes performing whole-program analysis (WPA) and link-time transformation (LTRANS) on the target second compiled file and the first compiled file to generate the target compiled file of the source file.

[0087] LTO inline optimization is an important part of the full-process analysis of WPA.

[0088] In this embodiment, multiple second compiled files are generated using multiple second versions of a second compiler, which facilitates subsequent inlining optimization using different compiler versions. In this application, it is not necessary to ensure that the globally used compiler version is consistent. During the compilation process, the target second compiled file is determined from the generated multiple second compiled files, allowing for subsequent inlining optimization of the first compiled file. This improves compilation flexibility and solves the problems of being unable to perform inlining optimization or exposing function file source code when the first and second compiler versions are different.

[0089] In some embodiments, the target second compiled file may not be able to be determined from multiple second compiled files. For example, there may be multiple versions of the second compiler that do not have the same version as the first compiler. In this case, inlining optimization cannot be performed based on the target second compiled file and the first compiled file to generate the target compiled file of the source file.

[0090] Thus, in some embodiments, the compilation method provided in this application may further include the following steps S450-S460 to generate a target compilation file of the source file when the target second compilation file cannot be determined from multiple second compilation files.

[0091] It should be noted that in the compilation method provided in the embodiments of this application, steps S420-S440 or steps S450-S460 can be executed optionally. Steps S450-S460 are described in detail below.

[0092] S450. Obtain the fifth compilation file, which is the non-linking optimized compilation file obtained by compiling the function file.

[0093] The number of fifth compiled files is the same as the number of function files. These fifth compiled files can be generated by any of the multiple versions of the second compiler that generated the second compiled files. The compiler generating the fifth compiled files needs to add a compilation option that outputs non-LTO symbol files (i.e., the fifth compiled files).

[0094] Similarly, the fifth compiled file is also packaged in the static library file by the library manager. During the process of parsing multiple second compiled files from the static library file, the fifth compiled file will also be parsed.

[0095] S460. Perform inlining optimization based on the fifth and first compilation files to generate the target compilation file of the source files.

[0096] The inlining optimization performed here is a normal inlining optimization, which inserts functions that are frequently called in the first compilation file or have small function bodies into the call points in the first compilation file.

[0097] During the inlining optimization process using the fifth compilation file, the method also includes: generating compilation prompts that instruct the target compilation file to be generated based on the non-linking optimized compilation file.

[0098] Compiler error messages indicate that inlining optimizations were performed outside of linking time, informing developers to be aware of these optimizations and take appropriate action.

[0099] In this embodiment, a fifth compiled file is also generated for the function file. The fifth compiled file is an optimized compiled file when not linked, and it includes general symbols. This allows the inlining optimization process to be executed normally without affecting the compilation process if the target second compiled file cannot be determined from multiple second compiled files.

[0100] The following describes in detail a method for determining a target second compiled file from a plurality of second compiled files, according to embodiments of this application. The method can be executed by a computing device, such as a processor of a second computing device 120. The method includes: determining the target second compiled file from the plurality of second compiled files based on first version information and second version information.

[0101] The first compilation file carries the first version information of the first compiler, and each second compilation file carries the second version information of the second compiler that generated the second compilation file.

[0102] The first version information includes the major version number of the first compiler (or the major version number of the first compiler's LTO) and the minor version number of the first compiler (or the minor version number of the first compiler's LTO). Usually, the major version number of the first compiler and the major version number of the first compiler's LTO are the same, and the minor version number of the first compiler and the minor version number of the first compiler's LTO are the same.

[0103] The second compiled file is an LTO symbol file, and the second version information includes the major version number and minor version number of the LTO of the second compiler that generated the second compiled file.

[0104] The target second compiled file is a second compiled file whose second version information matches the first version information, that is, a second compiled file whose major version number and minor version number both match the major version number and minor version number of the first compiled file.

[0105] The second version information here matches the first version information. If the first and second compiled files are expressed in the same way, it means that the second version information is the same as the first version information. If the first and second compiled files are expressed in different ways, it means that the second version information and the first version information have the same substantive content.

[0106] In this embodiment, the target second compilation file used for subsequent inlining optimization of the first compilation file is determined by using the first version information carried by the first compilation file and the second version information carried by the second compilation file, thereby improving the efficiency of determining the target second compilation file.

[0107] In some embodiments, the first compiled file includes target symbols. For example... Figure 5 As shown, based on the first version information and the second version information, the target second compilation files, including S510-S520, are determined from multiple second compilation files, as follows: S510. Determine at least one candidate second compilation file that includes the target symbol from among a plurality of second compilation files.

[0108] The target symbol can be a function, variable, class, etc., included in the first compiled file. There must be at least one target symbol.

[0109] S520. Based on the first version information and the second version information, determine the target second compilation file from at least one candidate second compilation file.

[0110] In practical applications, multiple second compiled files are traversed based on the target symbol. After traversing to a candidate second compiled file that includes the target symbol, if the second version information carried by the candidate second compiled file matches the first version information, the candidate second compiled file is determined to be the target second compiled file; if the second version information carried by the candidate second compiled file does not match the first version information, the traversal continues to the next second compiled file.

[0111] In this embodiment, candidate second compiled files are first determined based on the target symbols. These candidate second compiled files contain information about the target symbols. The target second compiled file is then determined from these candidate second compiled files. This eliminates the need to determine the target second compiled file from all second compiled files based on both first and second version information, thus improving the efficiency of target second compiled file determination. Furthermore, it resolves the issue of mismatch between the second and first version information of the determined target second compiled file and the first version information when multiple second compiled files contain target symbols, leading to errors in subsequent inlining optimizations. This improves the accuracy of target second compiled file determination.

[0112] The following describes in detail a method for generating a target compiled file from source files by performing inlining optimization based on a target second compiled file and a first compiled file, according to embodiments of this application.

[0113] Figure 6 This is a flowchart illustrating a method for generating source files by inlining optimization based on a target second compiled file and a first compiled file, as provided in an embodiment of this application. Figure 6The method shown can be executed by a computing device, such as the processor of a second computing device 120. The method includes the following steps: S610: Merge the third and fourth compilation files to obtain the preprocessed compilation file.

[0114] The first compilation file includes a third compilation file and a fourth compilation file. The third compilation file is obtained by compiling the main program file in the source file using the first compiler, and the fourth compilation file is obtained by compiling the subroutine files in the source file using the first compiler.

[0115] The preprocessed compilation file includes all the contents of the third and fourth compilation files.

[0116] S620. If there is a conflict between the compilation options of the third compilation file and the compilation options of the fourth compilation file, adjust the compilation options of the fourth compilation file to be compatible with the compilation options of the third compilation file to obtain the adjusted preprocessed compilation file.

[0117] Among them, compilation options indicate the compilation requirements of the compiled file and are various parameters and settings used to control the compiler's behavior. Examples include Position-Independent Code (PIC), Position Independent Executable (PIE), and CPU architecture specification (march).

[0118] Compiler option conflict refers to a situation where two or more compiler options used simultaneously during the compilation process contradict each other or are incompatible.

[0119] In some implementations, prior to S620, the method further includes: obtaining the compilation options of the third compilation file and the compilation options of the fourth compilation file, storing the obtained compilation options in a parsing candidate list, analyzing the compilation options in the parsing candidate list, and analyzing whether there are any compilation option conflicts.

[0120] Normally, there are no conflicts in the compilation options of the same compilation file. Therefore, the compilation options that conflict in the preprocessor compilation file are the compilation options of the third compilation file and the compilation options of the fourth compilation file.

[0121] In some implementations, the method further includes generating compiler option hints, which indicate that compiler options have been adjusted, and may also indicate the specific compiler option that has been adjusted and the compiler file in which the compiler option is located.

[0122] In this step, the compilation options for the third and fourth compilation files were optimized to avoid subsequent optimization failures or other runtime problems.

[0123] S630. Perform inline optimization based on the target second compilation file and the adjusted preprocessed compilation file to generate the target compilation file of the source file.

[0124] For a detailed description of S630, please refer to the detailed description of S440, which will not be repeated here.

[0125] In this embodiment, by adjusting the compilation options of the fourth compilation file to be compatible with those of the third compilation file when there is a conflict between the compilation options of the third compilation file, cross-compilation file merging can be achieved, solving the problem that inlining optimization cannot succeed due to compilation option conflicts and improving the success rate of inlining optimization.

[0126] In some embodiments, the method further includes: if the compilation options included in the first compilation file do not meet the target format requirements, adding a target compilation option to the first compilation file, wherein the target compilation option indicates the target format requirements.

[0127] The target format requirement can be either the format requirement of the generated target compiled file or the requirement for using the target compiled file in subsequent processes.

[0128] For example, if the generated target compiled file is a dynamic library file, and the target format of the dynamic library file requires that the code location is independent, then the target compilation option is PIC. If the first compiled file and other compiled files included in the first compiled file (the third compiled file and / or the fourth compiled file) do not contain PIC, then the target compilation option PIC is added.

[0129] In some implementations, the method further includes: generating a new compilation option prompt message, which indicates that a new compilation option has been added, and may also indicate the specific new compilation option.

[0130] In this embodiment, by adding target compilation options to the first compilation file when the compilation options included in the first compilation file do not meet the target format requirements, the problem that the obtained target compilation file cannot be used due to the failure to meet the target format requirements is solved.

[0131] The following describes in detail another method for generating a target compiled file of source files by inlining optimization based on a target second compiled file and a first compiled file, provided by embodiments of this application.

[0132] Figure 7 This is a flowchart illustrating another method for generating source files by inlining optimization based on a target second compiled file and a first compiled file, provided in an embodiment of this application. Figure 7The method shown can be executed by a computing device, such as the processor of a second computing device 120. The method includes the following steps: S710. If there is a conflict between the compilation options of the target second compilation file and the compilation options of the first compilation file, adjust the compilation options of the target second compilation file to be compatible with the compilation options of the first compilation file to obtain the adjusted target second compilation file.

[0133] For example, if the target second compilation file uses a different March than the first compilation file, adjust the March used in the target second compilation file to be compatible with the March used in the first compilation file.

[0134] Similarly, compiler option hints can also be generated during this process.

[0135] In this step, the compilation options of the target second compilation file and the first compilation file are optimized to avoid subsequent optimization failures or other runtime problems.

[0136] S720. Perform inlining optimization based on the adjusted target second compilation file and the first compilation file to generate the target compilation file of the source file.

[0137] For a detailed description of S720, please refer to the detailed description of S440, which will not be repeated here.

[0138] In this embodiment, by adjusting the compilation options of the target second compiled file to be compatible with those of the first compiled file when there is a conflict between the compilation options of the target second compiled file and the compilation options of the first compiled file, the problem of inlining optimization failing due to compilation option conflicts is solved, and the success rate of inlining optimization is improved.

[0139] Based on the embodiments provided in the above aspects, this application can be further combined to provide more implementation methods.

[0140] For example, by combining S610-S630 and S710-S720, if there are conflicts between the compilation options of the target second compiled file, the compilation options of the third compiled file, and the compilation options of the fourth compiled file, the compilation options of the target second compiled file and the compilation options of the fourth compiled file are adjusted to be compatible with the compilation options of the third compiled file, resulting in the adjusted target second compiled file and the adjusted preprocessed compiled file.

[0141] Please see Figure 8 , Figure 8 This is a schematic diagram of the static library file generation process.

[0142] like Figure 8As shown, first, the function file (func_a.c) is imported into multiple secondary compilers (multiple versions of the LTO compiler). Figure 8 The example shows three LTO compilers: LTO Compiler 1.0, LTO Compiler 2.0, and LTO Compiler 3.0, from which multiple second compiled files are obtained. Figure 8 func_a_v1.o, func_a_v2.o and func_a_v3.o in .

[0143] Next, import multiple second-compiled files into the library manager ( Figure 8 LTO-ar), to obtain the static library file ( Figure 8 (func_a.a in the text).

[0144] Please see Figure 9 , Figure 9 This is a schematic diagram of the process of generating a target compilation file.

[0145] like Figure 9 As shown, firstly, Figure 8 The obtained static library file (e.g.) Figure 9 (func_a.a in the file) and source files (e.g. Figure 9 Input the main.c file into the first compiler (e.g., in the main.c file) Figure 9 In GCC versions 7.3 / 10.3 / 12.3, after the compiler compiles the source files to obtain the first compiled file, the compiler performs linking with the linker.

[0146] Then, the LTO plugin in the first compiler performs the following steps: First, it loads and registers the LTO and the linker. Then, the LTO plugin processes the declaration file, including multi-version symbol resolution and symbol information verification.

[0147] During the multi-version symbol resolution process, the first version information of the first compiler is obtained, and the second version information of the candidate second compilation file input by the linker is obtained. If the second version information matches the first version information, the candidate second compilation file is selected as the target compilation file, and an instruction is sent to the linker to indicate that no further input of candidate second compilation files is performed. Then, during the symbol information confirmation process, the symbol information included in the target second compilation file is confirmed.

[0148] Subsequently, the LTO plugin reads the symbol information corresponding to the target symbols in the first compilation file from the target second compilation file. This can be to read the symbol information of all target symbols, or to read the symbol information of target symbols that meet the filtering conditions. This is beneficial for subsequent LTO inlining optimization that can be performed directly based on the symbol information corresponding to the target symbols in the target second compilation file.

[0149] Next, cross-module option optimization is performed on the target second and first compiled files. This optimization includes the following steps: identifying compilation options in each compiled file, performing conflict analysis on each option, and then handling the conflicting options for compatibility. The process of handling conflicting compilation options for compatibility is shown in steps S610-S630 and S710-S720.

[0150] Finally, the compiled file obtained by cross-module option optimization is subjected to full program analysis (WPA) and optimized execution (LTRANS) to obtain the target compiled file.

[0151] LTO inline optimization is an important part of the full-process analysis of WPA.

[0152] Please see Figure 10 , Figure 10 This diagram illustrates the inlining optimization of the entire source code of an application. Figure 10 Zhongyu Figure 9 The same parts (such as the processing of the first compiler) will not be described in detail here.

[0153] The entire source code of an application can be divided into main_1.c, main_2.c, and main3.c, which require inlining optimization, and main_4.c, which does not require inlining optimization. Main_1.c is the main program file, while main_2.c, main3.c, and main_4.c are subroutine files. main_1.c, main_2.c, and main3.c are merged in the first compiler iteration and based on the static library file (...). Figure 10 The LTO symbol file optimization included in func_a.a is used to obtain the initial target compiled file output by the first compiler. Then, the initial target compiled file is compared with the compiled file obtained by non-LTO compilation of main_4.c using a third compiler. Figure 10 Link the ordinary compiled files in the application to obtain the final target compiled file of the application.

[0154] The third compiler can be an LTO compiler that does not enable LTO functionality, or a compiler that does not have LTO functionality.

[0155] In other words, for the entire source code of an application or an acceleration library, a compilation method provided in this application embodiment can be used to perform partial compilation to obtain a partial target compilation file, which is then linked with a compilation file obtained by non-LTO compilation of another part of the source code to obtain the target compilation file of the application or acceleration library.

[0156] Alternatively, a compilation method provided in the embodiments of this application can be used to perform global compilation to obtain the target compiled file of the application or acceleration library.

[0157] The above text combines Figures 4 to 10 The compilation method provided according to the embodiments of this application is described in detail below. Figure 11 This application describes the compilation apparatus provided according to this application. These apparatuses can be used to implement the functions of the processor in the above method embodiments, and thus can also achieve the beneficial effects of the above method embodiments.

[0158] like Figure 11 As shown, the compilation device includes a data acquisition module 1110 and a processing module 1120.

[0159] The data acquisition module 1110 is used to acquire the first compiled file of the source file, which is obtained by compiling the program file in the source file using the first compiler.

[0160] For a more detailed description of the step / process implemented by the data acquisition module 1110, please refer to [link to relevant documentation]. Figure 4 S410 and related descriptions.

[0161] The data acquisition module 1110 is also used to acquire multiple second compiled files of the source file, which are obtained by compiling the function files in the source file using multiple versions of the second compiler.

[0162] For a more detailed description of the step / process implemented by the data acquisition module 1110, please refer to [link to relevant documentation]. Figure 4 S420 and related descriptions.

[0163] Processing module 1120 is used to determine a target second compilation file that matches the first compilation file from multiple second compilation files, wherein the version of the second compiler that generates the target second compilation file is the same as the version of the first compiler.

[0164] For a more detailed description of the step / process implemented by processing module 1120, please refer to [link to relevant documentation]. Figure 4 S430 and related descriptions.

[0165] The processing module 1120 is also used to perform inlining optimization based on the target second compilation file and the first compilation file to generate the target compilation file of the source file.

[0166] For a more detailed description of the step / process implemented by processing module 1120, please refer to [link to relevant documentation]. Figure 4 S440 and related descriptions.

[0167] In some implementations, the first compiled file carries first version information of the first compiler, and each second compiled file carries second version information of the second compiler that generated the second compiled file; the processing module 1120 is further configured to determine the target second compiled file from the plurality of second compiled files based on the first version information and the second version information.

[0168] In some implementations, the first compiled file includes target symbols; the processing module 1120 is further configured to determine at least one candidate second compiled file including target symbols from a plurality of second compiled files; and to determine a target second compiled file from at least one candidate second compiled file based on first version information and second version information.

[0169] For a more detailed description of the step / process implemented by processing module 1120, please refer to [link to relevant documentation]. Figure 5 S510-S520 and related descriptions.

[0170] In some implementations, the first compiled file includes a third compiled file and a fourth compiled file. The third compiled file is obtained by compiling the main program file in the source file using the first compiler, and the fourth compiled file is obtained by compiling the subroutine files in the source file using the first compiler. The processing module 1120 is also used to merge the third compiled file and the fourth compiled file to obtain a preprocessed compiled file. If there is a conflict between the compilation options of the third compiled file and the compilation options of the fourth compiled file, the compilation options of the fourth compiled file are adjusted to be compatible with the compilation options of the third compiled file to obtain an adjusted preprocessed compiled file. The compilation options indicate the compilation requirements of the compiled file. Inline optimization is performed based on the target second compiled file and the adjusted preprocessed compiled file to generate the target compiled file of the source file.

[0171] For a more detailed description of the step / process implemented by processing module 1120, please refer to [link to relevant documentation]. Figure 6 S610-S630 and related descriptions.

[0172] In some implementations, the processing module 1120 is further configured to add target compilation options to the first compilation file if the compilation options included in the first compilation file do not meet the target format requirements. The target compilation options indicate the target format requirements.

[0173] In some implementations, the processing module 1120 is further configured to adjust the compilation options of the target second compiled file to be compatible with the compilation options of the first compiled file when there is a conflict between the compilation options of the target second compiled file and the compilation options of the first compiled file, thereby obtaining an adjusted target second compiled file; and to perform inlining optimization based on the adjusted target second compiled file and the first compiled file to generate a target compiled file of the source file.

[0174] For a more detailed description of the step / process implemented by processing module 1120, please refer to [link to relevant documentation]. Figure 7 S710-S720 and related descriptions.

[0175] In some implementations, the data acquisition module 1110 is further configured to acquire a fifth compilation file, which is a non-linked time-optimized compilation file obtained by compiling the function file; the processing module 1120 is further configured to perform inlining optimization based on the fifth compilation file and the first compilation file to generate a target compilation file of the source file if the target second compilation file cannot be determined from multiple second compilation files.

[0176] For a more detailed description of the step / process implemented by the data acquisition module 1110, please refer to [link to relevant documentation]. Figure 4 For a more detailed description of S450 and related components, and of the step / process implemented by processing module 1120, please refer to [link to relevant documentation]. Figure 4 S460 and related descriptions.

[0177] In some implementations, the processing module 1120 is also used to generate compilation prompts that instruct the target compiled file to be generated based on the non-linking optimized compiled file.

[0178] In some implementations, the processing module 1120 is also configured to determine a target second compilation file from a plurality of second compilation files in response to a version matching operation.

[0179] The devices can be implemented in software or in hardware. For example, the implementation of a compiler device will be described below.

[0180] As an example of a software functional unit, a module can include code running on a computing instance. This computing instance can be at least one of a physical host (computing device), a virtual machine, a container, or other computing devices. Furthermore, the aforementioned computing device can be one or more. For example, the compilation device can include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers used to run the application can be distributed within the same region or in different regions. The multiple hosts / virtual machines / containers used to run the code can be distributed within the same Availability Zone (AZ) or in different AZs, each AZ including one or more geographically proximate data centers. Typically, a region can include multiple AZs.

[0181] Similarly, multiple hosts / virtual machines / containers used to run this code can be distributed within the same VPC or across multiple VPCs. Typically, a VPC is set up within a single region. Communication between two VPCs within the same region, and between VPCs in different regions, requires a communication gateway to be set up within each VPC to enable interconnection between VPCs.

[0182] As an example of a hardware functional unit, a compilation device can include at least one computing device, such as a server. Alternatively, the compilation device can also be a device implemented using an ASIC or a PLD. The aforementioned PLD can be implemented using a CPLD, FPGA, GAL, or any combination thereof.

[0183] The compilation unit includes multiple computing devices that can be distributed within the same region or in different regions. Similarly, the compilation unit includes multiple computing devices that can be distributed within the same Availability Zone (AZ) or in different AZs. Likewise, the YY unit includes multiple computing devices that can be distributed within the same Virtual Private Cloud (VPC) or multiple VPCs. These multiple computing devices can be any combination of computing devices such as servers, ASICs, PLDs, CPLDs, FPGAs, and GALs.

[0184] This application also provides a computing device 1200. For example... Figure 12 As shown, the computing device 1200 includes a bus 1202, a processor 1204, a memory 1206, and a communication interface 1208. The processor 1204, the memory 1206, and the communication interface 1208 communicate with each other via the bus 1202. The computing device 1200 can be a server or a terminal device. It should be understood that this application does not limit the number of processors and memories in the computing device 1200. Optionally, the processor 1204 of the computing device 1200 can be connected to a display or input device via the communication interface 1208.

[0185] Bus 1202 can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of representation, Figure 12 The bus 1202 may be represented by a single line, but this does not mean that there is only one bus or one type of bus. The bus 1202 may include a path for transmitting information between various components of the computing device 1200 (e.g., memory 1206, processor 1204, communication interface 1208).

[0186] Processor 1204 may include any one or more processors such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP). In this embodiment, processor 1204 is used to execute the embodiments of this application. Figures 4 to 10 The steps or operations of the provided compilation method.

[0187] The memory 1206 may include volatile memory, such as random access memory (RAM). The processor 1204 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state drive (SSD).

[0188] The memory 1206 stores executable program code, and the processor 1204 executes the executable program code to implement the aforementioned data acquisition module 1110 and processing module 1120, thereby realizing the embodiments of this application. Figures 4 to 10 The provided compilation method. That is, the memory 1206 stores the compilation method for executing the embodiments of this application. Figures 4 to 10 The instructions provided for the compilation method.

[0189] The communication interface 1208 uses transceiver modules such as, but not limited to, network interface cards and transceivers to enable communication between the computing device 1200 and other devices or communication networks.

[0190] The display can include various display devices capable of display functions, such as plasma displays and liquid crystal displays. The computing device 1200 can realize data display functions through the display.

[0191] Input devices can include various input devices such as keyboards, mice, and touch screens that enable user input.

[0192] This application also provides a chip system. The chip system may include a processor and a power supply circuit. The power supply circuit supplies power to the processor, which executes the embodiments of this application. Figures 4 to 10 The steps or operations of the provided compilation method.

[0193] This application also provides a computer program product containing instructions. The computer program product may be a software or program product containing instructions, capable of running on a computing device or stored on any usable medium. When the computer program product is run on at least one computing device, it causes the at least one computing device to execute the embodiments of this application. Figures 4 to 10 The steps or operations of the provided compilation method, for example, are used to execute embodiments of this application. Figures 4 to 10 The instructions provided for the compilation method.

[0194] This application also provides a computer-readable storage medium. The computer-readable storage medium can be any usable medium that a computing device can store, or a data storage device such as a data center containing one or more usable media. The usable medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive). The computer-readable storage medium includes instructions that instruct the computing device to execute embodiments of this application. Figures 4 to 10 The steps or operations of the provided compilation method, for example, are used to execute embodiments of this application. Figures 4 to 10 The instructions for the steps or operations of the provided compilation method.

[0195] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the protection scope of the technical solutions of the embodiments of this application.

[0196] The terms "first," "second," "third," and "fourth," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish different objects, not to define a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or apparatuses.

[0197] In the embodiments of this application, the terms "exemplary" or "for example" are used to indicate that something is an example, illustration, or description. Any embodiment or design that is described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design. Specifically, the use of the terms "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.

[0198] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a mutually exclusive, independent, or alternative embodiment. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.

Claims

1. A compilation method, characterized in that, include: Obtain the first compiled file, which is obtained by compiling the source file using the first compiler; Obtain multiple second compiled files, which are obtained by compiling function files using multiple versions of a second compiler, and the function files are associated with the source files; A target second compilation file is determined from the plurality of second compilation files, wherein the version of the second compiler that generates the target second compilation file is the same as the version of the first compiler; Inline optimization is performed based on the target second compiled file and the first compiled file to generate the target compiled file of the source file.

2. The method according to claim 1, characterized in that, The first compiled file carries the first version information of the first compiler, and each second compiled file carries the second version information of the second compiler that generated the second compiled file; The step of determining the target second compilation file from the plurality of second compilation files includes: The target second compilation file is determined from the plurality of second compilation files based on the first version information and the second version information.

3. The method according to claim 2, characterized in that, The first compiled file includes target symbols; The step of determining the target second compiled file from the plurality of second compiled files based on the first version information and the second version information includes: From the plurality of second compilation files, at least one candidate second compilation file including the target symbol is determined; Based on the first version information and the second version information, the target second compilation file is determined from the at least one candidate second compilation file.

4. The method according to any one of claims 1-3, characterized in that, The first compiled file includes a third compiled file and a fourth compiled file. The third compiled file is obtained by compiling the main program file in the source file using the first compiler, and the fourth compiled file is obtained by compiling the subroutine file in the source file using the first compiler. The step of performing inlining optimization based on the target second compiled file and the first compiled file to generate the target compiled file of the source file includes: The third and fourth compiled files are merged to obtain a preprocessed compiled file; If there is a conflict between the compilation options of the third compiled file and the compilation options of the fourth compiled file, the compilation options of the fourth compiled file are adjusted to be compatible with the compilation options of the third compiled file to obtain an adjusted preprocessed compiled file; wherein, the compilation options indicate the compilation requirements of the compiled file; Inline optimization is performed based on the target second compiled file and the adjusted preprocessed compiled file to generate the target compiled file of the source file.

5. The method according to any one of claims 1-4, characterized in that, The method also includes: If the compilation options included in the first compilation file do not meet the target format requirements, a new target compilation option is added to the first compilation file, and the target compilation option indicates the target format requirements.

6. The method according to any one of claims 1-5, characterized in that, The step of performing inlining optimization based on the target second compiled file and the first compiled file to generate the target compiled file of the source file includes: If the compilation options of the target second compiled file conflict with the compilation options of the first compiled file, the compilation options of the target second compiled file are adjusted to be compatible with the compilation options of the first compiled file to obtain the adjusted target second compiled file; Based on the adjusted target second compiled file and the first compiled file, inline optimization is performed to generate the target compiled file of the source file.

7. The method according to any one of claims 1-6, characterized in that, The method also includes: Obtain the fifth compilation file, which is the non-linked optimized compilation file obtained by compiling the function file; If the target second compilation file cannot be determined from the plurality of second compilation files, inline optimization is performed based on the fifth compilation file and the first compilation file to generate the target compilation file of the source file.

8. The method according to claim 7, characterized in that, The method also includes: Generate compilation prompts that instruct the target compiled file to be generated based on the non-linking optimized compiled file.

9. The method according to any one of claims 1-8, characterized in that, Determining the target second compilation file from the plurality of second compilation files includes: In response to the version matching operation, a target second compilation file is determined from the plurality of second compilation files.

10. A compilation apparatus, characterized in that, The device includes a data acquisition module and a processing module: The data acquisition module is used to acquire a first compiled file, which is obtained by compiling a source file using a first compiler; The data acquisition module is also used to acquire multiple second compiled files, which are obtained by compiling function files using multiple versions of a second compiler, and the function files are associated with the source file; The processing module is configured to determine a target second compilation file from the plurality of second compilation files, wherein the version of the second compiler that generates the target second compilation file is the same as the version of the first compiler; The processing module is further configured to perform inline optimization based on the target second compiled file and the first compiled file to generate the target compiled file of the source file.

11. A compilation system, characterized in that, The system includes at least one means for performing the method as described in any one of claims 1-9.

12. A computing device, characterized in that, The computing device includes a processor and a memory; the processor is configured to execute instructions stored in the memory to cause the computing device to perform the method as described in any one of claims 1-9.

13. A chip system, characterized in that, The chip system includes a processor and a power supply circuit, the power supply circuit being used to supply power to the processor, and the processor being used to perform the operational steps of the method as described in any one of claims 1-9.

14. A computer program product containing instructions, characterized in that, When the instruction is executed by at least one computing device, it causes the at least one computing device to perform the method as described in any one of claims 1-9.