unicorn icon indicating copy to clipboard operation
unicorn copied to clipboard

Add Backend Support for LoongArch64

Open tyssjhx opened this issue 2 years ago • 8 comments

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.

tyssjhx avatar Nov 01 '23 14:11 tyssjhx

Hello, nice contribution and looks good.

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

  • Add UC_ARCH_LONGARCH and related UC_MODE definitions to unicorn.h
  • Add a small sample like other architectures.
  • Generate register definitions like other archs.

And bonus (maybe in later PR):

  • Write a few unit tests
  • Generate definitions for all CPU models
  • Update bindings

wtdcode avatar Nov 14 '23 08:11 wtdcode

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

yetist avatar Nov 17 '23 14:11 yetist

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

bet4it avatar Dec 21 '23 03:12 bet4it

@bet4it I see. Anyway I can test this?

wtdcode avatar Dec 25 '23 12:12 wtdcode

Why not add LoongArch support in your DebianOnQEMU project😄

bet4it avatar Dec 25 '23 14:12 bet4it

Why not add LoongArch support in your DebianOnQEMU project😄

QEMU supports that? I will check and build ;)

wtdcode avatar Dec 25 '23 14:12 wtdcode

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 ;)

wtdcode avatar Dec 28 '23 09:12 wtdcode

@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?

zhaixiaojuan avatar May 30 '24 08:05 zhaixiaojuan