Updated on 2024-09-14 GMT+08:00

BiSheng Compiler

BiSheng compiler is a high-performance, high-reliability, and easy-to-expand compiler developed by Huawei. BiSheng compiler has introduced multiple compilation technologies and supports programming languages C, C++, and Fortran.

Constraints

  • BiSheng compiler can be used only with HCE 2.0 of the x86 architecture.
  • The native Clang-compiled languages of HCE cannot work with the Clang-compiled languages of the BiSheng compiler. If you have installed the native Clang-compiled language package and need to use it, do not install the BiSheng compiler anymore.

    If you have installed the BiSheng compiler but want to use the native Clang-compiled language, run rpm -e bisheng-compiler to delete the BiSheng compiler, and then open a new terminal to use the native Clang-compiled language.

Installing BiSheng Compiler

  1. Confirm that the repository is configured correctly.

    Check whether the parameters in the /etc/yum.repos.d/hce.repo file are configured correctly. The correct configuration is as follows:

    [base]
    name=HCE $releasever base
    baseurl=https://repo.huaweicloud.com/hce/$releasever/os/$basearch/
    enabled=1
    gpgcheck=1
    gpgkey=https://repo.huaweicloud.com/hce/$releasever/os/RPM-GPG-KEY-HCE-2
    
    [updates]
    name=HCE $releasever updates
    baseurl=https://repo.huaweicloud.com/hce/$releasever/updates/$basearch/
    ......
  2. Run yum install bisheng-compiler to install BiSheng compiler.
  3. Run source /usr/local/bisheng-compiler/env.sh to import environment variables.

    If you have opened a new terminal, import the environment variables into the new terminal.

  4. Check whether BiSheng compiler has been installed.

    Run clang –v to view the version number. If the command output contains the BiSheng compiler version, the BiSheng compiler has been successfully installed.

Using BiSheng Compiler

  1. Compile and run C and C++ programs.
    clang [command line flags] hello.c -o hello.o
    ./hello.o
    clang++ [command line flags] hello.cpp -o hello.o
    ./hello.o
  2. Compile and run Fortran programs.
    flang [command line flags] hello.f90 -o hello.o
    ./hello.o
  3. Specify a linker.

    Specify the LLVM lld for BiSheng compiler. If you do not specify the LLVM lld, the default linker ld will be used.

    clang [command line flags] -fuse-ld=lld hello.c -o hello.o
    ./hello.o