Compiler integration method, electronic device, storage medium, and program product

CN122795366APending Publication Date: 2026-09-22SHANGHAI BIREN TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610829667.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-06-09
Publication Date
2026-09-22

AI Technical Summary

Technical Problem

[0003]目前,跨平台的构建系统生成器能够提供对于多种编程语言的支持,但在支持新增的编程语言的编译器时,存在手动配置复杂度高、跨平台支持不足以及编译链接流程不统一等诸多缺陷

Benefits of technology

[0014]本发明还提供一种计算机程序产品,包括计算机程序,所述计算机程序被处理器执行时实现如上述任一种所述编译器集成方法。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122795366A_ABST
    Figure CN122795366A_ABST
Patent Text Reader

Abstract

The application relates to the technical field of high-performance computing, and provides a compiler integration method, an electronic device, a storage medium and a program product, the method comprising the following steps: based on at least one of a buffer variable, an environment variable and a compiler search path, locating a compiler path of a compiler; based on the compiler path, performing compiler information query to obtain configuration information of the compiler; filling the compiler path and the configuration information into a parameterized configuration template to obtain an integrated configuration file of the compiler, and the parameterized configuration template comprises a platform-independent build command structure for different target file types. The method, the electronic device, the storage medium and the program product provided by the application do not need complicated manual configuration, ignore programming language and platform differences, greatly reduce the threshold and configuration complexity of multi-platform adaptation by applying the platform-independent parameterized configuration template, improve the flexible expansibility of a build system, and maintain the consistency of a compilation and linking process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of high-performance computing technology, and in particular to a compiler integration method, electronic device, storage medium, and program product. Background Technology

[0002] In order to build and deploy applications on heterogeneous computing systems, the build system needs to support the compilation and linking of multiple programming languages.

[0003] Currently, cross-platform build system generators can provide support for multiple programming languages, but when supporting compilers for new programming languages, there are many drawbacks, such as high complexity of manual configuration, insufficient cross-platform support, and inconsistent compilation and linking processes. Summary of the Invention

[0004] This invention provides a compiler integration method, electronic device, storage medium, and program product to address the shortcomings of related technologies in building system generators when supporting compilers for new programming languages.

[0005] This invention provides a compiler integration method, comprising: The compiler path is located based on at least one of the following: buffer variables, environment variables, and compiler search paths. Based on the compiler path, perform a compiler information query to obtain the compiler's configuration information; The compiler path and configuration information are filled into the parameterized configuration template to obtain the compiler's integrated configuration file. The parameterized configuration template includes a build command structure that is platform-independent and targets different target file types.

[0006] According to a compiler integration method provided by the present invention, locating the compiler path based on at least one of buffer variables, environment variables, and compiler search paths includes: If a specified compiler path exists in the buffer variable, the specified compiler path is determined to be the compiler path of the specified compiler. If the buffer variable does not specify a compiler path and the environment variable is not empty, the compiler path of the compiler is determined based on the environment variable. If the buffer variable does not specify a compiler path and the environment variable is empty, the compiler path of the compiler is searched based on the compiler search path.

[0007] According to a compiler integration method provided by the present invention, the step of querying compiler information based on the compiler path to obtain the compiler configuration information includes at least one of the following: Execute a version query command based on the compiler path to obtain the compiler's vendor information, and add the vendor information to the configuration information; Compiler identifier detection is performed based on the compiler path to obtain the compiler's identifier information, and the identifier information is added to the configuration information; The application binary interface is detected based on the compiler path to obtain the application binary interface information of the compiler, and the application binary interface information is added to the configuration information.

[0008] The compiler integration method provided by the present invention further includes: A device architecture detection program is generated, which is used to call the application interface to detect the device's architecture information during device runtime; The device architecture detection program is run based on the compiler path to obtain architecture information; Based on the architecture information, the compiler's compilation parameters are adjusted.

[0009] According to a compiler integration method provided by the present invention, the architecture information includes the major version number and minor version number of each device.

[0010] The compiler integration method provided by the present invention further includes: The compiler is subjected to compilation feature detection to obtain the programming language standards supported by the compiler; The integration configuration file is optimized based on the programming language standards supported by the compiler.

[0011] According to a compiler integration method provided by the present invention, the build environment configuration parameters in the integration configuration file are determined based on the type of operating system running the compiler.

[0012] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the program, implements the compiler integration method described above.

[0013] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the compiler integration method as described above.

[0014] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements any of the compiler integration methods described above.

[0015] The compiler integration method, electronic device, storage medium, and program product provided by this invention locate the compiler path through at least one of buffer variables, environment variables, and compiler search paths, and automatically query configuration information based on this. Then, the compiler path and configuration information are populated into a platform-independent parameterized configuration template that supports multiple types of object files, achieving automated integration of compilers for newly added programming languages. This compiler integration method eliminates the need for cumbersome manual configuration, ignores differences in programming languages ​​and platforms, and significantly reduces the threshold and configuration complexity for multi-platform adaptation by applying a platform-independent parameterized configuration template. It also improves the flexibility and scalability of the build system and maintains the consistency of the compilation and linking process. Attached Figure Description

