Updated on 2025-09-19 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

The HCE native Clang compiler cannot work with the Clang compiler of BiSheng. If you have installed the native Clang compiler, do not install the BiSheng compiler anymore.

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

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/
    enabled=1
    gpgcheck=1
    gpgkey=https://repo.huaweicloud.com/hce/$releasever/updates/RPM-GPG-KEY-HCE-2
     
    [debuginfo]
    name=HCE $releasever debuginfo
    baseurl=https://repo.huaweicloud.com/hce/$releasever/debuginfo/$basearch/
    enabled=0
    gpgcheck=1
    gpgkey=https://repo.huaweicloud.com/hce/$releasever/debuginfo/RPM-GPG-KEY-HCE-2
  2. Run yum -y 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 a C/C++ program. A C program is used as an example.
    1. Add the following content to the hello.c file:
      #include <stdio.h>
      
      int main() {
          printf("Hello, World! This is a C program.\n");
          return 0;
      }
    2. Compile hello.c.
      clang hello.c -o hello
    3. Run hello.o.
      ./hello
  2. Compile and run a Fortran program.
    1. Add the following content to the hello.f90 file:
      program hello
          print *, "Hello, World! This is a Fortran program."
      end program hello
    2. Compile hello.f90.
      flang hello.f90 -o hello.o
    3. Run 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 -fuse-ld=lld hello.c -o hello.o
    ./hello.o

Upgrade and Rollback

  1. Upgrade
    yum upgrade bisheng-compiler
  2. Rollback
    yum downgrade bisheng-compiler

    For a cross-version upgrade of the BiSheng compiler, the rollback may fail due to file conflicts. You can manually delete the conflicting files and then run the rollback command again.