Navigation

    全志在线开发者论坛

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • 在线文档
    • 社区主页

    编译平头哥最新的riscv工具链

    MR Series
    1
    1
    1020
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      mxlol233 LV 3 last edited by

      最近换了个aarch64的板子做服务器。玩d1-h的时候发现平头哥没有提供aarch64下的工具链。

      #启动一个ubuntu 18.04 环境:
      docker run -it -v `pwd`:/work/ ubuntu:18.04 /bin/bash
      
      cd /work
      
      #clone平头哥编译器源码:
      git clone --recursive https://github.com/T-head-Semi/xuantie-gnu-toolchain
      
      cd xuantie-gnu-toolchain
      #第一趟编译,使用默认的linux-header:
      ./configure --prefix=`pwd`/.build/install/  \
      --with-arch=rv64imafdcv_zfh_xtheadc  --with-abi=lp64d
      
      cd ..
      
      #clone d1-linux源码:
      git clone https://github.com/TuringKi/d1-linux
      
      cd d1-linux
      
      #用第一趟编译好的riscv64工具链在指定的linux内核上编译出linux-header:
      PATH=/work/xuantie-gnu-toolchain/.build/install/bin/:$PATH \
      make ARCH=riscv CROSS_COMPILE=riscv64-unknown-linux-gnu-  \
      headers_install INSTALL_HDR_PATH=`pwd`/.build/install/usr -j8
      
      cd ../xuantie-gnu-toolchain
      
      #第二趟编译,使用指定内核的linux-header版本:
      ./configure --prefix=`pwd`/.build/install/  \
      --with-linux-headers-src=`pwd`/../d1-linux/.build/install/usr/include/ \
      --with-arch=rv64imafdcv_zfh_xtheadc  --with-abi=lp64d
      
      make -j8
      

      注意,vector扩展在march的描述字符应该为v0p7,即vector扩展的0.7版。
      比如,要使用向量扩展进行编译:

      riscv64-unknown-linux-gnu-ar -march=rv64gcv0p7 vector.S
      

      不要使用:

      riscv64-unknown-linux-gnu-ar -march=rv64gcv vector.S
      

      编译器不认。

      1 Reply Last reply Reply Quote Share 0
      • 1 / 1
      • First post
        Last post

      Copyright © 2024 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号

      行为准则 | 用户协议 | 隐私权政策