|
| 1 | +From git@z Thu Jan 1 00:00:00 1970 |
| 2 | +Subject: [PATCH v3] buildroot: Add basic support for LoongArch architecture |
| 3 | + (toolchain only) |
| 4 | +From: Zhiwei Duan < [email protected]> |
| 5 | +Date: Mon, 12 Dec 2022 16:34:57 +0800 |
| 6 | + |
| 7 | +MIME-Version: 1.0 |
| 8 | +Content-Type: text/plain; charset="utf-8" |
| 9 | +Content-Transfer-Encoding: 7bit |
| 10 | + |
| 11 | +With this patch, the buildroot can compile the rootfs of the loongarch architecture. |
| 12 | +Both external toolchain and buildroot toolchain can compile rootfs. |
| 13 | +buildroot toolchain: binutils>=2.38 GCC>=12 Linux>=5.19 glibc>=2.36. |
| 14 | + |
| 15 | +Signed-off-by: Zhiwei Duan < [email protected]> |
| 16 | +Link: https://lore.kernel.org/r/ [email protected] |
| 17 | +--- |
| 18 | + arch/Config.in | 16 +++++++++++ |
| 19 | + arch/Config.in.loongarch | 52 ++++++++++++++++++++++++++++++++++++ |
| 20 | + package/glibc/Config.in | 1 + |
| 21 | + support/gnuconfig/config.sub | 11 ++++++-- |
| 22 | + toolchain/Config.in | 2 +- |
| 23 | + 5 files changed, 79 insertions(+), 3 deletions(-) |
| 24 | + create mode 100644 arch/Config.in.loongarch |
| 25 | + |
| 26 | +diff --git a/arch/Config.in b/arch/Config.in |
| 27 | +index 1c0c400a98..88f805bb1e 100644 |
| 28 | +--- a/arch/Config.in |
| 29 | ++++ b/arch/Config.in |
| 30 | +@@ -251,6 +251,17 @@ config BR2_xtensa |
| 31 | + http://en.wikipedia.org/wiki/Xtensa |
| 32 | + http://www.tensilica.com/ |
| 33 | + |
| 34 | ++config BR2_loongarch64 |
| 35 | ++ bool "LOONGARCH64 (little endian)" |
| 36 | ++ select BR2_ARCH_IS_64 |
| 37 | ++ select BR2_USE_MMU |
| 38 | ++ help |
| 39 | ++ LOONGARCH is a RISC microprocessor from LOONGARCH Technologies. Little |
| 40 | ++ endian. |
| 41 | ++ https://www.loongson.cn/ |
| 42 | ++ #http://en.wikipedia.org/wiki/MIPS_Technologies |
| 43 | ++ |
| 44 | ++ |
| 45 | + endchoice |
| 46 | + |
| 47 | + # For some architectures or specific cores, our internal toolchain |
| 48 | +@@ -414,6 +425,11 @@ if BR2_xtensa |
| 49 | + source "arch/Config.in.xtensa" |
| 50 | + endif |
| 51 | + |
| 52 | ++if BR2_loongarch64 |
| 53 | ++source "arch/Config.in.loongarch" |
| 54 | ++endif |
| 55 | ++ |
| 56 | ++ |
| 57 | + # Set up target binary format |
| 58 | + choice |
| 59 | + prompt "Target Binary Format" |
| 60 | +diff --git a/arch/Config.in.loongarch b/arch/Config.in.loongarch |
| 61 | +new file mode 100644 |
| 62 | +index 0000000000..bf86490cff |
| 63 | +--- /dev/null |
| 64 | ++++ b/arch/Config.in.loongarch |
| 65 | +@@ -0,0 +1,52 @@ |
| 66 | ++# loongarch config |
| 67 | ++config BR2_LOONGARCH_CPU_LOONGARCH64 |
| 68 | ++ bool |
| 69 | ++ select BR2_LOONGARCH_NAN_LEGACY |
| 70 | ++ |
| 71 | ++choice |
| 72 | ++ prompt "Target Architecture Variant" |
| 73 | ++ default BR2_loongarch_64 if BR2_loongarch64 |
| 74 | ++ depends on BR2_loongarch64 |
| 75 | ++ help |
| 76 | ++ Specific CPU variant to use |
| 77 | ++ |
| 78 | ++config BR2_loongarch_64 |
| 79 | ++ bool "Generic LOONGARCH64" |
| 80 | ++ depends on BR2_ARCH_IS_64 |
| 81 | ++ select BR2_LOONGARCH_CPU_LOONGARCH64 |
| 82 | ++endchoice |
| 83 | ++ |
| 84 | ++config BR2_LOONGARCH_NAN_LEGACY |
| 85 | ++ bool |
| 86 | ++ |
| 87 | ++#config BR2_GCC_TARGET_NAN |
| 88 | ++# default "legacy" if BR2_LOONGARCH_NAN_LEGACY |
| 89 | ++ |
| 90 | ++config BR2_ARCH |
| 91 | ++ default "loongarch64" if BR2_loongarch64 |
| 92 | ++ |
| 93 | ++config BR2_NORMALIZED_ARCH |
| 94 | ++ default "loongarch" |
| 95 | ++ |
| 96 | ++config BR2_ENDIAN |
| 97 | ++ default "LITTLE" if BR2_loongarch64 |
| 98 | ++ |
| 99 | ++config BR2_GCC_TARGET_ARCH |
| 100 | ++ default "loongarch64" if BR2_loongarch_64 |
| 101 | ++ |
| 102 | ++config BR2_READELF_ARCH_NAME |
| 103 | ++ default "LoongArch" |
| 104 | ++ |
| 105 | ++config BR2_LOONGARCH_SOFT_FLOAT |
| 106 | ++ bool "Use soft-float" |
| 107 | ++ #default y |
| 108 | ++ select BR2_SOFT_FLOAT |
| 109 | ++ help |
| 110 | ++ If your target CPU does not have a Floating Point Unit (FPU) |
| 111 | ++ or a kernel FPU emulator, but you still wish to support |
| 112 | ++ floating point functions, then everything will need to be |
| 113 | ++ compiled with soft floating point support (-msoft-float). |
| 114 | ++ |
| 115 | ++ |
| 116 | ++# vim: ft=kconfig |
| 117 | ++# -*- mode:kconfig; -*- |
| 118 | +diff --git a/package/glibc/Config.in b/package/glibc/Config.in |
| 119 | +index 71c50504ac..d8325610f5 100644 |
| 120 | +--- a/package/glibc/Config.in |
| 121 | ++++ b/package/glibc/Config.in |
| 122 | +@@ -21,6 +21,7 @@ config BR2_PACKAGE_GLIBC_ARCH_SUPPORTS |
| 123 | + default y if BR2_microblaze |
| 124 | + default y if BR2_nios2 |
| 125 | + default y if BR2_arc && BR2_ARC_ATOMIC_EXT |
| 126 | ++ default y if BR2_loongarch64 |
| 127 | + depends on !BR2_powerpc_SPE |
| 128 | + depends on BR2_RISCV_ISA_RVA || !BR2_riscv |
| 129 | + depends on BR2_USE_MMU |
| 130 | +diff --git a/support/gnuconfig/config.sub b/support/gnuconfig/config.sub |
| 131 | +index 9bc49a7e92..c751ddf15a 100755 |
| 132 | +--- a/support/gnuconfig/config.sub |
| 133 | ++++ b/support/gnuconfig/config.sub |
| 134 | +@@ -164,7 +164,7 @@ case $1 in |
| 135 | + basic_os=$field2 |
| 136 | + ;; |
| 137 | + # Manufacturers |
| 138 | +- dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \ |
| 139 | ++ dec* | mips* | loongarch* | sequent* | encore* | pc533* | sgi* | sony* \ |
| 140 | + | att* | 7300* | 3300* | delta* | motorola* | sun[234]* \ |
| 141 | + | unicom* | ibm* | next | hp | isi* | apollo | altos* \ |
| 142 | + | convergent* | ncr* | news | 32* | 3600* | 3100* \ |
| 143 | +@@ -632,6 +632,11 @@ case $1 in |
| 144 | + basic_machine=ymp-cray |
| 145 | + basic_os=unicos |
| 146 | + ;; |
| 147 | ++ loongarch) |
| 148 | ++ basic_machine=loongarch-loongson |
| 149 | ++ basic_os= |
| 150 | ++ ;; |
| 151 | ++ |
| 152 | + *) |
| 153 | + basic_machine=$1 |
| 154 | + basic_os= |
| 155 | +@@ -1211,6 +1216,7 @@ case $cpu-$vendor in |
| 156 | + | mipsisa64sr71k | mipsisa64sr71kel \ |
| 157 | + | mipsr5900 | mipsr5900el \ |
| 158 | + | mipstx39 | mipstx39el \ |
| 159 | ++ | loongarch | loongarch64 \ |
| 160 | + | mmix \ |
| 161 | + | mn10200 | mn10300 \ |
| 162 | + | moxie \ |
| 163 | +@@ -1253,7 +1259,8 @@ case $cpu-$vendor in |
| 164 | + | x86 | x86_64 | xc16x | xgate | xps100 \ |
| 165 | + | xstormy16 | xtensa* \ |
| 166 | + | ymp \ |
| 167 | +- | z8k | z80) |
| 168 | ++ | z8k | z80 \ |
| 169 | ++ | loongarch | loongarch64) |
| 170 | + ;; |
| 171 | + |
| 172 | + *) |
| 173 | +diff --git a/toolchain/Config.in b/toolchain/Config.in |
| 174 | +index 4947ab3aae..a4939af6fb 100644 |
| 175 | +--- a/toolchain/Config.in |
| 176 | ++++ b/toolchain/Config.in |
| 177 | +@@ -24,7 +24,7 @@ config BR2_TOOLCHAIN_USES_UCLIBC |
| 178 | + # architectures |
| 179 | + select BR2_TOOLCHAIN_HAS_UCONTEXT if BR2_ARM_CPU_HAS_ARM || BR2_i386 \ |
| 180 | + || BR2_mips || BR2_mipsel || BR2_mips64 || BR2_mips64el \ |
| 181 | +- || BR2_sparc || BR2_x86_64 |
| 182 | ++ || BR2_sparc || BR2_x86_64 || BR2_loongarch64 |
| 183 | + select BR2_TOOLCHAIN_SUPPORTS_PIE if !BR2_m68k && !BR2_microblaze && !BR2_STATIC_LIBS |
| 184 | + |
| 185 | + config BR2_TOOLCHAIN_USES_MUSL |
| 186 | +-- |
| 187 | +2.20.1 |
| 188 | + |
| 189 | +_______________________________________________ |
| 190 | +buildroot mailing list |
| 191 | + |
| 192 | +https://lists.buildroot.org/mailman/listinfo/buildroot |
| 193 | + |
0 commit comments