unicorn-engine / unicorn

Unicorn CPU emulator framework (ARM, AArch64, M68K, Mips, Sparc, PowerPC, RiscV, S390x, TriCore, X86)
http://www.unicorn-engine.org
GNU General Public License v2.0
7.33k stars 1.31k forks source link

Add Backend Support for LoongArch64 #1903

Open tyssjhx opened 8 months ago

tyssjhx commented 8 months ago

Add backend support for LoongArch64, fixing the conflicts with tcg function tcg_out_dupi_vec. The codes are tested by the unit tests on a LoongArch and a x86 machine.

wtdcode commented 7 months ago

Hello, nice contribution and looks good.

However, before getting merged, changes you need to do at least include:

And bonus (maybe in later PR):

yetist commented 7 months ago

Thank you for this PR.

I try to compile it on Loong Arch Linux, but during the linking phase I get the following error:

[ 92%] Bundling unicorn_archive
/usr/bin/ld: libaarch64-softmmu.a(tcg.c.o):(.bss+0x0): multiple definition of `use_lsx_instructions'; libx86_64-softmmu.a(tcg.c.o):(.bss+0x0): first defined here
/usr/bin/ld: libm68k-softmmu.a(tcg.c.o):(.bss+0x0): multiple definition of `use_lsx_instructions'; libx86_64-softmmu.a(tcg.c.o):(.bss+0x0): first defined here
/usr/bin/ld: libmips-softmmu.a(tcg.c.o):(.bss+0x0): multiple definition of `use_lsx_instructions'; libx86_64-softmmu.a(tcg.c.o):(.bss+0x0): first defined here
/usr/bin/ld: libmipsel-softmmu.a(tcg.c.o):(.bss+0x0): multiple definition of `use_lsx_instructions'; libx86_64-softmmu.a(tcg.c.o):(.bss+0x0): first defined here
/usr/bin/ld: libmips64-softmmu.a(tcg.c.o):(.bss+0x0): multiple definition of `use_lsx_instructions'; libx86_64-softmmu.a(tcg.c.o):(.bss+0x0): first defined here
/usr/bin/ld: libmips64el-softmmu.a(tcg.c.o):(.bss+0x0): multiple definition of `use_lsx_instructions'; libx86_64-softmmu.a(tcg.c.o):(.bss+0x0): first defined here
/usr/bin/ld: libsparc-softmmu.a(tcg.c.o):(.bss+0x0): multiple definition of `use_lsx_instructions'; libx86_64-softmmu.a(tcg.c.o):(.bss+0x0): first defined here
/usr/bin/ld: libsparc64-softmmu.a(tcg.c.o):(.bss+0x0): multiple definition of `use_lsx_instructions'; libx86_64-softmmu.a(tcg.c.o):(.bss+0x0): first defined here
/usr/bin/ld: libppc-softmmu.a(tcg.c.o):(.bss+0x0): multiple definition of `use_lsx_instructions'; libx86_64-softmmu.a(tcg.c.o):(.bss+0x0): first defined here
/usr/bin/ld: libppc64-softmmu.a(tcg.c.o):(.bss+0x0): multiple definition of `use_lsx_instructions'; libx86_64-softmmu.a(tcg.c.o):(.bss+0x0): first defined here
/usr/bin/ld: libriscv32-softmmu.a(tcg.c.o):(.bss+0x0): multiple definition of `use_lsx_instructions'; libx86_64-softmmu.a(tcg.c.o):(.bss+0x0): first defined here
/usr/bin/ld: libriscv64-softmmu.a(tcg.c.o):(.bss+0x0): multiple definition of `use_lsx_instructions'; libx86_64-softmmu.a(tcg.c.o):(.bss+0x0): first defined here
/usr/bin/ld: libs390x-softmmu.a(tcg.c.o):(.bss+0x0): multiple definition of `use_lsx_instructions'; libx86_64-softmmu.a(tcg.c.o):(.bss+0x0): first defined here
/usr/bin/ld: libtricore-softmmu.a(tcg.c.o):(.bss+0x0): multiple definition of `use_lsx_instructions'; libx86_64-softmmu.a(tcg.c.o):(.bss+0x0): first defined here
[ 92%] Built target bundling_target
collect2: 错误:ld 返回 1
bet4it commented 6 months ago

@wtdcode This PR adds support for a new backend rather than a new target.

wtdcode commented 6 months ago

@bet4it I see. Anyway I can test this?

bet4it commented 6 months ago

Why not add LoongArch support in your DebianOnQEMU project😄

wtdcode commented 6 months ago

Why not add LoongArch support in your DebianOnQEMU project😄

QEMU supports that? I will check and build ;)

wtdcode commented 6 months ago

Doesn't build on current Debian rootfs because kernel building has not been merged so far and compilers lack linux headers.

Tried on Loong Archlinux, gcc core dumped while clang give the same error as @yetist suggest. I will investigate a bit more later.

@bet4it I made it work by https://github.com/wtdcode/DebianOnQEMU?tab=readme-ov-file#loongarch64 ;)

zhaixiaojuan commented 1 month ago

@wtdcode

Tried on Loong Archlinux, gcc core dumped while clang give the same error as @yetist suggest. I will investigate a bit more later.

Is there any latest progress on this issue?