目录

软件介绍

软件介绍

工具链名字

运行环境

BiSheng-llvm-binary-release-musl.tar.gz

在Linux上运行。

BiSheng-llvm-binary-release-win-musl.tar.gz

在Windows上运行。

BiSheng-llvm-binary-release-musl-arm.tar.gz

在Euler-os上运行。

目录层次

1. 解压压缩包。Windows版本的工具链建议使用7-Zip解压,因为其他解压工具会破坏文件的软链接。

tar xf BiSheng-llvm-binary-release-musl.tar.gz

2. 进入目录。

cd BiSheng -llvm-binary-release-musl

|--bin

|--|--clang C compiler

|--|--llvm-ar Static packaging tools

|--|--llvm-mc Assembler

|--|--lld Linker

|--|--llvm-nm List symbols in [file(s)]

|--|--llvm-objcopy Copies a binary file

|--|-- llvm -objdump Display information from object

|--|-- llvm -readelf Display information about the contents of ELF files

|--|-- llvm -strip Removes symbols and sections from files

|--lib Compiler-dependent library

|--libexec Compiler-dependent executable library

|--riscv32-elf Compiler-dependent system library

|--share Documents for install compiler to Linux

设置权限

要使用编译器,需要添加文件的可执行权限。

chmod -R u+x,g+x linx-llvm-binary-release-musl

环境需求

1. 运行在Linux平台上的工具链基于ubuntu18.04构建,不支持任何低于glibc 2.17版本的操作系统。可支持的操作系统:

1) Suse12sp5或更高。

2) CPU架构X86-64。

2. 运行在EulerOS平台上的工具链基于EulerOS Server V200R013C00SPC100B150版本构建。

3. 运行在Windows平台的工具链使用Linux平台的MinGW进行交叉编译。因此,工具链依赖MinGW中的libssp-0.dll文件。可以从MinGW官网 (https://www.mingw-w64.org/downloads/#mingw-builds) 下载预构建的MinGW二进制发布包。 从二进制发布包中获取libssp-0.dll,并将其保存到Windows操作系统的C:\Windows\SysWOW64目录下。 下载地址: https://github.com/niXman/mingw-builds-binaries/releases,i686-12.2.0-release-posix-dwarf-rt_v10-rev0.7z。

构建

  1. 准备源码文件 hello.c。
#include <stdio.h>
int main()
{
    printf("Hello, World!");
    return 0;
}

2. 跑构建命令,xxx是解压工具链后的绝对路径,源码文件也一样。

xxx/bin/clang -march=rv32imc hello.c -o a.out

选项

Option

Description

-O2/-O3/-Os/-Oz

Support for different optimization levels.

--target

--target=riscv32, choose the target architecture.

-march

-march=rv32imfdc

‘i’ means integer, ‘f’ means float, ‘d’ means double. ‘c’ means compress

-mabi

-mabi=ilp32/ilp32f/ilp32d