My Haiku LoongArch (UEFI) port progress

Recently I am working on making Haiku LoongArch porting. It’s a really new arch for Haiku operating system, but I think it’s the time to begin.

  1. Our gcc toolchain is updated to 13.3, which supports loongarch64(the new world)
  2. I have one loongarch64 board, and it’s a great farm to work on.
  3. My job is referring to loongarch system adaption.

Now after some hacking to our buildtools, I have made our toolchain compiled for loongarch64:

my working repos(github):

referring:

work progress:

  1. toolchain with loongarch support [finished]
  2. haikuporter/haikuports.cross with loongarch support[initial support]
  3. base package cross bootstrap[wip]
    1. gcc_bootstrap finished.
    2. sys-devel [wip]
  4. qemu efi bootloader boot up
  5. qemu kernel boot up
  6. qemu system launch

my working repos(china):

18 Likes

I’ve heard that the latest Loongson cores are competitive per clock with the top-of-the-line x86-64 models. Is it based closely on the MIPS instruction set or has the LoongArch deviated and become its own?

In February 2021, Prestige Century Investments Limited and CIP United Company Limited (Shanghai Xinlianxin Intelligent Technology Co., Ltd.) initiated an arbitration with the Hong Kong International Arbitration Centre regarding the dispute over the MIPS technology licensing contract with Loongson Technology Corporation Limited. Ultimately, the Hong Kong International Arbitration Centre ruled that Xinlianxin is the losing party.

。。。。
so , become its own with a huge cash.

I see. I learned MIPS assembly langauge at Minnesota State University so I wondered about that. There isn’t much I can do with a Chinese architecture since I live in the U.S.A. but thanks for the update.

with gcc-bootstrap, I got error as below, it seems that wrapper-script got failed:

*** [Makefile:1046: all] Error 2
Command ‘[‘bash’, ‘-c’, ‘. /home/dev/haiku/generated.loongarch64/objects/haiku/loongarch64/packaging/repositories/HaikuPortsCross-build/sys-devel/gcc_bootstrap/work-13.2.0_2023_08_10/wrapper-script’]’ returned non-zero exit status 2.

Usually there will be more details much earlier in the build log. If you can share a complete build log, maybe we can spot it in there.

I shared the log : https://raw.githubusercontent.com/pengphei/haiku-loongarch-bootstrap/refs/heads/main/2025-01-13-gcc-bootstrap-error.log

1 Like

at line 6170 I can see that isl_test_cpp failed to link during gcc build. But there are no errors from the linker. Same thing again at line 12936. That looks like the first thing to understand and fix?

I see that you are running jam without the -q option, which means even if an error occurs, it will continue and try to build as much things as possible. This may make it harder to see the errors, with -q, jam will stop a bit earlier when a problem occurs and you can then fix it before moving on.

I see that you have tried to build both bootstrap and non-bootstrap builds, I’m not sure if that’s going to work well. Usually I keep the two separate in different generated directories.

Does your toolchain support PE format import/export capabilities (__declspec(dllimport))? I see, you have EDK2, which uses PE, but it doesn’t use importing/exporting, so asking.

Hi there. This is very cool. Can one already buy such a machine in Europe?

They have pretty fast CPUs by now. :slight_smile:

Best regards
Andreas

1 Like

I searched on aliexpress and found some selling at ~150 €

3 Likes

Do you have a link handy?

It forces me to login to view commit log? Seriously? Communist Party of China wants my personal information so deadly?

This is great, but unfortunately Gitee requires an account for even basic features such as viewing commit history and downloading repos as ZIP archives. Would you be open to reuploading your work to another Git forge? If GitHub is not an option, perhaps Codeberg could be a more amenable choice.

1 Like

hmmm, because the connection to github is not very good, I made a mirror for haiku’s repos to gitee. I will push my repos back to github today :wink: ,thanks for your advice.

I tried manually link isl_test_cpp, error as below :

