diff --git a/cross-toolchain.spec b/cross-toolchain.spec index d6f85e0..b755ca9 100644 --- a/cross-toolchain.spec +++ b/cross-toolchain.spec @@ -41,6 +41,13 @@ %define target_libdir lib64 %endif +%if "%target_arch" == "loongarch64" +%define target_kernel loongarch +%define target_qemu_arch loongarch64 +%define target_ld_linux /lib64/ld-linux-loongarch-lp64d.so.1 +%define target_libdir lib64 +%endif + %if "%target_arch" != "arm" %define target %target_arch-linux-gnu %else @@ -64,7 +71,11 @@ ExclusiveArch: x86_64 %define gcc_branch %(v=%gcc_version; v=${v%%%%.*}; echo $v) %define binutils_version %{get_version binutils-source} %define glibc_version %{get_version glibc-source} +%if "%target_arch" == "loongarch64" +%define kernel_version 6.0 +%else %define kernel_version 5.10 +%endif BuildPreReq: gcc-c++ @@ -540,6 +551,29 @@ _start: EOF %endif +%if "%target_arch" == "loongarch64" +cat > bye.S < + +.data +message: .asciz "bye-bye ...\n" + +.text +.global _start +_start: + li.w \$a7, __NR_write + li.w \$a0, 1 # stdout file descriptor + la \$a1, message + li.w \$a2, 12 # message length + syscall 0x0 + + li.w \$a7, __NR_exit + li.w \$a0, 0 + syscall 0x0 + +.section .note.GNU-stack,"",@progbits +EOF + env PATH=%buildroot%prefix/bin:$PATH \ %buildroot%prefix/bin/%target-gcc -static -nostdlib -o bye_asm bye.S || exit 11 qemu-%target_qemu_arch-static ./bye_asm || exit 13