Macで Xilinx/systemctlm-cosim-demo動かす(その2)
を 個人PC(Mac)で動かそうとしてます。
環境
- macOS Monterey 12.5
- Clang 14.0.6
前提
以下がインストールされている状態です。
動機
- 暇
(夏休み) - 面白そう
- 個人PC(Mac)で動くかやってみよう
構成
systemctlm-cosim-demo/docs/lmac-demos.md を見てみると必要な構成は以下の感じぽい
systemctlm-cosim-demoのビルド
systemctlm-cosim-demo/docs/lmac-demos.md 記載を参考に
$ git clone https://github.com/Xilinx/systemctlm-cosim-demo.git $ cd systemctlm-cosim-demo $ git submodule update --init # .config.mkの作成があるが、環境変数で設定しているのでスルー $ make libsystemctlm-soc/libremote-port/safeio.c:92:27: error: unknown type name 'off64_t'; did you mean 'off_t'? int rp_safe_copyfd(int s, off64_t off, size_t olen, int d) ^~~~~~~ off_t /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/usr/include/sys/_types/_off_t.h:31:33: note: 'off_t' declared here typedef __darwin_off_t off_t; ^ libsystemctlm-soc/libremote-port/safeio.c:101:2: warning: implicit declaration of function 'lseek64' is invalid in C99 [-Wimplicit-function-declaration] lseek64(s, off, SEEK_SET); ^ 1 warning and 1 error generated. make: *** [libsystemctlm-soc/libremote-port/safeio.o] Error 1
とりあえず以下のように修正
diff --git a/libremote-port/safeio.c b/libremote-port/safeio.c index 8dd4f29..3dbc3f6 100644 --- a/libremote-port/safeio.c +++ b/libremote-port/safeio.c @@ -89,7 +89,7 @@ rp_safe_write(int fd, const void *wbuf, size_t count) } /* Try to splice if possible. */ -int rp_safe_copyfd(int s, off64_t off, size_t olen, int d) +int rp_safe_copyfd(int s, off_t off, size_t olen, int d) { static unsigned char buf[16 * 1024]; int len = olen; @@ -98,7 +98,7 @@ int rp_safe_copyfd(int s, off64_t off, size_t olen, int d) int tlen = 0; D(fprintf(stderr, "%s off=%lld len=%d\n", __func__, off, len)); - lseek64(s, off, SEEK_SET); + lseek(s, off, SEEK_SET); #if 0 long r; do diff --git a/libremote-port/safeio.h b/libremote-port/safeio.h index bbd1373..0fca973 100644 --- a/libremote-port/safeio.h +++ b/libremote-port/safeio.h @@ -28,6 +28,6 @@ ssize_t rp_safe_read(int fd, void *buf, size_t count); ssize_t rp_safe_write(int fd, const void *buf, size_t count); -ssize_t rp_safe_copyfd(int s, off64_t off, size_t len, int d); +ssize_t rp_safe_copyfd(int s, off_t off, size_t len, int d); #endif
再度 make
$ make libsystemctlm-soc/libremote-port/remote-port-proto.c:61:12: fatal error: 'byteswap.h' file not found # include <byteswap.h> ^~~~~~~~~~~~ 1 error generated. make: *** [libsystemctlm-soc/libremote-port/remote-port-proto.o] Error 1
調べてみると、
Macだとbyteswap.h
の代わりに machine/endian.h
が該当するもよう。
ただ machine/endian.h
をみると、htobe64
やbe64toh
といったマクロが見つからないので適当に以下のような感じで対応した。(後日 GitHubの Issueで聞いてみようと思う)
--- a/libremote-port/remote-port-proto.c +++ b/libremote-port/remote-port-proto.c @@ -54,6 +54,15 @@ # define be64toh(x) _byteswap_uint64(x) # define be32toh(x) _byteswap_ulong(x) # define be16toh(x) _byteswap_ushort(x) +#elif defined(__APPLE__) +# include <machine/endian.h> +# define htobe64(x) htonll(x) +# define htobe32(x) htonl(x) +# define htobe16(x) htons(x) + +# define be64toh(x) ntohll(x) +# define be32toh(x) ntohl(x) +# define be16toh(x) ntohs(x) #endif /* Fallback for ancient Linux systems. */
再度 make
$ make
$ ls *_demo
versal_demo versal_mrmac_demo zynq_demo zynqmp_demo
いくつか Warningがあったもののビルドできたみたい。
前回単体でビルドしたやつだとエラーでなかったのはなぜだろう!?
続く