[0016] To more clearly illustrate the technical solutions in this invention or related technologies, the accompanying drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0017] Figure 1 This is a flowchart illustrating the compiler integration method provided by the present invention.

[0018] Figure 2 This is a flowchart illustrating the compiler detection method provided by the present invention.

[0019] Figure 3 This is a flowchart illustrating the device architecture detection method provided by the present invention.

[0020] Figure 4 This is a schematic diagram of the compiler integration system provided by the present invention.

[0021] Figure 5 This is a schematic diagram of the compiler integration device provided by the present invention.

[0022] Figure 6 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation

[0023] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0024] All actions involving the acquisition of signal information or data in this invention are carried out in compliance with the relevant data protection laws and policies of the country where the device is located, and with the authorization granted by the owner of the device.

[0025] A heterogeneous computing system refers to a system containing different computing units. These different computing units can be of different types, different manufacturers of the same type, or different models of the same type and manufacturer. Specifically, the computing units included in a heterogeneous computing system can include one or more of the following: CPU (Central Processing Unit), GPU (Graphics Processing Unit), TPU (Tensor Processing Unit), NPU (Neural Network Processing Unit), DPU (Deep Learning Processing Unit), APU (Accelerated Processing Unit), and GPGPU (General-Purpose computing on Graphics Processing Unit). This embodiment of the invention does not impose specific limitations on this.

[0026] In heterogeneous computing systems, different computing units often require different programming languages ​​and compilers. For example, GPUs from vendor A might use C or C++, while GPUs from vendor B might use HIP (High Performance) or OpenCL (Open Computing Language). To build and deploy applications on heterogeneous computing systems, the build system needs to support the compilation and linking of multiple programming languages. Here, a build system refers to a software tool that automatically converts source code into executable programs, library files, or other final artifacts. A build system generator is an abstract tool built on top of the build system, specifically designed to solve cross-platform project management and configuration file generation. Typically, the build system generator first configures the platform environment, and then the build system performs the actual compilation.

[0027] Currently, cross-platform build system generators are widely used for project build management in C or C++ languages. Taking CMake (cross-platform make, describing installations for all platforms) as an example, such build system generators typically support multiple programming languages, including C, C++, Fortran (Formula Translator), and HIP, through a modular design. Each programming language is supported through a set of CMake module files, which are responsible for detecting the compiler, configuring compilation parameters, and managing the compilation and linking processes.

[0028] Although current build system generators can provide support for multiple programming languages, the following problems still exist when supporting new programming languages: First, manual configuration is highly complex. When supporting a new programming language, developers need to manually create or modify a large number of CMake module files. Since each CMake module file must strictly adhere to format specifications, manual configuration has a high probability of errors and high maintenance costs.

[0029] Secondly, cross-platform support is insufficient. Due to differences in compiler and linker parameters across different operating systems, current build system generators need to write specific code for each platform to handle these differences, lacking a unified abstraction layer to achieve platform-independent build configurations.

[0030] Furthermore, the compilation and linking processes are inconsistent. For heterogeneous programming languages, host code and device code typically need to be compiled separately for each language before linking. Current build system generators implement compilation and linking processes differently for different languages, lacking a unified interface abstraction, which leads to the complexity of multi-language mixed programming.

[0031] In response, this invention provides a compiler integration method that aims to solve the technical problems of high manual configuration complexity, insufficient cross-platform support, and inconsistent compilation and linking processes when supporting new heterogeneous programming languages. It achieves automated, standardized, and rapid integration of compilers for new languages, reduces configuration complexity, and provides a platform-independent unified compilation and linking process interface.

[0032] Figure 1 This is a flowchart illustrating the compiler integration method provided by the present invention, as shown below. Figure 1 As shown, this method is applied to a build system generator. The execution entity of the compiler integration method provided by this invention can be the build system generator itself, or a module built into the build system generator. The method includes: Step 110: Locate the compiler path based on at least one of the following: buffer variables, environment variables, and compiler search paths.

[0033] Specifically, buffered variables are variables stored in a buffer, which developers can manually modify to force intervention or specify configuration behavior for the compiler; environment variables are global variables set at the system level, reflecting information about the compiler to be integrated, such as the compiler path or executable file name. The compiler search path refers to a pre-defined directory for searching the compiler's executable files, or a pre-defined list of default installation directories for the programming language corresponding to the compiler.

[0034] In this embodiment of the invention, to achieve automated compiler identification, the specific location of the compiler to be integrated, i.e., the compiler path, can be found based on at least one of buffer variables, environment variables, and compiler search paths. It is understood that the compiler path refers to the location where the executable file of the compiler to be integrated is stored, and can specifically be an absolute path or a relative path.

[0035] For example, the compiler can be located directly by the path string manually entered by the user in the buffer variable; or the compiler can be located by reading environment variables; or the compiler can be located by traversing a preset compiler search path. This embodiment of the invention does not specifically limit the scope of the invention.

[0036] Step 120: Based on the compiler path, perform a compiler information query to obtain the compiler configuration information.

[0037] Here, configuration information refers to compiler-related information required by the build system when organizing compilation and linking tasks. This may include, for example, compiler vendor information, version number, supported programming languages, compiler identifier, etc.

