]> git.ipfire.org Git - thirdparty/systemd.git/commit
mips: Fix conditional inclusion of <asm/sgidefs.h>
authorAndreas K. Hüttel <dilfridge@gentoo.org>
Fri, 20 Mar 2026 12:52:17 +0000 (13:52 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Sun, 22 Mar 2026 19:02:13 +0000 (20:02 +0100)
commitbeef155b12cc2c196d7af2e182458de006eb2cf5
tree9a9761a979cbe73cf1cd3a733de67f8c199500a3
parent9d844012bc2bc776109c736c798bca237ffb1bf9
mips: Fix conditional inclusion of <asm/sgidefs.h>

systemd now has a system call wrapper that does a long series of #ifdef's to
differentiate between architectures and ABIs. This wrapper has two problems.

1. On mips, it needs to differentiate between O32, N32, N64 ABI. It does that
via a code block in src/include/override/sys/generate-syscall.py (and derived
files):

     76 #  elif defined(_MIPS_SIM)
     77 #    if _MIPS_SIM == _MIPS_SIM_ABI32
     78 #      define systemd_NR_{syscall} {nr_mipso32}
     79 #    elif _MIPS_SIM == _MIPS_SIM_NABI32
     80 #      define systemd_NR_{syscall} {nr_mips64n32}
     81 #    elif _MIPS_SIM == _MIPS_SIM_ABI64
     82 #      define systemd_NR_{syscall} {nr_mips64}
     83 #    else
     84 #      error "Unknown MIPS ABI"
     85 #    endif
     86 #  elif defined(__hppa__)

Now the _MIPS_SIM* constants stem from a vendor-specific header file sgidefs.h,
which is included with glibc, but not with musl. It is however always present
in the Linux kernel headers as asm/sgidefs.h ...

2. To work around this, the syscall wrapper already has a block

     47 #ifdef ARCH_MIPS
     48 #include <asm/sgidefs.h>
     49 #endif

Turns out, ARCH_MIPS is defined nowhere in Gentoo, neither on glibc nor on musl.
As a result the code (by accident, probably sgidefs.h is included transitively
somehow) works on glibc, but not on musl.

The simplest fix is to replace line 47 in the generator and the derived file
with

     47 #ifdef __mips__

Two other source code files require a similar fix since they rely on the
constants.

Bug: https://github.com/systemd/systemd/issues/41239
Bug: https://bugs.gentoo.org/971376
Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
src/include/override/sys/generate-syscall.py
src/include/override/sys/syscall.h
src/shared/base-filesystem.c
src/shared/seccomp-util.c