public inbox for development@lists.ipfire.org
 help / color / mirror / Atom feed
* [PATCH v1 0/8] Add loongarch64 architecture support to IPFire
@ 2026-08-05  2:39 Vincent Li
  2026-08-05  2:39 ` [PATCH v1 1/8] make.sh: Add support for building on loongarch64 Vincent Li
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Vincent Li @ 2026-08-05  2:39 UTC (permalink / raw)
  To: Michael Tremer, development; +Cc: Vincent Li

This patch series adds initial support for the LoongArch64 architecture
to the IPFire build system and installer. LoongArch64 is the 64-bit
RISC architecture developed by Loongson Technology, using UEFI as its
standard firmware interface.

The series includes:

1. **Build system detection** (make.sh): Add architecture detection
   for loongarch64 in the main build script.

2. **Toolchain fixes** (gcc): Fix dynamic linker path for native
   bootstrap to ensure glibc builds correctly.

3. **Package build system** (lfs/Config): Update config.guess/sub
   scripts to recognize loongarch64 as a valid architecture.

4. **EFI and GRUB support** (lfs/Config): Define architecture
   variables for building EFI firmware and GRUB for loongarch64.

5. **Go language support** (lfs/Config): Set GOARCH=loong64 for
   building Go packages.

6. **Installer EFI detection** (installer): Enable EFI boot mode
   detection for loongarch64 systems.

7. **Installer bootloader** (installer): Add GRUB installation
   support for loongarch64-efi.

8. **Kernel build** (kernel): Add architecture definitions and
   special handling for building the Linux kernel on loongarch64.

These changes are the foundation for a complete loongarch64 port
of IPFire and have been tested on a LoongArch64 development system.

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
---
  make.sh: Add support for building on loongarch64
  gcc: Add dynamic linker path for loongarch64 native toolchain build
  lfs/Config: Update config.guess and config.sub for loongarch64 support
  lfs/Config: Add EFI and GRUB architecture definitions for loongarch64
  lfs/Config: Set GOARCH for loongarch64 builds
  installer: Enable EFI support for loongarch64
  installer: Add bootloader installation support for loongarch64
  kernel: Add build support for loongarch64

 .../kernel/kernel.config.loongarch64-ipfire   |  7814 +++++
 config/rootfiles/common/loongarch64/linux     | 23754 ++++++++++++++++
 lfs/Config                                    |    14 +-
 lfs/gcc                                       |     4 +
 lfs/linux                                     |    10 +
 make.sh                                       |     7 +-
 src/installer/hw.c                            |     3 +-
 src/installer/install-bootloader              |     3 +
 8 files changed, 31605 insertions(+), 4 deletions(-)
 create mode 100644 config/kernel/kernel.config.loongarch64-ipfire
 create mode 100644 config/rootfiles/common/loongarch64/linux

-- 
2.38.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v1 1/8] make.sh: Add support for building on loongarch64
  2026-08-05  2:39 [PATCH v1 0/8] Add loongarch64 architecture support to IPFire Vincent Li
@ 2026-08-05  2:39 ` Vincent Li
  2026-08-05  2:39 ` [PATCH v1 2/8] gcc: Add dynamic linker path for loongarch64 native toolchain build Vincent Li
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Vincent Li @ 2026-08-05  2:39 UTC (permalink / raw)
  To: Michael Tremer, development; +Cc: Vincent Li

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
---
 make.sh | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/make.sh b/make.sh
index 37f01c1a2..fd8b777a3 100755
--- a/make.sh
+++ b/make.sh
@@ -49,6 +49,7 @@ KVER="${KVER/-rc/.0-rc}${KVER_SUFFIX}"
 # All supported architectures
 ARCHES=(
 	aarch64
+	loongarch64
 	riscv64
 	x86_64
 )
@@ -2415,7 +2416,7 @@ done
 
 # Check the architecture
 case "${BUILD_ARCH}" in
-	aarch64|x86_64|riscv64)
+	aarch64|x86_64|riscv64|loongarch64)
 		;;
 
 	*)
@@ -2429,6 +2430,10 @@ case "${BUILD_ARCH}" in
 		BUILD_PLATFORM="arm"
 		;;
 
+	loongarch64)
+		BUILD_PLATFORM="loongarch"
+		;;
+
 	riscv64)
 		BUILD_PLATFORM="riscv"
 		;;
-- 
2.38.1



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v1 2/8] gcc: Add dynamic linker path for loongarch64 native toolchain build
  2026-08-05  2:39 [PATCH v1 0/8] Add loongarch64 architecture support to IPFire Vincent Li
  2026-08-05  2:39 ` [PATCH v1 1/8] make.sh: Add support for building on loongarch64 Vincent Li
