Macで Xilinx/systemctlm-cosim-demo動かす(その4)
を 個人PC(Mac)で動かそうとしてます。
環境
- macOS Monterey 12.5
- Clang 14.0.6
前提
以下がインストールされている状態です。
動機
- 暇
(夏休み) - 面白そう
- 個人PC(Mac)で動くかやってみよう
構成
systemctlm-cosim-demo/docs/lmac-demos.md を見てみると必要な構成は以下の感じぽい
Xilinx/qemu
systemctlm-cosim-demo/docs/lmac-demos.md 記載を参考に
新たにインストールしたもの
$ brew install ninja $ brew install libgcrypt
$ git clone https://github.com/Xilinx/qemu.git $ mkdir build-qemu $ cd build-qemu $ ../qemu/configure --target-list=aarch64-softmmu,microblazeel-softmmu,riscv64-softmmu $ make qemu/include/hw/misc/ipcores-rsa5-4k.h:30:10: fatal error: 'gcrypt.h' file not found #include <gcrypt.h> ^~~~~~~~~~ 1 error generated.
あれ?ヘッダーファイルが無い!?
$ clang -x c++ -v -E /dev/null
で見てみると、search startsに /usr/local/include
が入ってなかったので 環境変数に設定した。
(ついで、ライブラリパスも)
$ export C_INCLUDE_PATH=/usr/local/include $ export CPLUS_INCLUDE_PATH=/usr/local/include $ export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/lib
再度 make
し、ヘッダーファイルのエラーは解消
Undefined symbols for architecture x86_64: "_gcry_mpi_add", referenced from: _rsa_do_add in hw_misc_ipcores-rsa5-4k.c.o _rsa_do_sub in hw_misc_ipcores-rsa5-4k.c.o _rsa_do_mod_addr in hw_misc_ipcores-rsa5-4k.c.o _rsa_do_montmul in hw_misc_ipcores-rsa5-4k.c.o _rsa_do_exp in hw_misc_ipcores-rsa5-4k.c.o _rsa_do_mul in hw_misc_ipcores-rsa5-4k.c.o : "_gcry_mpi_test_bit", referenced from: _gf_mul in hw_misc_ipcores-rsa5-4k.c.o _gf_lshift in hw_misc_ipcores-rsa5-4k.c.o _bin_xor in hw_misc_ipcores-rsa5-4k.c.o _rsa_do_gf_mod in hw_misc_ipcores-rsa5-4k.c.o _rsa_do_add in hw_misc_ipcores-rsa5-4k.c.o _rsa_do_sub in hw_misc_ipcores-rsa5-4k.c.o _rsa_do_mod_addr in hw_misc_ipcores-rsa5-4k.c.o ... ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
ライブラリ内には定義はされているぽい。
$ grep "_gcry_mpi_add" /usr/local/lib/* # : Binary file /usr/local/lib/libgcrypt.20.dylib matches Binary file /usr/local/lib/libgcrypt.a matches Binary file /usr/local/lib/libgcrypt.dylib matches
と存在していることは確か。
標準出力にコンパイル時の引数が表示されていたので、見てみると-lgcrypt
のライブラリが読み込まれてないことが判明。
とりあえず、configure
時に追加するようにした。
$ ../qemu/configure --target-list=aarch64-softmmu,microblazeel-softmmu,riscv64-softmmu --extra-ldflags="-lgcrypt" $ make
エラーなく実行ファイルができてそう。
$ ls qemu-system-*
qemu-system-aarch64 qemu-system-microblazeel qemu-system-riscv64
qemu-system-aarch64-unsigned qemu-system-microblazeel-unsigned qemu-system-riscv64-unsigned
これで、主要なビルドは終わった!...はず