Re: [PATCH v2 0/4] tools/nolibc: MIPS: entrypoint cleanups and N32/N64 ABIs

From: Thomas Weißschuh
Date: Sat Mar 29 2025 - 05:51:58 EST


On 2025-03-26 23:04:30+0100, Sebastian Andrzej Siewior wrote:
> On 2025-03-26 22:51:54 [+0100], Thomas Weißschuh wrote:
> > > mips32le works as-is.
> > > For mips64le I had to s/-march=mips64r6/-march=mips64r2 to match the
> > > ABI. Which makes me wonder: Why do do we need to pass -march here and
> > > can't rely on toolchain defaults?
> >
> > The goal here is to have an as-wide-as-possible test matrix for
> > nolibc-test, which will mostly be running on QEMU anyways.
> > Also we need to run the correct QEMU user variant; by fixing the
> > architecture this is easy to do.
>
> I would prefer to make distro users as in real hardware first class
> citizen and not QEMU users. If you run qemu you can specify the ABI
> anyway.

Does the following work for you when running kust "make nolibc-test"?

diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile
index 58bcbbd029bc..27d5ceb20858 100644
--- a/tools/testing/selftests/nolibc/Makefile
+++ b/tools/testing/selftests/nolibc/Makefile
@@ -174,10 +174,13 @@ CFLAGS_s390x = -m64
CFLAGS_s390 = -m31
CFLAGS_mips32le = -EL -mabi=32 -fPIC
CFLAGS_mips32be = -EB -mabi=32
+ifeq ($(origin XARCH),command line)
+CFLAGS_ARCH = $(CFLAGS_$(XARCH))
+endif
CFLAGS_STACKPROTECTOR ?= $(call cc-option,-mstack-protector-guard=global $(call cc-option,-fstack-protector-all))
CFLAGS ?= -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 -W -Wall -Wextra \
$(call cc-option,-fno-stack-protector) $(call cc-option,-Wmissing-prototypes) \
- $(CFLAGS_$(XARCH)) $(CFLAGS_STACKPROTECTOR) $(CFLAGS_EXTRA)
+ $(CFLAGS_ARCH) $(CFLAGS_STACKPROTECTOR) $(CFLAGS_EXTRA)
LDFLAGS :=

LIBGCC := -lgcc
@@ -232,7 +235,7 @@ all: run

sysroot: sysroot/$(ARCH)/include

-sysroot/$(ARCH)/include: | defconfig
+sysroot/$(ARCH)/include:
$(Q)rm -rf sysroot/$(ARCH) sysroot/sysroot
$(QUIET_MKDIR)mkdir -p sysroot
$(Q)$(MAKE) -C $(srctree) outputmakefile