@ 2026-08-05  2:39 ` Vincent Li
  2026-08-05  2:39 ` [PATCH v1 3/8] lfs/Config: Update config.guess and config.sub for loongarch64 support Vincent Li
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Vincent Li @ 2026-08-05  2:39 UTC (permalink / raw)
  To: Michael Tremer, development; +Cc: Vincent Li, Vincent Li

When building GCC natively on loongarch64 as part of the toolchain
bootstrap, the generated spec file incorrectly uses the default system
library path "/lib" for the dynamic linker. This causes the glibc build
to fail during validation because the compiled test program requests
the system runtime linker at /lib/ld-linux-loongarch-lp64d.so.1 instead
of the toolchain-specific path /tools_loongarch64/lib/.

The ABI_GRLEN_SPEC macro in gcc/config/loongarch/gnu-user.h defines
the dynamic linker path pattern. During the initial toolchain bootstrap
stage (PASS=1 with TOOLCHAIN=1), this needs to reference $(TOOLS_DIR)/lib
where the bootstrap runtime linker is installed, rather than the system
/lib path which may not yet have a compatible runtime linker.

Add a conditional sed substitution for loongarch64 builds that replaces
'"/lib" ABI_GRLEN_SPEC' with '"$(TOOLS_DIR)/lib" ABI_GRLEN_SPEC' in
gnu-user.h. This ensures GCC generates the correct dynamic linker path
for the bootstrap environment.

Without this change, the glibc build validation fails with:
  readelf -l dummy | grep "Requesting program interpreter: /tools_loongarch64"
  make: *** [glibc:131: /usr/src/ipfire-2.x/log_loongarch64/glibc-2.43-tools] Error 1

Assisted-by: DeepSeek-V4-Flash
Signed-off-by: Vincent Li <Vincent Li <vincent.mc.li@gmail.com>
---
 lfs/gcc | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lfs/gcc b/lfs/gcc
index c3a8da602..6645b2e03 100644
--- a/lfs/gcc
+++ b/lfs/gcc
@@ -229,6 +229,10 @@ ifeq "$(TOOLCHAIN)" "1"
 	cd $(DIR_APP) && tar xfa $(DIR_DL)/mpc-$(MPC_VER).tar.gz
 	cd $(DIR_APP) && mv -v mpc-$(MPC_VER) mpc
 
+ifeq "$(BUILD_ARCH)" "loongarch64"
+	sed -i '/ABI_GRLEN_SPEC/s@"/lib" ABI_GRLEN_SPEC@"$(TOOLS_DIR)/lib" ABI_GRLEN_SPEC@g' $(DIR_APP)/gcc/config/loongarch/gnu-user.h
+endif
+
 	for file in $$(find $(DIR_APP)/gcc/config -name linux64.h -o -name linux.h \
 			-o -name sysv4.h -o -name linux-eabi.h -o -name linux-elf.h -o -name aarch64-linux.h); do \
 		echo "Processing $${file}..."; \
-- 
2.38.1



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v1 3/8] lfs/Config: Update config.guess and config.sub for loongarch64 support
  2026-08-05  2:39 [PATCH v1 0/8] Add loongarch64 architecture support to IPFire Vincent Li
  2026-08-05  2:39 ` [PATCH v1 1/8] make.sh: Add support for building on loongarch64 Vincent Li
  2026-08-05  2:39 ` [PATCH v1 2/8] gcc: Add dynamic linker path for loongarch64 native toolchain build Vincent Li
@ 2026-08-05  2:39 ` Vincent Li
  2026-08-05  2:39 ` [PATCH v1 4/8] lfs/Config: Add EFI and GRUB architecture definitions for loongarch64 Vincent Li
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Vincent Li @ 2026-08-05  2:39 UTC (permalink / raw)
  To: Michael Tremer, development; +Cc: Vincent Li

Some software packages contain outdated config.guess and config.sub
scripts that do not recognize loongarch64 as a valid architecture.
This causes build failures when configuring packages that use these
scripts to detect the target platform.

Extend the UPDATE_AUTOMAKE macro to also apply to loongarch64 builds,
ensuring that config.guess and config.sub are updated from the system
automake installation for all packages.

This brings loongarch64 in line with the existing behavior for aarch64
and riscv64 architectures, where these scripts are already updated to
support those newer architectures.

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
---
 lfs/Config | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lfs/Config b/lfs/Config
