1"use strict";(self.webpackChunkmilkv_website=self.webpackChunkmilkv_website||[]).push([[6946],{18292:(e,n,i)=>{i.r(n),i.d(n,{assets:()=>c,contentTitle:()=>l,default:()=>h,frontMatter:()=>s,metadata:()=>r,toc:()=>d});var o=i(85893),t=i(11151);const s={sidebar_label:"GCC Toolchain",sidebar_position:30},l="SG2042 GCC toolchain documentation",r={id:"pioneer/resources/gcc",title:"SG2042 GCC toolchain documentation",description:"SG2042 use the T-HEAD GNU compiler toolchain, this document introduces how to build and use this toolchain.",source:"@site/docs/pioneer/resources/gcc.md",sourceDirName:"pioneer/resources",slug:"/pioneer/resources/gcc",permalink:"/docs/pioneer/resources/gcc",draft:!1,unlisted:!1,editUrl:"https://github.com/milk-v/milkv.io/edit/main/docs/pioneer/resources/gcc.md",tags:[],version:"current",sidebarPosition:30,frontMatter:{sidebar_label:"GCC Toolchain",sidebar_position:30},sidebar:"pioneer",previous:{title:"SG2042 Running benchmark software usage documentation",permalink:"/docs/pioneer/resources/scoresoftware"},next:{title:"InferLLM",permalink:"/docs/pioneer/resources/inferllm"}},c={},d=[{value:"1. How to Build",id:"1-how-to-build",level:2},{value:"1.1 Download the source for github",id:"11-download-the-source-for-github",level:3},{value:"1.2 Install prerequisites",id:"12-install-prerequisites",level:3},{value:"1.3 Build steps",id:"13-build-steps",level:3},{value:"1.4 Check the build",id:"14-check-the-build",level:3},{value:"2. How to use",id:"2-how-to-use",level:2},{value:"3. Bug reports",id:"3-bug-reports",level:2}];function a(e){const n={a:"a",code:"code",em:"em",h1:"h1",h2:"h2",h3:"h3",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,t.a)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(n.h1,{id:"sg2042-gcc-toolchain-documentation",children:"SG2042 GCC toolchain documentation"}),"\n",(0,o.jsx)(n.p,{children:"SG2042 use the T-HEAD GNU compiler toolchain, this document introduces how to build and use this toolchain."}),"\n",(0,o.jsx)(n.h1,{id:"t-head-gnu-compiler-toolchain",children:"T-HEAD GNU Compiler Toolchain"}),"\n",(0,o.jsx)(n.p,{children:"T-HEAD GNU Compiler Toolchain is a RISC-V vendor toolchain that supports T-head CPUs. It offers vendor extensions series X-Thead, and optimized many special instructions."}),"\n",(0,o.jsxs)(n.p,{children:["You can download the source and build it from ",(0,o.jsx)(n.a,{href:"https://github.com/T-head-Semi/xuantie-gnu-toolchain",children:"Here"})]}),"\n",(0,o.jsxs)(n.p,{children:["A prebuild toolchain can be downloaded from ",(0,o.jsx)(n.a,{href:"https://occ.t-head.cn/community/download",children:"Here"})]}),"\n",(0,o.jsx)(n.h2,{id:"1-how-to-build",children:"1. How to Build"}),"\n",(0,o.jsx)(n.h3,{id:"11-download-the-source-for-github",children:"1.1 Download the source for github"}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{children:"$ git clone https://github.com/T-head-Semi/xuantie-gnu-toolchain\n"})}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.em,{children:"Notes: the source files will take around 6.65 GB of disk and download size."})}),"\n",(0,o.jsx)(n.h3,{id:"12-install-prerequisites",children:"1.2 Install prerequisites"}),"\n",(0,o.jsx)(n.p,{children:"Several standard packages are needed to build the toolchain, so we need to prepare the build environment before build."}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsx)(n.li,{children:(0,o.jsx)(n.strong,{children:"On Ubuntu"})}),"\n"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{children:"$ apt-get install -y make diffutils autoconf automake autotools-dev curl python3 python3-pip libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev ninja-build git cmake libglib2.0-dev\n"})}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsx)(n.li,{children:(0,o.jsx)(n.strong,{children:"On On Fedora/CentOS/RHEL OS"})}),"\n"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{children:"$ dnf install -y make diffutils autoconf automake python3 libmpc-devel mpfr-devel gmp-devel gawk bison flex texinfo patchutils gcc gcc-c++ zlib-devel expat-devel\n"})}),"\n",(0,o.jsx)(n.h3,{id:"13-build-steps",children:"1.3 Build steps"}),"\n",(0,o.jsx)(n.p,{children:"Sets up the configure args at first, pick an install path like /opt/riscv, tools will be installed in /opt/riscv/bin subdir:"}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{children:"$ ./configure --prefix=/opt/riscv \u2013-with-arch=rv64gc_zfh_xtheadba_xtheadbb_xtheadbs_xtheadcmo_xtheadcondmov_xtheadfmemidx_xtheadfmv_xtheadint_xtheadmac_xtheadmemidx_xtheadmempair_xtheadsync --with-abi=lp64d\n"})}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.em,{children:"Notes: you can enable any other supported RISC-V sub-extensions by adding extensions in --with-arch option. For example, to enable RISC-V Bitmanip extension in toolchain, you can add _zba_zbb_zbc_zbs follow exist args."})}),"\n",(0,o.jsx)(n.p,{children:"It supports two build modes: a generic ELF/Newlib toolchain and a more sophisticated Linux-ELF/glibc toolchain."}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsx)(n.li,{children:(0,o.jsx)(n.strong,{children:"Newlib toolchain"})}),"\n"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{children:"$ make -j $(nproc)\n"})}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsx)(n.li,{children:(0,o.jsx)(n.strong,{children:"Linux-ELF/glibc toolchain"})}),"\n"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{children:"$ make linux -j $(nproc)\n"})}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.em,{children:"Notes: The build usually takes about fifteen minutes."})}),"\n",(0,o.jsx)(n.h3,{id:"14-check-the-build",children:"1.4 Check the build"}),"\n",(0,o.jsx)(n.p,{children:"After build finished, check with"}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{children:"$ /opt/riscv/bin/riscv64-xxx-gcc -v\n"})}),"\n",(0,o.jsx)(n.p,{children:"to see if the toolchain installed correctly."}),"\n",(0,o.jsx)(n.h2,{id:"2-how-to-use",children:"2. How to use"}),"\n",(0,o.jsx)(n.p,{children:"You can get an introduction to basic usage through --help option:"}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{children:"$ /opt/riscv/bin/riscv64-xxx-gcc --help\n"})}),"\n",(0,o.jsxs)(n.p,{children:["For further details please refer to ",(0,o.jsx)(n.a,{href:"https://gcc.gnu.org/onlinedocs/gcc-13.2.0/gcc/",children:"GCC user manual"})]}),"\n",(0,o.jsx)(n.h2,{id:"3-bug-reports",children:"3. Bug reports"}),"\n",(0,o.jsxs)(n.p,{children:["If you meet any problems when using toolchain, please send a bug report to ",(0,o.jsx)(n.a,{href:"https://gcc.gnu.org/bugzilla",children:"GCC Bugzilla"})," or ",(0,o.jsx)(n.a,{href:"https://github.com/riscv-collab/riscv-gnu-toolchain/issues",children:"open a new issue"}),"."]}),"\n",(0,o.jsx)(n.p,{children:"The RISC-V toolchain SIG will help you solve the problem soon."})]})}function h(e={}){const{wrapper:n}={...(0,t.a)(),...e.components};return n?(0,o.jsx)(n,{...e,children:(0,o.jsx)(a,{...e})}):a(e)}},11151:(e,n,i)=>{i.d(n,{Z:()=>r,a:()=>l});var o=i(67294);const t={},s=o.createContext(t);function l(e){const n=o.useContext(s);return o.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function r(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:l(e.components),o.createElement(s.Provider,{value:n},e.children)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.