dev@localhost:~/haiku/generated.loongarch64/objects/haiku/loongarch64/packaging/repositories/HaikuPortsCross-build/sys-devel/gcc_bootstrap/work-13.3.0_2025_01_13/sources/gcc_bootstrap-13.3.0_2025_01_13-obj/isl> /home/dev/haiku/generated.loongarch64/cross-tools-loongarch64/bin/loongarch64-unknown-haiku-g++ -O2 -static-libstdc++ -static-libgcc -o isl_test_cpp isl_test_cpp-isl_test_cpp.o  ./.libs/libisl.a /home/dev/haiku/generated.loongarch64/objects/haiku/loongarch64/packaging/repositories/HaikuPortsCross-build/sys-devel/gcc_bootstrap/work-13.3.0_2025_01_13/sources/gcc_bootstrap-13.3.0_2025_01_13-obj/./gmp/.libs/libgmp.a
/home/dev/haiku/generated.loongarch64/cross-tools-loongarch64/lib64/gcc/loongarch64-unknown-haiku/13.3.0/../../../../loongarch64-unknown-haiku/bin/ld: cannot find crti.o: 没有那个文件或目录
/home/dev/haiku/generated.loongarch64/cross-tools-loongarch64/lib64/gcc/loongarch64-unknown-haiku/13.3.0/../../../../loongarch64-unknown-haiku/bin/ld: cannot find start_dyn.o: 没有那个文件或目录
/home/dev/haiku/generated.loongarch64/cross-tools-loongarch64/lib64/gcc/loongarch64-unknown-haiku/13.3.0/../../../../loongarch64-unknown-haiku/bin/ld: cannot find init_term_dyn.o: 没有那个文件或目录
/home/dev/haiku/generated.loongarch64/cross-tools-loongarch64/lib64/gcc/loongarch64-unknown-haiku/13.3.0/../../../../loongarch64-unknown-haiku/bin/ld: cannot find -lroot: 没有那个文件或目录
/home/dev/haiku/generated.loongarch64/cross-tools-loongarch64/lib64/gcc/loongarch64-unknown-haiku/13.3.0/../../../../loongarch64-unknown-haiku/bin/ld: cannot find crtn.o: 没有那个文件或目录

and I can’t find these link files needed by haiku gcc config:

./gcc/gcc/config/haiku.h:#define STARTFILE_SPEC "crti.o%s crtbeginS.o%s %{!shared:%{!nostart:start_dyn.o%s}} init_term_dyn.o%s"

the great wall.
:joy:
:rofl:

They are in Haiku sources in src/system/glue/arch/

Did you fill that in and adjust he corresponding jamfiles already so your files are built?

The ld command is then run inside haikuporter, which is set up to make these files available as needed. I’m not sure you can run the same command outside of that environment.

the ld command can run outside of haikuporter :wink: . after some hacked to ctri/ctrn, now we have less error:

/home/dev/haiku/generated.loongarch64/cross-tools-loongarch64/bin/loongarch64-unknown-haiku-g++ -O2 -static-libstdc++ -static-libgcc -o isl_test_cpp isl_test_cpp-isl_test_cpp.o  ./.libs/libisl.a /home/dev/haiku/generated.loongarch64/objects/haiku/loongarch64/packaging/repositories/HaikuPortsCross-build/sys-devel/gcc_bootstrap/work-13.3.0_2025_01_13/sources/gcc_bootstrap-13.3.0_2025_01_13-obj/./gmp/.libs/libgmp.a
/home/dev/haiku/generated.loongarch64/cross-tools-loongarch64/lib64/gcc/loongarch64-unknown-haiku/13.3.0/../../../../loongarch64-unknown-haiku/bin/ld: cannot find start_dyn.o: 没有那个文件或目录
/home/dev/haiku/generated.loongarch64/cross-tools-loongarch64/lib64/gcc/loongarch64-unknown-haiku/13.3.0/../../../../loongarch64-unknown-haiku/bin/ld: cannot find init_term_dyn.o: 没有那个文件或目录
/home/dev/haiku/generated.loongarch64/cross-tools-loongarch64/lib64/gcc/loongarch64-unknown-haiku/13.3.0/../../../../loongarch64-unknown-haiku/bin/ld: cannot find -lroot: 没有那个文件或目录

But I don’t know where I can reach start_dyn.o init_term_dyn.o

All those are supposed to be built as part of Haiku itself, during the “stage 0” bootstrap. The build system creates a haiku_cross_devel_sysroot_stage0_<ARCH>.hpkg which should contain them.