index 5abcd0715..2334d5f0a 100644
--- a/lfs/Config
+++ b/lfs/Config
@@ -476,7 +476,7 @@ define INSTALL_INITSCRIPTS
     done
 endef
 
-ifeq "$(BUILD_ARCH)" "$(filter $(BUILD_ARCH),aarch64 riscv64)"
+ifeq "$(BUILD_ARCH)" "$(filter $(BUILD_ARCH),aarch64 riscv64 loongarch64)"
 define UPDATE_AUTOMAKE
 	for i in $$(find $(DIR_APP) -name config.guess -o -name config.sub); do \
 		cp -vf /usr/share/automake*/$$(basename $${i}) $${i} || \
-- 
2.38.1



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v1 4/8] lfs/Config: Add EFI and GRUB architecture definitions for loongarch64
  2026-08-05  2:39 [PATCH v1 0/8] Add loongarch64 architecture support to IPFire Vincent Li
                   ` (2 preceding siblings ...)
  2026-08-05  2:39 ` [PATCH v1 3/8] lfs/Config: Update config.guess and config.sub for loongarch64 support Vincent Li
@ 2026-08-05  2:39 ` Vincent Li
  2026-08-05  2:39 ` [PATCH v1 5/8] lfs/Config: Set GOARCH for loongarch64 builds Vincent Li
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Vincent Li @ 2026-08-05  2:39 UTC (permalink / raw)
  To: Michael Tremer, development; +Cc: Vincent Li

Add support for building EFI bootable images on loongarch64 by defining
the appropriate architecture variables. This enables the build system
to correctly locate and build the EFI firmware, GRUB bootloader, and
associated boot components for the LoongArch64 architecture.

- Set EFI=1 to enable EFI support
- Set EFI_ARCH=LOONGARCH64 for EFI firmware selection
- Set GRUB_ARCH=loongarch64 to build the correct GRUB target

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
---
 lfs/Config | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lfs/Config b/lfs/Config
index 2334d5f0a..06ba065ea 100644
--- a/lfs/Config
+++ b/lfs/Config
@@ -111,7 +111,7 @@ DIR_TMP_PAK = $(DIR_TMP)/package-$(PROG)
 # Add the compiler location and version and specs to the ccache hash
 CCACHE_COMPILERCHECK += $(shell gcc -dumpspecs 2>/dev/null | md5sum | cut -d ' ' -f1)
 
-# We support EFI on x86_64 riscv64 and aarch64
+# We support EFI on x86_64 riscv64 aarch64 and loongarch64
 ifeq "$(BUILD_ARCH)" "x86_64"
 	EFI = 1
 	EFI_ARCH = x64
@@ -130,6 +130,12 @@ ifeq "$(BUILD_ARCH)" "aarch64"
 	GRUB_ARCH = arm64
 endif
 
+ifeq "$(BUILD_ARCH)" "loongarch64"
+	EFI = 1
+	EFI_ARCH = LOONGARCH64
+	GRUB_ARCH = $(BUILD_ARCH)
+endif
+
 CMAKE = cmake
 
 # In the toolchain, we might be cross-compiling and need cmake to know
-- 
2.38.1



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v1 5/8] lfs/Config: Set GOARCH for loongarch64 builds
  2026-08-05  2:39 [PATCH v1 0/8] Add loongarch64 architecture support to IPFire Vincent Li
                   ` (3 preceding siblings ...)
  2026-08-05  2:39 ` [PATCH v1 4/8] lfs/Config: Add EFI and GRUB architecture definitions for loongarch64 Vincent Li