[0038] After determining the compiler path, the corresponding compiler can be invoked based on that path, thereby enabling information retrieval for that compiler. For example, specific query parameters can be input into the executable file corresponding to that compiler path, or a specific detection program can be executed to obtain the output information of the compiler's executable file. Furthermore, by parsing the output information, the compiler's configuration information can be obtained.

[0039] Step 130: Fill the compiler path and the configuration information into the parameterized configuration template to obtain the compiler's integrated configuration file. The parameterized configuration template includes a build command structure for different target file types and is platform-independent.

[0040] Here, a parameterized configuration template refers to a predefined template file. The parameterized configuration template contains the build command structure, which refers to the command-line syntax framework followed when performing compilation, linking, and other actions at the underlying level. For example, the build command structure may include the command-line framework for object file compilation commands, the command-line framework for executable file linking commands, and the command-line framework for dynamic library creation commands.

[0041] The platform refers to the operating system or underlying hardware and software environment on which the compiler to be integrated runs. For example, different platforms may correspond to different operating system types, such as Windows, Linux, and macOS.

[0042] To improve the cross-platform support capability of the build system generator—that is, its ability to integrate compilers running on different platforms—this embodiment of the invention parameterizes and abstracts the variables in the compilation and linking commands for different target file types, resulting in a build command structure that includes the target file type. Here, the target file type can include object files, dynamic libraries, static libraries, executable files, etc. The parameterized and abstracted variables in the compilation and linking commands for different target file types can include configuration information such as compiler path, source file name, target file name, and vendor version number.

[0043] Therefore, the parameterized configuration template obtained by parameterizing the variables in the command decouples the command itself from the specific runtime environment. The differences in file extensions, link library formats and compiler identifiers that may exist when running on different platforms are also eliminated because the variables are parameterized and abstracted. Thus, the parameterized configuration template realizes the platform-independent abstraction of compilation options and can be regarded as a unified interface abstraction across platforms.

[0044] After obtaining the compiler path and configuration information, these can be populated into the parameterized configuration template to obtain the integrated configuration file for the compiler. This integrated configuration file can include compiler information files, language information files, and other low-level compiler-oriented configuration files, which can be directly loaded and applied by the build system to drive the actual compilation task.

[0045] In the method provided in this embodiment of the invention, the compiler path is located using at least one of buffer variables, environment variables, and compiler search paths. Based on this, configuration information is automatically queried. Then, the compiler path and configuration information are populated into a platform-independent parameterized configuration template that supports multiple types of object files, thus achieving automated integration of compilers for newly added programming languages. This compiler integration method eliminates the need for cumbersome manual configuration, ignores differences in programming languages ​​and platforms, and significantly reduces the threshold and configuration complexity for multi-platform adaptation by applying a platform-independent parameterized configuration template. It also improves the flexibility and scalability of the build system and maintains the consistency of the compilation and linking process.

[0046] Based on the above embodiments, step 110, locating the compiler path based on at least one of buffer variables, environment variables, and compiler search paths, includes: If a specified compiler path exists in the buffer variable, the specified compiler path is determined to be the compiler path of the specified compiler. If the buffer variable does not specify a compiler path and the environment variable is not empty, the compiler path of the compiler is determined based on the environment variable. If the buffer variable does not specify a compiler path and the environment variable is empty, the compiler path of the compiler is searched based on the compiler search path.

[0047] Specifically, when locating the compiler's path, the priority of buffer variables, environment variables, and compiler search paths decreases in that order.

[0048] First, we can determine whether the specified compiler path exists in the buffer variable, that is, whether the user has manually specified the compiler through the buffer variable.

[0049] When a compiler path is specified in a buffer variable, that path can be directly identified as the compiler's actual compiler path. For example, if a new programming language is added as ABCD, buffer variables like CMAKE_ABCD_COMPILER can represent the user's highest-priority explicit instructions. It's important to note that ABCD here refers to various possible programming languages. If the user manually assigns a specific file path to this buffer variable, that file path will be read first as the specified compiler path. This mechanism satisfies the user's need for mandatory intervention and precise compiler specification in complex heterogeneous computing scenarios.

[0050] If the compiler path is not specified in the buffer variable, you can check if the environment variable is empty.

[0051] When environment variables are not empty, the compiler path can be determined based on them. For example, standardized environment variables can be predefined, such as "ABCDCXX" or "ABCDHOSTCXX," which can be used to globally declare the compiler's location at the system level. If the environment variables are confirmed to be non-empty, the string parameter stored in the environment variable can be directly extracted and used to determine the compiler path. This mechanism allows users to switch compilers simply by changing environment variables without modifying any build scripts or configuration parameters in the project.

[0052] When environment variables are empty, the compiler path can be searched based on the compiler search path. In other words, if neither the buffer variables nor the environment variables provide a valid compiler path, a search mechanism targeting the compiler path can be automatically triggered. Furthermore, the executable file can be traversed in the compiler search path; once found, the path of the executable file is automatically located and returned as the compiler path.

[0053] In this embodiment of the invention, compiler path location is achieved by prioritizing buffer variables, followed by environment variables, and finally compiler search paths. During compiler path location, the user's right to forcibly specify the compiler path is preserved, while also considering automated search schemes in case the user fails to configure it, ensuring intelligent compiler automatic detection and improving its fault tolerance.

[0054] Based on any of the above embodiments, in step 120, the step of querying compiler information based on the compiler path to obtain the compiler configuration information includes: The version query command is executed based on the compiler path to obtain the compiler's vendor information, and the vendor information is added to the configuration information.

[0055] Here, the version lookup command is a command passed to the compiler's executable file to retrieve information related to the compiler's version. Vendor information can be understood as the result of executing the version lookup command; specifically, vendor information may include the name and brand of the manufacturer that developed or released the compiler.

[0056] Specifically, after obtaining the compiler path, a version query command can be executed based on the executable file pointed to by that compiler path. The execution result of the version query command can then be obtained, and vendor information can be parsed from it and recorded in the configuration information.

[0057] Therefore, the compiler's configuration information can include the compiler's vendor information, thus enabling automated integration of compilers from different vendors.

[0058] Based on any of the above embodiments, in step 120, the step of querying compiler information based on the compiler path to obtain the compiler configuration information includes: Compiler identifier detection is performed based on the compiler path to obtain the compiler's identifier information, and the identifier information is added to the configuration information.

[0059] Specifically, compiler identification detection refers to the process of identifying the compiler's identity by compiling or running a dedicated probe. In some embodiments, the probe may be referred to as a compiler identification detection program.

[0060] Identification information is used to represent the compiler's identity in the build system. Identification information may include the compiler ID, as well as information such as the default version of the language standard and extension support status.

[0061] The build system generator can create programs that include compiler identifier detection logic, such as the compiler identifier detection program CMakeABCDCompilerId.su.in. Based on this, the compiler can be invoked to run the compiler identifier detection program according to the compiler path, thereby performing compiler identifier detection, obtaining the compiler's identifier information, and recording this identifier information in the configuration information.

[0062] Therefore, the compiler's configuration information can include the compiler's identification information, thus providing the conditions for automated integration for different compilers.

[0063] Based on any of the above embodiments, in step 120, the step of querying compiler information based on the compiler path to obtain the compiler configuration information includes: The application binary interface is detected based on the compiler path to obtain the application binary interface information of the compiler, and the application binary interface information is added to the configuration information.

[0064] Specifically, Application Binary Interface (ABI) detection refers to the process of compiling and running a dedicated detection program to check the compatibility of the binary code generated by the compiler. In some embodiments, the detection program may be referred to as the compiler ABI detection program.

[0065] Application binary interface information can be understood as the result of application binary interface detection, and application binary interface information can reflect the compatibility of binary code generated by the compiler.

[0066] The system generator can create programs that include application binary interface detection logic, such as the compiler ABI detection program CMakeABCDCompilerABI.su. Based on this, the compiler ABI detection program can be run by calling the compiler based on the compiler path, thereby performing ABI detection, obtaining the compiler's application binary interface information, and recording this information in the configuration settings.

[0067] Therefore, the compiler's configuration information can include the compiler's application binary interface information, thus providing a basis for compiler integration compatibility.

[0068] In the method provided in this embodiment of the invention, at least one of the following is executed based on the compiler path: version query command, compiler identifier detection, and application binary interface detection. This enables fine-grained information query for the compiler, eliminates compilation and linking errors caused by human error or configuration delays in traditional manual configuration, and effectively ensures the quality of automated integration of compilers for new programming languages.

[0069] Figure 2 This is a flowchart illustrating the compiler detection method provided by the present invention, as shown below. Figure 2 As shown, in the compiler integration method, the compiler to be integrated can be detected. This compiler detection can be implemented by the build system generator or by the compiler auto-detection module built into the build system generator. Figure 2 In the compiler detection methods, the following are included: First, check if the generator type is supported: This can also be understood as the build system checking generator compatibility. Specifically, after the process begins, the build system generator can first check whether the current generator type supports the new programming language used by the compiler to be integrated. If the check result is positive, the process proceeds to the next step.

[0070] Secondly, check the environment variables: Specifically, after determining that generator support is available, the build system generator can check whether a specific environment variable is empty or whether a specific environment variable has already been set.

[0071] If environment variables have been set, the compiler path and parameters contained in the environment variables can be obtained, and the existence of the compiler can be verified based on the compiler path. If the existence of the compiler is confirmed, the compiler identifier detection is performed to obtain the compiler identifier.

[0072] For cases where environment variables are not set, the build system generator can use a preset list of default compilers and search for executable files of compilers from that list within a preset compiler search path. If a corresponding executable file is found, its location is set as the compiler's path. Subsequently, the compiler can be invoked based on this path, and a version lookup command can be executed to obtain the compiler's vendor information.

[0073] Finally, the obtained supplier information and compiler identification information can be used as the compiler configuration information and populated into the parameterized configuration template along with the compiler path, thereby generating an integrated configuration file for the compiler.

