天天看點

Gem5與NVMain混合編譯(一)

gem5的安裝與使用

1. 安裝各類庫檔案(ubuntu)

sudo apt-get install mercurial scons swig gcc m4 python python-dev 
libgoogle-perftools-dev g++ libprotobuf-dev
           

由于ubuntu預設情況下,并沒有提供C/C++的編譯環境,單獨安裝gcc以及g++比較麻煩,ubuntu提供一個build-essential軟體包。安裝這個軟體包,編譯C/C++需要的軟體包都會被安裝

sudo apt-get install build-essential
           

2.下載下傳gem5源碼

hg clone http://repo.gem5.org/gem5
           
Gem5與NVMain混合編譯(一)
Gem5與NVMain混合編譯(一)
  • 配置hgrc

    打開hgrc檔案:

    vim gem5/.hg/hgrc

    ,将以下檔案内容拷貝到裡面,修改username,style等資訊,style是你gem5檔案裡的style.其實我覺得

    [email]

    中的内容其實作用不大,但是看了好多其他的都差不多是這樣我自己就隻修改了style和username。

    資訊的修改隻是一種辨別,不影響編譯和使用,最重要的是

    [extensions] hgext.mq =

    擴充hg指令.
[ui]
# Set the username you will commit code with
username=Your Name <[email protected]>
ssh = ssh -C
# Always use git diffs since they contain permission changes and rename info
[defaults]
qrefresh = --git
email = --git
diff = --git
[extensions]
# These are various extensions we find useful
# Mercurial Queues -- allows managing of changes as a series of patches
hgext.mq =
# PatchBomb -- send a series of changesets as e-mailed patches
hgext.patchbomb =
# External Diff tool (e.g. kdiff3, meld, vimdiff, etc)
hgext.extdiff =
# Fetch allows for a pull/update operation to be done with one command and automatically commits a merge changeset
hgext.fetch =
# Path to the style file for the M5 repository
# This file enforces our coding style requirements
style = /path/to/your/gem5/util/style.py
[email]
method = smtp
from = Your Name <[email protected]>
[smtp]
host = your.smtp.server.here
           

3.擷取NVMain

  • 注冊bitbucket帳号

    https://bitbucket.org/account/signup/

  • 擷取NVMain使用權

    打開https://bitbucket.org/mrp5060/nvmain/并登陸bitbucket賬号,登陸後重新打開前面這個網站擷取下載下傳指令

git clone https://your [email protected]/xxx
           
  • 或者點選下載下傳nvmain(無需注冊)
  • nvmain檔案位置随意,我放在了gem5根目錄下,如果放的位置不同,後面編譯時注意相對位置

4.安裝NVMain更新檔

  • 進入gem5根目錄
  • 初始化更新檔目錄
hg init
hg qinit
           
  • 輸入更新檔 (注意nvmain檔案位置,以及更新檔的版本号)
hg qimport -f ./nvmain/patches/gem5/nvmain2-gem5-11688+
           
  1. 安裝更新檔
hg qpush
           
  1. 如果打更新檔出錯,檢查gem5的版本,檢查nvmain中更新檔的版本
//版本不對,更新gem5
hg update 11688
//檢查更新檔是否打上
hg qapplied
           

5.聯合編譯gem5和nvmain

scons EXTRAS=nvmain ./build/X86/gem5.opt 
           
Gem5與NVMain混合編譯(一)

在這一步中容易出現各種錯誤

1. ImportError: No module named gem5_scons:

Gem5與NVMain混合編譯(一)

檢視gem5目錄中是否存在gem5_scons檔案夾,如果沒有則在site_scons中将gem5_scons移到gem5根目錄下

Gem5與NVMain混合編譯(一)

2. [-Werror=implicit-fallthrough=]

這個問題困擾了我好久,百度了好久終于發現問題

如果gcc版本号為7,那麼源代碼的switch-case塊中如果忘了加上break,有可能會報錯Implicit fallthrough error。

解決辦法:編譯時忽略Implicit fallthrough error這個錯誤

修改 gem5中的SConstruct

在CCFLAGS中添加 -Wno-implicit-fallthrough 即可忽略該錯誤

main.Append(CCFLAGS=['-Wall', '-Wundef', '-Wextra',
                         '-Wno-sign-compare', '-Wno-unused-parameter','-Wno-implicit-fallthrough'])
           

3. [-Werror]相關類似錯誤

均可按照上面的方法,忽略gcc-7版本的問題導緻的錯誤

6.測試

./build/X86/gem5.opt ./configs/example/se.py -c ./tests/test-progs/hello/bin/x86/linux/hello

           
Gem5與NVMain混合編譯(一)

如果遇到和我一樣的錯誤的,希望對你有幫助,麼麼哒