@ 2026-08-05  2:39 ` Vincent Li
  2026-08-05  2:39 ` [PATCH v1 6/8] installer: Enable EFI support for loongarch64 Vincent Li
  2026-08-05  2:39 ` [PATCH v1 7/8] installer: Add bootloader installation " Vincent Li
  6 siblings, 0 replies; 8+ messages in thread
From: Vincent Li @ 2026-08-05  2:39 UTC (permalink / raw)
  To: Michael Tremer, development; +Cc: Vincent Li

Define GOARCH=loong64 for loongarch64 architecture builds to enable
proper Go language compilation support. The Go programming language
uses "loong64" as the architecture identifier for LoongArch 64-bit
systems.

This allows any Go packages in the build system to compile correctly
for the loongarch64 target by providing the correct GOARCH value during
the build process.

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
---
 lfs/Config | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lfs/Config b/lfs/Config
index 06ba065ea..fea0fcbbd 100644
--- a/lfs/Config
+++ b/lfs/Config
@@ -157,6 +157,10 @@ ifeq "$(BUILD_ARCH)" "aarch64"
 	GOARCH = arm64
 endif
 
+ifeq "$(BUILD_ARCH)" "loongarch64"
+	GOARCH = loong64
+endif
+
 # Rust
 ifeq "$(BUILD_ARCH)" "riscv64"
 	RUST_ARCH = riscv64gc
-- 
2.38.1



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v1 6/8] installer: Enable EFI support for loongarch64
  2026-08-05  2:39 [PATCH v1 0/8] Add loongarch64 architecture support to IPFire Vincent Li
                   ` (4 preceding siblings ...)
  2026-08-05  2:39 ` [PATCH v1 5/8] lfs/Config: Set GOARCH for loongarch64 builds Vincent Li
@ 2026-08-05  2:39 ` Vincent Li
  2026-08-05  2:39 ` [PATCH v1 7/8] installer: Add bootloader installation " Vincent Li
  6 siblings, 0 replies; 8+ messages in thread
From: Vincent Li @ 2026-08-05  2:39 UTC (permalink / raw)
  To: Michael Tremer, development; +Cc: Vincent Li

Add loongarch64 to the list of architectures that support EFI boot mode
in the installer hardware detection logic. This enables the installer
to correctly detect and configure EFI boot installation for LoongArch64
systems, which use UEFI as the standard firmware interface.

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
---
 src/installer/hw.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/installer/hw.c b/src/installer/hw.c
index 058671624..0e8e175b3 100644
--- a/src/installer/hw.c
+++ b/src/installer/hw.c
@@ -116,7 +116,8 @@ struct hw* hw_init() {
 	// Should we install in EFI mode?
 	if ((strcmp(hw->arch, "x86_64") == 0)
 			|| (strcmp(hw->arch, "aarch64") == 0)
-			|| (strcmp(hw->arch, "riscv64") == 0))
+			|| (strcmp(hw->arch, "riscv64") == 0)
+			|| (strcmp(hw->arch, "loongarch64") == 0))
 		hw->efi = 1;
 
 	return hw;
-- 
2.38.1



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v1 7/8] installer: Add bootloader installation support for loongarch64
  2026-08-05  2:39 [PATCH v1 0/8] Add loongarch64 architecture support to IPFire Vincent Li
                   ` (5 preceding siblings ...)
  2026-08-05  2:39 ` [PATCH v1 6/8] installer: Enable EFI support for loongarch64 Vincent Li
@ 2026-08-05  2:39 ` Vincent Li
  6 siblings, 0 replies; 8+ messages in thread
From: Vincent Li @ 2026-08-05  2:39 UTC (permalink / raw)
  To: Michael Tremer, development; +Cc: Vincent Li

Add loongarch64-efi to the list of supported bootloader architectures
in the install-bootloader script. This ensures that when installing
on LoongArch64 systems, the correct bootloader components (GRUB for
EFI) are installed during the installation process.

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
---
 src/installer/install-bootloader | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/installer/install-bootloader b/src/installer/install-bootloader
index f21578495..a61fcb29c 100644
--- a/src/installer/install-bootloader
+++ b/src/installer/install-bootloader
@@ -104,6 +104,9 @@ function grub_install() {
 		aarch64)
 			arches="arm64-efi"
 			;;
+		loongarch64)
+			arches="loongarch64-efi"
+			;;
 		riscv64)
 			arches="riscv64-efi"
 			;;
-- 
2.38.1



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-08-05  2:40 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-05  2:39 [PATCH v1 0/8] Add loongarch64 architecture support to IPFire Vincent Li
2026-08-05  2:39 ` [PATCH v1 1/8] make.sh: Add support for building on loongarch64 Vincent Li
2026-08-05  2:39 ` [PATCH v1 2/8] gcc: Add dynamic linker path for loongarch64 native toolchain build Vincent Li
2026-08-05  2:39 ` [PATCH v1 3/8] lfs/Config: Update config.guess and config.sub for loongarch64 support Vincent Li
2026-08-05  2:39 ` [PATCH v1 4/8] lfs/Config: Add EFI and GRUB architecture definitions for loongarch64 Vincent Li
2026-08-05  2:39 ` [PATCH v1 5/8] lfs/Config: Set GOARCH for loongarch64 builds Vincent Li
2026-08-05  2:39 ` [PATCH v1 6/8] installer: Enable EFI support for loongarch64 Vincent Li
2026-08-05  2:39 ` [PATCH v1 7/8] installer: Add bootloader installation " Vincent Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox