public inbox for development@lists.ipfire.org
 help / color / mirror / Atom feed
* [PATCH v1 2/8] gcc: Add dynamic linker path for loongarch64 native toolchain build
@ 2026-08-05  2:42 Vincent Li
  0 siblings, 0 replies; 2+ messages in thread
From: Vincent Li @ 2026-08-05  2:42 UTC (permalink / raw)
  To: Michael Tremer, development; +Cc: 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.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] 2+ messages in thread
* [PATCH v1 0/8] Add loongarch64 architecture support to IPFire
@ 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
  0 siblings, 1 reply; 2+ 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] 2+ messages in thread

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

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-05  2:42 [PATCH v1 2/8] gcc: Add dynamic linker path for loongarch64 native toolchain build Vincent Li
  -- strict thread matches above, loose matches on Subject: below --
2026-08-05  2:39 [PATCH v1 0/8] Add loongarch64 architecture support to IPFire Vincent Li
2026-08-05  2:39 ` [PATCH v1 2/8] gcc: Add dynamic linker path for loongarch64 native toolchain build Vincent Li

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