[0074] In related technologies, heterogeneous programming languages ​​typically require compilation optimization based on the architectural characteristics of the target device. Traditional methods require explicitly specifying the target architecture in the user code, lacking the ability to automatically detect device hardware information and dynamically configure compilation parameters, resulting in low compilation efficiency and a tendency to encounter architecture mismatch issues.

[0075] Based on any of the above embodiments, the compiler integration method further includes: A device architecture detection program is generated, which is used to call the application interface to detect the device's architecture information during device runtime; The device architecture detection program is run based on the compiler path to obtain architecture information; Based on the architecture information, the compiler's compilation parameters are adjusted.

[0076] Specifically, a device architecture detection program refers to a code file used to detect the architectural characteristics of a target device. Here, the target device is the computing device to be detected, which can also be understood as a computing unit. In this embodiment of the invention, the computing device to be detected is simply referred to as a device.

[0077] Application interfaces are low-level driver interfaces provided by the environment during the runtime of heterogeneous programming languages, such as ABCDGetDeviceCount or ABCDGetDeviceProperties.

[0078] The device architecture detection program is used to proactively query the architecture characteristics of devices currently mounted in the system by calling the aforementioned application interfaces during device runtime. These architecture characteristics can also be understood as device architecture version information, or simply device architecture information.

[0079] After generating the device architecture detection program, the corresponding compiler can be called to compile and link the generated program based on the compiler path obtained from the location, thus generating an executable detection tool. This tool can then be run. During operation, the detection tool can capture real-time feedback from the device through the application interface and parse this feedback into architecture information. This architecture information can be understood as the structure for detecting the device's architecture characteristics; the architecture information describes the device's hardware architecture features.

[0080] After obtaining the architecture information, it can be fed back to the build system, which will then optimize the compiler's compilation parameters based on the architecture information.

[0081] In this embodiment of the invention, the device architecture detection program realizes automated detection of the device architecture, and then the compilation parameters can be dynamically adjusted according to the detected architecture information. This realizes automatic detection of device hardware and dynamic configuration of compilation parameters, which can effectively improve compilation efficiency and avoid architecture mismatch problems.

[0082] Based on any of the above embodiments, the architecture information includes the major version number and minor version number of each device.

[0083] Here, the Major Version number identifies the generational update of the device architecture, while the Minor Version number identifies the update within the same generation of architecture. By combining the Major and Minor Version numbers, the specific position of the device in the entire architecture update and iteration process can be accurately located.

[0084] In some embodiments, during the operation of the device architecture detection program, all devices in the system can be traversed, and for each device, the device architecture detection program will call the application interface to obtain information that reflects the architecture characteristics of the device, which may include the major version number and minor version number of the device.

[0085] Figure 3 This is a flowchart illustrating the device architecture detection method provided by the present invention, as shown below. Figure 3 As shown, in the compiler integration method, architecture detection can be performed on the computing device. This architecture detection can be implemented by the build system generator or by the dynamic device architecture detection module built into the build system generator. Figure 3 In China, device architecture detection methods include: First, begin device architecture testing: At this stage, the operating environment of the underlying heterogeneous computing devices can be initialized, providing conditions for subsequent hardware architecture queries.

[0086] Secondly, the number of devices acquired: You can call an application interface such as ABCDGetDeviceCount() to get the number of available computing devices. Then, check if the number of devices is 0.

[0087] If the number of devices is 0, it indicates that there are currently no available computing devices, the detection ends, and an error message is returned.

[0088] If the number of devices is greater than 0, proceed to the next step and begin iterating through all devices.

[0089] During device traversal, for each device, device attributes can be retrieved and the major and minor version numbers of the device can be parsed from them: During device traversal, for each device, an application interface such as ABCDGetDeviceCount() can be called again to obtain the attributes of the currently traversed device, and then the major version number and minor version number of the device can be extracted from the device attributes.

[0090] Finally, output the architecture information: The major and minor version numbers of each device encountered can be formatted, for example, into the string "MMmm", where "MM" represents the major version number and "mm" represents the minor version number. After iterating through all devices, the formatted results of all devices can be concatenated into a list of architectures, which can then be output as the final architecture information.

[0091] In related technologies, when it is necessary to add support for new language standards to the same programming language, existing frameworks lack flexible configuration mechanisms, often requiring modification of the core code and making it difficult to achieve smooth expansion.

[0092] Based on any of the above embodiments, the compiler integration method further includes: The compiler is subjected to compilation feature detection to obtain the programming language standards supported by the compiler; The integration configuration file is optimized based on the programming language standards supported by the compiler.

[0093] Specifically, programming language standards can be understood as information such as the syntax rules, keyword set, and feature requirements of a programming language. Different versions of a programming language can correspond to different programming language standards. For example, versions of programming languages ​​such as ABCD03, ABCD11, ABCD14, ABCD17, ABCD20, and ABCD23 can each have their own corresponding programming language standards.

[0094] Furthermore, different compilers may have varying degrees of support for different programming language standards.

[0095] In this context, the compiler's integration configuration file can be optimized based on various versions of programming language standards. Specifically, a compiler feature detection mechanism can be used to automatically detect compiler features, thereby determining the compiler's support for different versions of programming language standards. This reveals the compiler's supported programming language standards, i.e., the versions of programming languages ​​it supports. Based on this, the compiler-supported programming language standards can be populated into the parameterized configuration template, thus optimizing the integration configuration file. This optimized configuration file reflects the compatibility between the compiler and programming language standards, effectively improving the compiler's integrated language extensibility.

