在主机(x86-64)上编译Mono应用程序后,我必须将生成的可执行文件复制到目标(AARCH64)。
在目标上,我必须使用'--aot'选项运行单声道以提高运行时性能。这很烦人,因为我必须为每个目标设备都这样做。
是否可以通过交叉编译方式在目标主机上运行AOT编译?
最诚挚的问候
-卡斯滕
更新:
问题是'mono --aot'执行'as'(也可能是ld):
...
Executing the native assembler: "as" -o /tmp/mono_aot_ENXWoc.o /tmp/mono_aot_ENXWoc
...
我认为必须针对交叉编译版本,例如arm-linux-gnueabi-as,...。我还没有找到该怎么做。稍后,我将查看单声道代码,以找出答案。
更新: 读取代码
https://github.com/mono/mono/blob/8ec9b12e53e4c0f7ab3fde48ebadf20cdb4bff1b/mono/mini/aot-compiler.c
和手册页
https://www.systutorials.com/docs/linux/man/1-mono
建议支持以下选项:
--aot=tool-prefix=arch64-linux-
更新:
上面的'tool-prefix'选项还不够。 Mono必须使用'--host'和'--target'配置选项作为交叉工具构建。否则,将生成用于主机体系结构的汇编代码:
# mono --aot=full,tool-prefix=aarch64-linux- src/helloworld.exe
Mono Ahead of Time compiler - compiling assembly
/home/behlingc/projects/.../helloworld.exe
AOTID 240451E8-B522-2A5C-2EC4-7D49CE189CF7
Code: 30(6%) Info: 5(1%) Ex Info: 24(4%) Unwind Info: 17(3%) Class Info: 30(6%)
PLT: 10(2%) GOT Info: 264(52%) Offsets: 120(24%) GOT: 216
Compiled: 2/2 (100%), No GOT slots: 1 (50%), Direct calls: 0 (100%)
Executing the native assembler: "aarch64-linux-as" -o
/tmp/mono_aot_5J2dOf.o /tmp/mono_aot_5J2dOf
/tmp/mono_aot_5J2dOf: Assembler messages:
/tmp/mono_aot_5J2dOf:140: Error: unknown mnemonic `call' -- `call .Lp_1'
/tmp/mono_aot_5J2dOf:156: Error: unknown mnemonic `call' -- `call .Lm_0'
/tmp/mono_aot_5J2dOf:157: Error: unknown mnemonic `call' -- `call .Lm_1'
/tmp/mono_aot_5J2dOf:158: Error: unknown mnemonic `call' -- `call
method_addresses'
/tmp/mono_aot_5J2dOf:236: Error: unknown mnemonic `jmp' -- `jmp
*mono_aot_helloworld_got+208(%rip)'
/tmp/mono_aot_5J2dOf:253: Error: junk at end of line, first unrecognized
character is `0'
AOT of image src/helloworld.exe failed.
从monos()configure.ac:
...
if test "x$host" != "x$target"; then
AC_DEFINE(MONO_CROSS_COMPILE,1,[The runtime is compiled for cross-compiling mode])
...
case "$target" in
...
aarch64*-linux-*)
TARGET=ARM64;
;;
...
更新:
与“ Cross Mono”配合使用(从我的Yocto构建中提取):
aarch64-pxc-linux-mono --aot=full,tool-prefix=aarch64-pxc-linux- bin/Debug/*.exe
结果:
Mono Ahead of Time compiler - compiling assembly /home/behlingc/projects/hmi-next/build-pxc/tmp-pxc-glibc/work/aarch64-pxc-linux/dual-can-test-tool/1.0-r0/<myapp>/bin/Debug/<myapp>.exe
AOTID 80A21DF5-6E8C-5D14-9C6C-F40370586870
Code: 73100(83%) Info: 1273(1%) Ex Info: 5459(6%) Unwind Info: 626(0%) Class Info: 3367(3%) PLT: 183(0%) GOT Info: 3113(3%) Offsets: 691(0%) GOT: 4168
Compiled: 57/57 (100%), No GOT slots: 21 (36%), Direct calls: 8 (38%)
Executing the native assembler: "aarch64-pxc-linux-as" -o /tmp/mono_aot_dlEBox.o /tmp/mono_aot_dlEBox
Executing the native linker: "aarch64-pxc-linux-ld" -shared -o /home/behlingc/projects/hmi-next/build-pxc/tmp-pxc-glibc/work/aarch64-pxc-linux/dual-can-test-tool/1.0-r0/DualCan_WIN32_Komplett_GUI_640x480/bin/Debug/DualCan_WIN32_Komplett_GUI_640x480.exe.so.tmp /tmp/mono_aot_dlEBox.o
JIT时间:19 ms,生成时间:10 ms,组装+链接时间:32 ms。 调试:Shell函数do_compile完成