Re: [PATCH 2/5] nolibc: add support for s390

From: Willy Tarreau
Date: Tue Dec 27 2022 - 16:36:12 EST


Hi Sven,

On Fri, Dec 09, 2022 at 03:19:36PM +0100, Sven Schnelle wrote:
> Use arch-x86_64 as a template. Not really different, but
> we have our own mmap syscall which takes a structure instead
> of discrete arguments.
(...)

This evening I downloaded an s390 toolchain from kernel.org's nolibc
toolchains and expected to test the code under qemu, but I met two
build errors.

The first one is that __maybe_unused breaks the build below:

> +static __maybe_unused
> +void *sys_mmap(void *addr, size_t length, int prot, int flags, int fd,
> + off_t offset)

And indeed, __maybe_unused is not defined here in userland. The following
patch allows to go further:

diff --git a/tools/include/nolibc/arch-s390.h b/tools/include/nolibc/arch-s390.h
index 34b744e2f7d6..effae6e3d9e2 100644
--- a/tools/include/nolibc/arch-s390.h
+++ b/tools/include/nolibc/arch-s390.h
@@ -194,7 +194,7 @@ struct s390_mmap_arg_struct {
unsigned long offset;
};

-static __maybe_unused
+static __attribute__((unused))
void *sys_mmap(void *addr, size_t length, int prot, int flags, int fd,
off_t offset)
{

But with this addressed, I'm facing this next error:

$ make nolibc-test LDFLAGS= ARCH=s390 CC=/f/tc/nolibc/gcc-12.2.0-nolibc/s390-linux/bin/s390-linux-gcc
MKDIR sysroot/s390/include
make[1]: Entering directory '/g/public/linux/master/tools/include/nolibc'
make[2]: Entering directory '/g/public/linux/master'
make[2]: Leaving directory '/g/public/linux/master'
make[2]: Entering directory '/g/public/linux/master'
INSTALL /g/public/linux/master/tools/testing/selftests/nolibc/sysroot/sysroot/include
make[2]: Leaving directory '/g/public/linux/master'
make[1]: Leaving directory '/g/public/linux/master/tools/include/nolibc'
CC nolibc-test
/tmp/ccCzaBgD.s: Assembler messages:
/tmp/ccCzaBgD.s:9: Error: Unrecognized opcode: `lg'
/tmp/ccCzaBgD.s:12: Error: Unrecognized opcode: `lay'
/tmp/ccCzaBgD.s:15: Error: Unrecognized opcode: `lghi'
make: *** [Makefile:108: nolibc-test] Error 1

Thus I'm wondering if specific options are required for the compiler
(it's gcc 12.2.0 + binutils 2.39), if I'm not using the proper compiler,
or if there's anything wrong in the asm code (e.g. maybe by accident you
sent the patch from an earlier development branch), or anything else ?

FWIW I've used the patches from Paul's dev branch:

https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git/log/?h=dev

And the s390 toolchain from here:

https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/12.2.0/

Thanks in advance for any help,
Willy