[0096] Currently, compiler and linker parameters differ across operating systems. To address these differences, related technologies require writing specific code for each platform, lacking a unified abstraction layer to achieve platform-independent build configurations.

[0097] Based on any of the above embodiments, the build environment configuration parameters in the integration configuration file are determined based on the type of operating system running the compiler.

[0098] Specifically, to achieve seamless migration and high adaptability of the compiler across different operating systems, the build system generator in this embodiment of the invention also possesses cross-platform abstraction capabilities, enabling dynamic configuration adjustments based on different operating system types. For example, the operating system types here may include Windows, Linux, macOS, etc.

[0099] Specifically, in the integration configuration file, the build environment configuration parameters refer to the parameters necessary for the compilation and linking process to run normally under a specific operating system. These parameters may include file extensions, library formats, and compiler identifiers.

[0100] The build system generator can access device platform-related configuration interfaces within the parameterized configuration template. During the generation of the integration configuration file, the build system generator identifies the type of operating system the compiler is currently running on and automatically invokes the device platform-related configuration interfaces in the parameterized configuration template to set build environment configuration parameters that match the operating system type for the generated integration configuration file.

[0101] Therefore, the embodiments of the present invention can achieve cross-platform consistency of compiler integration, improve the deployment efficiency of heterogeneous language compilers in multi-platform environments, and enhance the universality of integration configuration files.

[0102] Figure 4 This is a schematic diagram of the compiler integration system provided by the present invention. Figure 4The left side of the diagram provides a hierarchical runtime environment for compiler integration methods, consisting of three levels from top to bottom: the top level is the core of the build system generator, the middle level is the heterogeneous language support framework, and the bottom level is the hardware environment for heterogeneous device runtime.

[0103] The core of the build system generator lies in the compiler integration process. It first receives the project configuration input from the user. Based on this, the build system generator converts the project configuration into a description file that the underlying execution engine can recognize. This drives the build system backend to identify and run newly added compilers. Taking CMake as an example, the project configuration can be CMakeLists, the description file generated by CMake can be Makefile or build.ninja, and the build system backend can be GCC (GNU Compiler Collection) or Clang, etc.

[0104] The heterogeneous language support framework can include a compiler detection module, an architecture detection module, a compiler command generation module, a platform abstraction module, and a language standard management module. Specifically, the compiler detection module automatically identifies and configures compilers for heterogeneous programming languages; the architecture detection module generates a program including architecture detection logic during compilation, which is executed by the compiler to obtain architecture information of the underlying heterogeneous devices and feeds this information back to the build system for compiler parameter optimization; the compiler command generation module defines standardized parameterized configuration templates and automatically generates integration configuration files; the platform abstraction module provides a unified platform-related configuration structure, automatically matching appropriate build environment configuration parameters based on the operating system type; and the language standard management module manages different versions of programming language standards and supports automatically determining the compiler's support for each programming language standard through a compiler feature detection mechanism.

[0105] The hardware environment for heterogeneous devices to run may include the application programming interface (API) for device runtime, and N heterogeneous devices.

[0106] During the execution of the system generator, the heterogeneous language compiler automatic integration method can be invoked to achieve compiler integration. This method enables automatic compiler detection and dynamic architecture detection. Automatic compiler detection can be implemented through the compiler detection module of the heterogeneous language support framework, while dynamic architecture detection can be implemented through its architecture detection module. Furthermore, in this method, the results of both automatic compiler detection and architecture homomorphism detection are input into a unified compilation command generation engine, which generates an integration configuration file. This unified compilation command generation engine can be implemented by the compilation command generation module of the heterogeneous language support framework. Additionally, this engine is also associated with a cross-platform abstraction layer and language standard management; the cross-platform abstraction layer is implemented by the platform abstraction module, and language standard management is implemented by the language standard management module.

[0107] Based on any of the above embodiments, the compiler integration method may include the following steps: At the start of the integration process, the build system generator first performs a preliminary compatibility check, that is, it checks whether the build system generator type supports the heterogeneous programming language to be integrated. After confirming support, the system begins to locate the compiler path. For example, the compiler path can be determined by reading environment variables or buffer variables.

[0108] After determining the compiler path, the build system generator performs compiler information queries based on that path. Specifically, it can execute a version query command based on the compiler path to obtain the compiler vendor information. It can also call and run a pre-created compiler identifier detection program to obtain information including the compiler identifier, the default language standard version, and extension support status. Furthermore, it can compile and run a pre-created compiler ABI detection program to detect and extract the compiler's ABI information. All of the above information can be placed into the configuration information.

[0109] In addition, the build system generator can create and run compiler tests to verify that the compiler is working properly and ensure that the subsequent build process is not interrupted due to compiler corruption or missing environment.

