diff mbox series

buildroot: Add support for LoongArch

Message ID e7c091e6-afdf-4f1b-0d38-dfabc267bde0@loongson.cn
State Superseded
Headers show
Series buildroot: Add support for LoongArch | expand

Commit Message

Zhiwei Duan Dec. 5, 2022, 3:12 a.m. UTC
From: Zhiwei Duan <duanzhiwei@loongson.cn>

With this patch, buildroot works well on LoongArch.

Signed-off-by: Zhiwei Duan <duanzhiwei@loongson.cn>
---
  arch/Config.in               | 16 +++++++++++
  arch/Config.in.loongarch     | 52 ++++++++++++++++++++++++++++++++++++
  package/glibc/Config.in      |  1 +
  support/gnuconfig/config.sub | 11 ++++++--
  toolchain/Config.in          |  2 +-
  5 files changed, 79 insertions(+), 3 deletions(-)
  create mode 100644 arch/Config.in.loongarch


  config BR2_TOOLCHAIN_USES_MUSL

Comments

Bagas Sanjaya Dec. 5, 2022, 4:14 a.m. UTC | #1
On 12/5/22 10:12, duan wrote:
> From: Zhiwei Duan <duanzhiwei@loongson.cn>
> 
> With this patch, buildroot works well on LoongArch.
> 

What about "Add basic support for LoongArch architecture (toolchain
only)."?
Zhiwei Duan Dec. 5, 2022, 6:37 a.m. UTC | #2
Add basic support for LoongArch architecture.
Both external tool chains and internal tool chains can compile rootfs.

> -----原始邮件-----
> 发件人: "Bagas Sanjaya" <bagasdotme@gmail.com>
> 发送时间:2022-12-05 12:14:13 (星期一)
> 收件人: buildroot@buildroot.org
> 抄送: 
> 主题: Re: [Buildroot] [PATCH] buildroot: Add support for LoongArch
> 
> On 12/5/22 10:12, duan wrote:
> > From: Zhiwei Duan <duanzhiwei@loongson.cn>
> > 
> > With this patch, buildroot works well on LoongArch.
> > 
> 
> What about "Add basic support for LoongArch architecture (toolchain
> only)."?
> 
> -- 
> An old man doll... just what I always wanted! - Clara
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot


本邮件及其附件含有龙芯中科的商业秘密信息,仅限于发送给上面地址中列出的个人或群组。禁止任何其他人以任何形式使用(包括但不限于全部或部分地泄露、复制或散发)本邮件及其附件中的信息。如果您错收本邮件,请您立即电话或邮件通知发件人并删除本邮件。 
This email and its attachments contain confidential information from Loongson Technology , which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this email in error, please notify the sender by phone or email immediately and delete it.
Bagas Sanjaya Dec. 5, 2022, 7:54 a.m. UTC | #3
On 12/5/22 13:37, 段志伟 wrote:
> Add basic support for LoongArch architecture.
> Both external tool chains and internal tool chains can compile rootfs.
> 

Please send v2 with my suggestions addressed instead.
diff mbox series

Patch

diff --git a/arch/Config.in b/arch/Config.in
index 1c0c400a98..ccb47a8104 100644
--- a/arch/Config.in
+++ b/arch/Config.in
@@ -251,6 +251,17 @@  config BR2_xtensa
http://en.wikipedia.org/wiki/Xtensa
http://www.tensilica.com/

+config BR2_loongarch64
+    bool "LOONGARCH64 (little endian)"
+    select BR2_ARCH_IS_64
+    select BR2_USE_MMU
+    help
+      MIPS is a RISC microprocessor from MIPS Technologies. Little
+      endian.
+ https://www.loongson.cn/
+      #http://en.wikipedia.org/wiki/MIPS_Technologies
+
+
  endchoice

  # For some architectures or specific cores, our internal toolchain
@@ -414,6 +425,11 @@  if BR2_xtensa
  source "arch/Config.in.xtensa"
  endif

+if BR2_loongarch64
+source "arch/Config.in.loongarch"
+endif
+
+
  # Set up target binary format
  choice
      prompt "Target Binary Format"
diff --git a/arch/Config.in.loongarch b/arch/Config.in.loongarch
new file mode 100644
index 0000000000..80e332d186
--- /dev/null
+++ b/arch/Config.in.loongarch
@@ -0,0 +1,52 @@ 
+# mips default CPU ISAs
+config BR2_LOONGARCH_CPU_LOONGARCH64
+    bool
+    select BR2_LOONGARCH_NAN_LEGACY
+
+choice
+    prompt "Target Architecture Variant"
+    default BR2_loongarch_64 if BR2_loongarch64
+    depends on BR2_loongarch64
+    help
+      Specific CPU variant to use
+
+config BR2_loongarch_64
+    bool "Generic LOONGARCH64"
+    depends on BR2_ARCH_IS_64
+    select BR2_LOONGARCH_CPU_LOONGARCH64
+endchoice
+
+config BR2_LOONGARCH_NAN_LEGACY
+    bool
+
+#config BR2_GCC_TARGET_NAN
+#    default "legacy"    if BR2_LOONGARCH_NAN_LEGACY
+
+config BR2_ARCH
+    default "loongarch64"    if BR2_loongarch64
+
+config BR2_NORMALIZED_ARCH
+    default "loongarch"
+
+config BR2_ENDIAN
+    default "LITTLE"    if BR2_loongarch64
+
+config BR2_GCC_TARGET_ARCH
+    default "loongarch64"    if BR2_loongarch_64
+
+config BR2_READELF_ARCH_NAME
+    default "LoongArch"
+
+config BR2_LOONGARCH_SOFT_FLOAT
+        bool "Use soft-float"
+        #default y
+        select BR2_SOFT_FLOAT
+        help
+          If your target CPU does not have a Floating Point Unit (FPU)
+          or a kernel FPU emulator, but you still wish to support
+          floating point functions, then everything will need to be
+          compiled with soft floating point support (-msoft-float).
+
+
+# vim: ft=kconfig
+# -*- mode:kconfig; -*-
diff --git a/package/glibc/Config.in b/package/glibc/Config.in
index 71c50504ac..d8325610f5 100644
--- a/package/glibc/Config.in
+++ b/package/glibc/Config.in
@@ -21,6 +21,7 @@  config BR2_PACKAGE_GLIBC_ARCH_SUPPORTS
      default y if BR2_microblaze
      default y if BR2_nios2
      default y if BR2_arc && BR2_ARC_ATOMIC_EXT
+    default y if BR2_loongarch64
      depends on !BR2_powerpc_SPE
      depends on BR2_RISCV_ISA_RVA || !BR2_riscv
      depends on BR2_USE_MMU
diff --git a/support/gnuconfig/config.sub b/support/gnuconfig/config.sub
index 9bc49a7e92..c751ddf15a 100755
--- a/support/gnuconfig/config.sub
+++ b/support/gnuconfig/config.sub
@@ -164,7 +164,7 @@  case $1 in
                          basic_os=$field2
                          ;;
                      # Manufacturers
-                    dec* | mips* | sequent* | encore* | pc533* | sgi* | 
sony* \
+                    dec* | mips* | loongarch* | sequent* | encore* | 
pc533* | sgi* | sony* \
                      | att* | 7300* | 3300* | delta* | motorola* | 
sun[234]* \
                      | unicom* | ibm* | next | hp | isi* | apollo | 
altos* \
                      | convergent* | ncr* | news | 32* | 3600* | 3100* \
@@ -632,6 +632,11 @@  case $1 in
                  basic_machine=ymp-cray
                  basic_os=unicos
                  ;;
+            loongarch)
+                basic_machine=loongarch-loongson
+                basic_os=
+                ;;
+
              *)
                  basic_machine=$1
                  basic_os=
@@ -1211,6 +1216,7 @@  case $cpu-$vendor in
              | mipsisa64sr71k | mipsisa64sr71kel \
              | mipsr5900 | mipsr5900el \
              | mipstx39 | mipstx39el \
+            | loongarch | loongarch64 \
              | mmix \
              | mn10200 | mn10300 \
              | moxie \
@@ -1253,7 +1259,8 @@  case $cpu-$vendor in
              | x86 | x86_64 | xc16x | xgate | xps100 \
              | xstormy16 | xtensa* \
              | ymp \
-            | z8k | z80)
+            | z8k | z80 \
+            | loongarch | loongarch64)
                  ;;

              *)
diff --git a/toolchain/Config.in b/toolchain/Config.in
index 4947ab3aae..a4939af6fb 100644
--- a/toolchain/Config.in
+++ b/toolchain/Config.in
@@ -24,7 +24,7 @@  config BR2_TOOLCHAIN_USES_UCLIBC
      # architectures
      select BR2_TOOLCHAIN_HAS_UCONTEXT if BR2_ARM_CPU_HAS_ARM || 
BR2_i386 \
          || BR2_mips || BR2_mipsel || BR2_mips64 || BR2_mips64el \
-        || BR2_sparc || BR2_x86_64
+        || BR2_sparc || BR2_x86_64 || BR2_loongarch64
      select BR2_TOOLCHAIN_SUPPORTS_PIE if !BR2_m68k && !BR2_microblaze 
&& !BR2_STATIC_LIBS