From: Nathan Chancellor <nathan@kernel.org>
To: WANG Rui <r@hev.cc>
Cc: arnd@arndb.de, chenhuacai@kernel.org, chenhuacai@loongson.cn,
guoren@kernel.org, jiaxun.yang@flygoat.com, kernel@xen0n.name,
linux-kernel@vger.kernel.org, lixuefeng@loongson.cn,
loongarch@lists.linux.dev
Subject: Re: [PATCH V4 14/14] LoongArch: Adjust build infrastructure for 32BIT/64BIT
Date: Fri, 24 Apr 2026 11:19:51 -0700 [thread overview]
Message-ID: <20260424181951.GA813908@ax162> (raw)
In-Reply-To: <20260424110624.48510-1-r@hev.cc>
Hi Rui,
On Fri, Apr 24, 2026 at 07:06:23PM +0800, WANG Rui wrote:
> > As a result of the above problem, I see
> >
> > clang: error: ignoring '-mabi=ilp32s' as it conflicts with that implied by '-msoft-float' (lp64s) [-Werror,-Woption-ignored]
> > clang: error: ignoring '-mabi=ilp32s' as it conflicts with that implied by '-msoft-float' (lp64s) [-Werror,-Woption-ignored]
> > clang: error: ignoring '-mabi=ilp32s' as it conflicts with that implied by '-msoft-float' (lp64s) [-Werror,-Woption-ignored]
> >
> > when building configurations that I expected to be 64-bit but had been
> > turned into 32-bit ones with LLVM. This was also reported by the test
> > robot with allnoconfig.
> >
> > https://lore.kernel.org/202604232041.ESJDwVG4-lkp@intel.com/
> >
> > Maybe some change is needed on the LLVM side?
>
> The root cause is that scripts/Makefile.clang unconditionally sets
> CLANG_TARGET_FLAGS_loongarch to loongarch64-linux-gnusf.
> However, Clang with --target=loongarch64 does not support a 32-bit ABI.
> LLVM clearly separates loongarch32 and loongarch64 targets.
>
> Since CLANG_TARGET_FLAGS gets initialized before CONFIG is available, the
> current setup effectively assumes that a 64-bit target must also handle
> a 32-bit ABI. That assumption may not hold for LLVM, which models 32-bit
> and 64-bit LoongArch as separate targets.
Hmmm, okay, that definitely explains it. As the comment at the top of
scripts/Makefile.clang states, we rely on targets supporting switching
their word size via '-m32' / '-m64' so that we can use a 64-bit triple
but still get a 32-bit one if necessary. For example:
--target=x86_64-linux-gnu -m32
effectively becomes
--target=i386-linux-gnu
It seems like this works for LoongArch in clang as well?
diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile
index 47516aeea9d2..2837004d0d75 100644
--- a/arch/loongarch/Makefile
+++ b/arch/loongarch/Makefile
@@ -67,6 +67,9 @@ ifneq ($(SUBARCH),$(ARCH))
endif
ifdef CONFIG_32BIT
+ifdef CONFIG_CC_IS_CLANG
+cflags-y += -m32
+endif
ifdef CONFIG_32BIT_STANDARD
ld-emul = $(32bit-emul)
cflags-y += -march=la32v1.0 -mabi=ilp32s -mcmodel=normal
diff --git a/arch/loongarch/vdso/Makefile b/arch/loongarch/vdso/Makefile
index 42aa96249828..eeda13ecb711 100644
--- a/arch/loongarch/vdso/Makefile
+++ b/arch/loongarch/vdso/Makefile
@@ -14,6 +14,7 @@ ccflags-vdso := \
$(filter -E%,$(KBUILD_CFLAGS)) \
$(filter -march=%,$(KBUILD_CFLAGS)) \
$(filter -m%-float,$(KBUILD_CFLAGS)) \
+ $(filter -m32,$(KBUILD_CFLAGS)) \
$(CLANG_FLAGS) \
-D__VDSO__
--
appears to do the right thing?
$ make -skj"$(nproc)" ARCH=loongarch LLVM=1 mrproper loongarch32_defconfig all
$ file vmlinux arch/loongarch/boot/vmlinux.efi
vmlinux: ELF 32-bit LSB executable, LoongArch, version 1 (SYSV), statically linked, BuildID[sha1]=26b4af26bb14c923270429f4ccdc66a519c059b1, not stripped
arch/loongarch/boot/vmlinux.efi: PE32+ executable for EFI (application), LoongArch 32-bit (stripped to external PDB), 2 section
Cheers,
Nathan
next prev parent reply other threads:[~2026-04-24 18:19 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-27 15:48 [PATCH V4 00/14] LoongArch: Add basic LoongArch32 support Huacai Chen
2025-11-27 15:48 ` [PATCH V4 01/14] LoongArch: Add atomic operations for 32BIT/64BIT Huacai Chen
2025-11-27 15:48 ` [PATCH V4 02/14] LoongArch: Add adaptive CSR accessors " Huacai Chen
2025-11-27 15:48 ` [PATCH V4 03/14] LoongArch: Adjust common macro definitions " Huacai Chen
2025-11-27 15:48 ` [PATCH V4 04/14] LoongArch: Adjust boot & setup " Huacai Chen
2025-11-27 15:48 ` [PATCH V4 05/14] LoongArch: Adjust memory management " Huacai Chen
2025-11-27 15:48 ` [PATCH V4 06/14] LoongArch: Adjust process " Huacai Chen
2025-11-27 15:48 ` [PATCH V4 07/14] LoongArch: Adjust time routines " Huacai Chen
2025-11-27 15:48 ` [PATCH V4 08/14] LoongArch: Adjust module loader " Huacai Chen
2025-11-27 15:48 ` [PATCH V4 09/14] LoongArch: Adjust system call " Huacai Chen
2025-11-27 15:48 ` [PATCH V4 10/14] LoongArch: Adjust user accessors " Huacai Chen
2025-11-27 15:48 ` [PATCH V4 11/14] LoongArch: Adjust misc routines " Huacai Chen
2025-11-27 15:48 ` [PATCH V4 12/14] LoongArch: Adjust VDSO/VSYSCALL " Huacai Chen
2025-11-27 15:48 ` [PATCH V4 13/14] LoongArch: Adjust default config files " Huacai Chen
2025-11-27 15:48 ` [PATCH V4 14/14] LoongArch: Adjust build infrastructure " Huacai Chen
2025-11-28 13:57 ` Arnd Bergmann
2025-11-28 14:27 ` Huacai Chen
2026-04-23 22:06 ` Nathan Chancellor
2026-04-24 4:14 ` Huacai Chen
2026-04-24 11:06 ` WANG Rui
2026-04-24 18:19 ` Nathan Chancellor [this message]
2026-04-25 2:29 ` hev
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=20260424181951.GA813908@ax162 \
--to=nathan@kernel.org \
--cc=arnd@arndb.de \
--cc=chenhuacai@kernel.org \
--cc=chenhuacai@loongson.cn \
--cc=guoren@kernel.org \
--cc=jiaxun.yang@flygoat.com \
--cc=kernel@xen0n.name \
--cc=linux-kernel@vger.kernel.org \
--cc=lixuefeng@loongson.cn \
--cc=loongarch@lists.linux.dev \
--cc=r@hev.cc \
/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