[0110] Following this, the build system generator can populate the configuration information and compiler path into the parameterized configuration template, thereby generating the integration configuration file. Specifically, the parameterized configuration template can contain two types of templates: one is a template containing all the compiler's underlying attribute configurations, denoted here as the compiler information configuration template; the other is a template defining various compilation and linking command rules, denoted here as the language information file template. By populating the parameterized configuration template, two types of integration configuration files can be obtained: the compiler information configuration file and the language information file.

[0111] The method provided in this invention achieves automated integration of novel heterogeneous programming language compilers through modular design. Developers only need to provide the compiler path, or set corresponding buffer variables and environment variables. The system generator can then automatically locate the compiler path based on these buffer variables, environment variables, and the compiler search path. It then automatically queries compiler information based on this path to obtain configuration information, and subsequently automatically generates the compiler's integration configuration file. Compared to traditional, cumbersome manual configuration methods, this method enables the system generator to automatically complete all integration work, including compiler detection and parameter configuration, effectively avoiding the error rate of manual configuration and significantly reducing configuration time.

[0112] Furthermore, the method provided in this embodiment of the invention can automatically detect the device's architecture information during construction using a device architecture detection program, and dynamically optimize compilation parameters based on the obtained architecture information. The heterogeneous applications compiled in this way can achieve improved execution performance under typical workloads because they can accurately match the underlying hardware characteristics.

[0113] Furthermore, the method provided in this embodiment of the invention fills the compiler path and configuration information into a preset parameterized configuration template. Since this parameterized configuration template includes a platform-independent build command structure for different target file types, it completely encapsulates platform-related differences within a unified build command structure. Based on this, build scripts written by developers can be parsed and run by the build system generator on different operating system platforms without any modification, solving the compatibility problem caused by inconsistent compilation and linking interfaces when heterogeneous languages ​​are used across platforms in related technologies.

[0114] It should be noted that the methods provided in this invention can be applied to various fields. For example, they can be applied to the field of high-performance computing to support scientific computing programs developed based on various new heterogeneous programming languages, helping researchers quickly build and deploy heterogeneous applications. As another example, they can be applied to the field of artificial intelligence and deep learning to support deep learning frameworks and model deployment tools developed based on heterogeneous programming languages, helping developers quickly adapt to different AI acceleration hardware. As yet another example, they can be applied to the field of autonomous driving and intelligent vehicles to support in-vehicle software systems developed based on heterogeneous programming languages, helping automotive software vendors quickly adapt to different in-vehicle computing platforms. As yet another example, they can be applied to the field of data centers and cloud computing to support cloud services and applications developed based on heterogeneous programming languages, helping ISVs (Independent Software Vendors) quickly build cloud-native applications that support multiple heterogeneous hardware. As yet another example, they can be applied to the field of edge computing and the Internet of Things to support edge applications developed based on heterogeneous programming languages, simplifying the construction process for different edge devices through an automatic architecture detection mechanism. Furthermore, they can be applied to scientific research and education and open-source communities, thereby facilitating the rapid trial and evaluation of new programming languages ​​and lowering the threshold for learning and experimenting with new technologies.

[0115] The compiler integration apparatus provided by the present invention is described below. The compiler integration apparatus described below and the compiler integration method described above can be referred to in correspondence.

[0116] Figure 5 This is a schematic diagram of the compiler integration device provided by the present invention, as shown below. Figure 5 As shown, the device includes: The locating unit 510 is used to locate the compiler path of the compiler based on at least one of buffer variables, environment variables, and compiler search paths; The query unit 520 is used to query compiler information based on the compiler path to obtain the compiler's configuration information; The generation unit 530 is used to fill the compiler path and the configuration information into the parameterized configuration template to obtain the compiler's integrated configuration file. The parameterized configuration template includes a build command structure that is independent of different target file types and platform.

[0117] In the apparatus provided in this embodiment of the invention, the compiler path is located by at least one of buffer variables, environment variables, and compiler search paths. Based on this, configuration information is automatically queried. Then, the compiler path and configuration information are filled into a platform-independent parameterized configuration template that supports multiple types of object files, thereby achieving automated integration of compilers for newly added programming languages. This compiler integration method eliminates the need for cumbersome manual configuration, ignores differences in programming languages ​​and platforms, and greatly reduces the threshold and configuration complexity for multi-platform adaptation by applying a platform-independent parameterized configuration template. It also improves the flexibility and scalability of the build system and maintains the consistency of the compilation and linking process.

[0118] Based on any of the above embodiments, the positioning unit is specifically used for: If a specified compiler path exists in the buffer variable, the specified compiler path is determined to be the compiler path of the specified compiler. If the buffer variable does not specify a compiler path and the environment variable is not empty, the compiler path of the compiler is determined based on the environment variable. If the buffer variable does not specify a compiler path and the environment variable is empty, the compiler path of the compiler is searched based on the compiler search path.

[0119] Based on any of the above embodiments, the query unit is specifically used for: Execute a version query command based on the compiler path to obtain the compiler's vendor information, and add the vendor information to the configuration information; Compiler identifier detection is performed based on the compiler path to obtain the compiler's identifier information, and the identifier information is added to the configuration information; The application binary interface is detected based on the compiler path to obtain the application binary interface information of the compiler, and the application binary interface information is added to the configuration information.

[0120] Based on any of the above embodiments, the device further includes an architecture detection unit, used for: A device architecture detection program is generated, which is used to call the application interface to detect the device's architecture information during device runtime; The device architecture detection program is run based on the compiler path to obtain architecture information; Based on the architecture information, the compiler's compilation parameters are adjusted.

[0121] Based on any of the above embodiments, the architecture information includes the major version number and minor version number of each device.

[0122] Based on any of the above embodiments, the device further includes a language unification unit, used for: The compiler is subjected to compilation feature detection to obtain the programming language standards supported by the compiler; The integration configuration file is optimized based on the programming language standards supported by the compiler.

[0123] Based on any of the above embodiments, the build environment configuration parameters in the integration configuration file are determined based on the type of operating system running the compiler.

[0124] Figure 6 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 6 As shown, the electronic device may include: a processor 610, a communications interface 620, a memory 630, and a communication bus 640, wherein the processor 610, the communications interface 620, and the memory 630 communicate with each other via the communication bus 640. The processor 610 can call logical commands in the memory 630 to execute a compiler integration method, which includes: The compiler path is located based on at least one of the following: buffer variables, environment variables, and compiler search paths. Based on the compiler path, perform a compiler information query to obtain the compiler's configuration information; The compiler path and configuration information are filled into the parameterized configuration template to obtain the compiler's integrated configuration file. The parameterized configuration template includes a build command structure that is platform-independent and targets different target file types.

[0125] Furthermore, the logical commands in the aforementioned memory 630 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to related technologies, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several commands to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0126] On the other hand, the present invention also provides a computer program product, the computer program product comprising a computer program, the computer program being able to be stored on a non-transitory computer-readable storage medium, and when the computer program is executed by a processor, the computer being able to execute the compiler integration method provided by the above methods, the method comprising: The compiler path is located based on at least one of the following: buffer variables, environment variables, and compiler search paths. Based on the compiler path, perform a compiler information query to obtain the compiler's configuration information; The compiler path and configuration information are filled into the parameterized configuration template to obtain the compiler's integrated configuration file. The parameterized configuration template includes a build command structure that is platform-independent and targets different target file types.

[0127] In another aspect, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to perform the compiler integration methods provided by the methods described above, the method comprising: The compiler path is located based on at least one of the following: buffer variables, environment variables, and compiler search paths. Based on the compiler path, perform a compiler information query to obtain the compiler's configuration information; The compiler path and configuration information are filled into the parameterized configuration template to obtain the compiler's integrated configuration file. The parameterized configuration template includes a build command structure that is platform-independent and targets different target file types.

[0128] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0129] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the parts that contribute to the related technology, can be embodied in the form of software products. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several commands to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0130] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention 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; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A compiler integration method, characterized in that, Applied to building system generators, the method includes: The compiler path is located based on at least one of the following: buffer variables, environment variables, and compiler search paths. Based on the compiler path, perform a compiler information query to obtain the compiler's configuration information; The compiler path and configuration information are filled into the parameterized configuration template to obtain the compiler's integrated configuration file. The parameterized configuration template includes a build command structure that is platform-independent and targets different target file types.

2. The compiler integration method according to claim 1, characterized in that, The method of locating the compiler path based on at least one of buffer variables, environment variables, and compiler search paths includes: If a specified compiler path exists in the buffer variable, the specified compiler path is determined to be the compiler path of the specified compiler. If the buffer variable does not specify a compiler path and the environment variable is not empty, the compiler path of the compiler is determined based on the environment variable. If the buffer variable does not specify a compiler path and the environment variable is empty, the compiler path of the compiler is searched based on the compiler search path.

3. The compiler integration method according to claim 1, characterized in that, The process of querying compiler information based on the compiler path to obtain the compiler's configuration information includes at least one of the following: Execute a version query command based on the compiler path to obtain the compiler's vendor information, and add the vendor information to the configuration information; Compiler identifier detection is performed based on the compiler path to obtain the compiler's identifier information, and the identifier information is added to the configuration information; The application binary interface is detected based on the compiler path to obtain the application binary interface information of the compiler, and the application binary interface information is added to the configuration information.

4. The compiler integration method according to claim 1, characterized in that, Also includes: A device architecture detection program is generated, which is used to call the application interface to detect the device's architecture information during device runtime; The device architecture detection program is run based on the compiler path to obtain architecture information; Based on the architecture information, the compiler's compilation parameters are adjusted.

5. The compiler integration method according to claim 4, characterized in that, The architecture information includes the major version number and minor version number of each device.

6. The compiler integration method according to any one of claims 1 to 5, characterized in that, Also includes: The compiler is subjected to compilation feature detection to obtain the programming language standards supported by the compiler; The integration configuration file is optimized based on the programming language standards supported by the compiler.

7. The compiler integration method according to any one of claims 1 to 5, characterized in that, The build environment configuration parameters in the integrated configuration file are determined based on the type of operating system running the compiler.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the compiler integration method as described in any one of claims 1 to 7.

9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the compiler integration method as described in any one of claims 1 to 7.

10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the compiler integration method as described in any one of claims 1 to 7.