Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Backend Support for LoongArch64 #1903

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open

Conversation

tyssjhx
Copy link

@tyssjhx tyssjhx commented Nov 1, 2023

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.

zhaodongru and others added 2 commits November 1, 2023 21:54
fix: modify the code to pass compile

add: add code for tcg_out_op, tcg_can_emit_vec_op, tcg_target_op_def to support new tcg_op

fix: fix bugs related to epilogue and ret_addr

fix: fix bug in qemu_ld_slow_path, the return register is wrong
@wtdcode
Copy link
Member

wtdcode commented Nov 14, 2023

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

@yetist
Copy link

yetist commented Nov 17, 2023

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
Copy link
Contributor

bet4it commented Dec 21, 2023

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

@wtdcode
Copy link
Member

wtdcode commented Dec 25, 2023

@bet4it I see. Anyway I can test this?

@bet4it
Copy link
Contributor

bet4it commented Dec 25, 2023

Why not add LoongArch support in your DebianOnQEMU project😄

@wtdcode
Copy link
Member

wtdcode commented Dec 25, 2023

Why not add LoongArch support in your DebianOnQEMU project😄

QEMU supports that? I will check and build ;)

@wtdcode
Copy link
Member

wtdcode commented Dec 28, 2023

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants