GQBBBB / GQBBBB.github.io

My Blog
3 stars 0 forks source link

Build SPEC CPU2006 in riscv64 linux #10

Open GQBBBB opened 4 years ago

GQBBBB commented 4 years ago

这是在riscv64 linux环境下构建cpu2006的过程:

  1. 拿到cpu2006(version 1.0.1)代码,包括tools/src下的文件.
  2. build tools.
  3. 安装
  4. 配置环境变量
  5. 运行

build tools

因为cpu2006预编译工具链不包括riscv64架构的,所以你要重新构建所有工具,然后才可以安装. 以下操作在cpu2006/tools/src下.

执行./buildtools开始构建.

以下是我出现的错误以及解决办法:

Q1: config.guess无法识别你机器的架构

首先你要保证它自带的工具可以识别出来你的架构,更新一下config.guess和config.sub. 下载最新的config.guess和config.sub

wget -O config.guess 'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD'
wget -O config.sub 'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD'

把下载的config.guess和config.sub替换掉以下目录中已存在的

tools/src/expat-1.95.8/conftools/
tools/src/tar-1.15.1/config/
tools/src/specinvoke/
tools/src/make-3.80/config/

Q2: WARNING: `makeinfo' is missing on your system.

安装texinfo这个包

sudo dnf install -y texi2html texinfo

Q3: yacc command not found

安装byacc这个包

sudo dnf install -y byacc

Q4: error: conflicting types for 'yylex'

把函数定义中变量类型和声明类型统一一下.

Q5: ./glob/glob.c:577:23: warning: implicit declaration of function '__alloca'; did you mean 'alloca'? [-Wimplicit-function-declaration]

把CPU2006所有文件中包含# if _GNU_GLOB_INTERFACE_VERSION == GLOB_INTERFACE_VERSION的全部改为# if _GNU_GLOB_INTERFACE_VERSION >= GLOB_INTERFACE_VERSION. 参考这里

Q6: make: *** No rule to make target <command-line>', needed byminiperlmain.o'.

打开tools/src/perl-5.8.7/makedepend.SH, 添加一行:

             -e '/^#.*<command line>/d' \
+            -e '/^#.*<command-line>/d' \

Q7: lib/getline.h:31:1: error: conflicting types for 'getline' & !!! error building specmd5sum

打开./tools/src/specmd5sum/md5sum.c文件,注释掉#include "getline.h".

Q8:下面一大段错误:

 make: *** [miniperl] Error 1
 + testordie 'error building Perl'
 + test 2 -ne 0
 + echo '!!! error building Perl'
 !!! error building Perl
 + kill -TERM 15173
 + exit 1
 !!!!! buildtools killed
  1. 打开./tools/src/perl-5.8.7/ext/IPC/SysV/SysV.xs,注释掉include <asm/page.h>
  2. 打开./tools/src/buildtools, 输入\-dOes找到代码段位置, 并做以下修改:
    ./Configure -dOes -Ud_flock $PERLFLAGS -Ddosuid=undef -Dprefix=$INSTALLDIR 
    -Dd_bincompat3=undef -A ldflags="-ldl -lm -L${INSTALLDIR}/lib" -A ccflags=-I${INSTALLDIR}/include 
    -Ui_db -Ui_gdbm -Ui_ndbm -Ui_dbm -Uuse5005threads 
    -Dcccdlflags="-fPIC -shared" -Dlddlflags="-shared -fPIC" -Duseshrplib=true ; 
    testordie "error configuring perl"

Q9: make: *** [blib/arch/auto/Compress/Bzip2/Bzip2.so] Error 1

打开./tools/src/buildtools, 找到BZIP2CFLAGS变量, 在它所在语句的上面添加BZIP2CFLAGS=-fPIC.

很多解决办法参考这里

最后./buildtools成功:

Top of SPEC benchmark tree is '/home/gqb/cpu2006'
Tools built successfully.  Go to the top of the tree and
source the shrc file.  Then you should be ready.

build大概需要一个小时, 中间可能有很多warning, 但是不用管. :sob::sob::sob:

获得config文件

因为cpu2006不包含riscv64的cfg文件,所以你需要从这里获得riscv.cfg, 然后可能需要根据你的机器做一些修改, 并把它移动到cpu2006/config/目录下.

安装

cpu2006下运行./install.sh. 查看输出感觉这一步操作的含义是不是和./buildtools差不多??? install大概需要一个多小时.

软件包完整性校验失败,可能是我们修改了代码.

...
Tools build successful.

Checking the integrity of your source tree...

bin/specmd5sum: WARNING: 4 of 15910 computed checksums did NOT match
bin/specmd5sum: WARNING: 37 of 15910 file sizes did NOT match

tools/src/buildtools: FAILED size mismatch
tools/src/bzip2-1.0.3/configure: FAILED size mismatch
tools/src/expat-1.95.8/conftools/config.guess: FAILED size mismatch
tools/src/expat-1.95.8/conftools/config.sub: FAILED size mismatch
tools/src/make-3.80/config.h.in: FAILED size mismatch
tools/src/make-3.80/config/config.guess: FAILED size mismatch
tools/src/make-3.80/config/config.sub: FAILED size mismatch
tools/src/make-3.80/configure: FAILED size mismatch
tools/src/make-3.80/configure.in: FAILED
tools/src/make-3.80/glob/glob.c: FAILED
tools/src/make-3.80/po/da.gmo: FAILED size mismatch
tools/src/make-3.80/po/da.po: FAILED size mismatch
tools/src/make-3.80/po/de.gmo: FAILED size mismatch
tools/src/make-3.80/po/de.po: FAILED size mismatch
tools/src/make-3.80/po/es.gmo: FAILED size mismatch
tools/src/make-3.80/po/es.po: FAILED size mismatch
tools/src/make-3.80/po/fr.gmo: FAILED size mismatch
tools/src/make-3.80/po/fr.po: FAILED size mismatch
tools/src/make-3.80/po/gl.gmo: FAILED size mismatch
tools/src/make-3.80/po/gl.po: FAILED size mismatch
tools/src/make-3.80/po/he.gmo: FAILED size mismatch
tools/src/make-3.80/po/he.po: FAILED size mismatch
tools/src/make-3.80/po/hr.gmo: FAILED size mismatch
tools/src/make-3.80/po/hr.po: FAILED size mismatch
tools/src/make-3.80/po/ja.gmo: FAILED size mismatch
tools/src/make-3.80/po/ja.po: FAILED size mismatch
tools/src/make-3.80/po/ko.gmo: FAILED size mismatch
tools/src/make-3.80/po/ko.po: FAILED size mismatch
tools/src/perl-5.8.7/ext/IPC/SysV/SysV.xs: FAILED size mismatch
tools/src/perl-5.8.7/makedepend.SH: FAILED size mismatch
tools/src/specinvoke/config.guess: FAILED size mismatch
tools/src/specinvoke/config.sub: FAILED size mismatch
tools/src/specmd5sum/md5sum.c: FAILED size mismatch
tools/src/tar-1.15.1/config.hin: FAILED size mismatch
tools/src/tar-1.15.1/config/config.guess: FAILED size mismatch
tools/src/tar-1.15.1/config/config.sub: FAILED size mismatch
tools/src/tar-1.15.1/configure: FAILED size mismatch
tools/src/tar-1.15.1/doc/stamp-vti: FAILED
tools/src/tar-1.15.1/doc/version.texi: FAILED
tools/src/tar-1.15.1/lib/getdate.c: FAILED size mismatch
tools/src/tar-1.15.1/lib/getdate.y: FAILED size mismatch
Package integrity check failed.  Some failures are to be expected after
building the tools, as the build process modifies some files in the
distribution.

安装成功

Top of SPEC benchmark tree is '/home/gqb/cpu2006'
Everything looks okay.  cd to /home/gqb/cpu2006,
source the shrc file and have at it!

配置环境变量

. ./shrc

运行

运行一下mcf测试一下吧

runspec --config riscv.cfg --size=ref --noreportable  --iterations=1 --tune=base 429.mcf

(这里的riscv.cfg就是上面让你移到config文件夹下的那个, 如果重命名为default.cfg也可以去掉--config )

结果:

[gqb@stage4 cpu2006]$ runspec --config riscv.cfg --size=ref --noreportable  --iterations=1 --tune=base 429.mcf
runspec v4662 - Copyright 1999-2006 Standard Performance Evaluation Corporation
Using 'riscv64-linux' tools
Reading MANIFEST... 17911 files
Loading runspec modules...............
Locating benchmarks...found 31 benchmarks in 12 benchsets.
Locating output formats: ASCII, config, CSV, flags, HTML, mail, PDF, PostScript, raw, Screen, Submission Check
Reading config file '/home/gqb/cpu2006/config/riscv.cfg'
Benchmarks selected: 429.mcf
Compiling Binaries
  Building 429.mcf ref base riscv default: (build_base_riscv.0000)

Build successes: 429.mcf(base)

Parsing Flags
  Looking at 429.mcf base riscv default: done
Flag Parsing Complete

Setting Up Run Directories
  Setting up 429.mcf ref base riscv default: created (run_base_ref_riscv.0000)
Running Benchmarks
  Running 429.mcf ref base riscv default
Success: 1x429.mcf
Producing Reports
mach: default
  ext: riscv
    size: ref
      set: int
        format: raw -> /home/gqb/cpu2006/result/CINT2006.002.rsf
        format: flags -> /home/gqb/cpu2006/result/CINT2006.002.flags.html
        format: ASCII -> /home/gqb/cpu2006/result/CINT2006.002.txt
        format: CSV -> /home/gqb/cpu2006/result/CINT2006.002.csv
        format: HTML -> /home/gqb/cpu2006/result/CINT2006.002.html, ../../../../../result//invalid.gif, CINT2006.002.gif
      set: fp

The log for this run is in /home/gqb/cpu2006/result/CPU2006.002.log

runspec finished at Wed Nov 20 14:53:28 2019; 2117 total seconds elapsed

运行时出现错误参考这里.


参考:

  1. https://www.okqubit.net/runspec.html 感谢 Hisanobu Tomari
  2. https://raw.githubusercontent.com/ccelio/Speckle/master/riscv.cfg
  3. https://github.com/sjp38/CPU2006-Express#runspec-errors