public inbox for development@lists.ipfire.org
 help / color / mirror / Atom feed
From: Vincent Li <vincent.mc.li@gmail.com>
To: Michael Tremer <michael.tremer@ipfire.org>, development@lists.ipfire.org
Cc: Vincent Li <vincent.mc.li@gmail.com>,
	Vincent Li <VincentLivincent.mc.li@gmail.com>
Subject: [PATCH v1 2/8] gcc: Add dynamic linker path for loongarch64 native toolchain build
Date: Tue,  4 Aug 2026 19:39:50 -0700	[thread overview]
Message-ID: <20260805023956.3379890-3-vincent.mc.li@gmail.com> (raw)
In-Reply-To: <20260805023956.3379890-1-vincent.mc.li@gmail.com>

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



  parent reply	other threads:[~2026-08-05  2:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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
2026-08-05  2:42 [PATCH v1 2/8] gcc: Add dynamic linker path for loongarch64 native toolchain build Vincent Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260805023956.3379890-3-vincent.mc.li@gmail.com \
    --to=vincent.mc.li@gmail.com \
    --cc=VincentLivincent.mc.li@gmail.com \
    --cc=development@lists.ipfire.org \
    --cc=michael.tremer@ipfire.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox