Compilation Options

Common compilation options of AI CPU are as follows.

Table 1 Common compilation options

Option

Required (Yes/No)

Description

-help

No

Displays the help information.

-o <file>

No

Specifies the name and location of the output file.

-c

Yes

Compiles and generates the target file.

-O

No

Specifies the optimization level of the compiler. Currently, -O3, -O2, and -O0 are supported.

-fPIC

No

Instructs the compiler to generate location-independent code.

--std=c++17

No

Configures the C++ standard. This option is required for the Ascend C operator compilation which uses the C++17 standard. If the file name extension is asc, the default value of std is c++17.

-x

No

Parses and compiles the input file following this option based on the specific syntax API. The file name extension can be cce, asc, or aicpu. Ccache compilation cache acceleration is not supported.

--cce-aicpu-L

No

Specifies the library path on which the AI CPU device depends.

--cce-aicpu-l

No

Specifies the library on which the AI CPU device depends.

--cce-aicpu-sysroot=

No

Specifies sysroot for AI CPU device compilation.

During AI CPU heterogeneous compilation, the host and device CPUs may have different architectures, which is similar to cross compilation. You can use this option to specify a separate sysroot for device compilation to avoid lack of some header files.

--cce-aicpu-toolkit-path=

No

Specifies the AI CPU device linker path.

The HCC linker (linker carried by the HCC compiler in the CANN software package) is optimized for the AI CPU and automatically links auxiliary runtime library object files such as crt*.o during device linking. You are advised to use the HCC linker.

The path of the HCC compiler is ${INSTALL_DIR}/toolkit/toolchain/hcc/bin. You can use this option to specify the bin path of the HCC compiler to enable the HCC linker. Replace ${INSTALL_DIR} with the CANN component directory. For example, if the installation is performed by the root user, the default file storage path is /usr/local/Ascend/cann.