[klibc] Mips cross-compiling whos

Olliver Schinagl oliver at schinagl.nl
Tue Jul 26 13:30:13 PDT 2022

Hey list,

I'm trying to cross-compile klibc on mips. As I packaged it for alpine 
before, I figured it shouldn't be that hard ;) Sadly, alpine doesn't 
support mips[32|64] so I have to cross-compile it.

I'm doing this from within an alpine based docker container, using a 
simple script (setup vars, unzip, make).

There's a few things I don't understand why they are the way they are, 
but have a somewhat easy work-around (haven't spend time to figure out 
if it is the correct one at all or not :p).

First, this work-around I have also in the alpine packages, since it's 
just shuffling stuff around, but keeping all definitions, I don't 
mind/care much.


         if [ ! -e 'usr/include/sys/sysinfo.h.orig' ]; then
             mv 'usr/include/sys/sysinfo.h' \
         cat \
             '/usr/include/linux/sysinfo.h' \
             'usr/include/sys/sysinfo.h.orig' > \

excuse the uglyness :p

Secondly, specificaly on mips, I get re-definition errors, I haven't 
looked into detail why `f_owner_ex` is redefined, but I use the 
following here:


         sed -i \
             -e '/^typedef struct flock {$/i # define 
             -e '/^struct f_owner_ex {$/,+6d' \


Lastly, _KLIBC_USE_RT_SIG supposedly 'can' be used on mips, but it 
causes a `-1` unnamed array definition error, so 'can' means 'does not 
needed to be', so I just disabled it.


         sed -i 's|^\(#define _KLIBC_USE_RT_SIG \).*$|\1 0|' 


Now, to compile, I use


         make \
              KBUILD_REPRODUCIBLE=1 \
              KLIBCARCH="mips" \
              KLIBCKERNELSRC='/usr/' \


with the kernel header package installed under '/usr'; but I'm thrown a 
`syscalls.h` missing header error, that I can't figure out. It seems 
like `syscalls.pl` would generate them, but I get no warnings or errors 
on the failure thereof, which kinda puts me at a loss.


usr/klibc/sigsuspend.c:8:10: fatal error: klibc/havesyscall.h: No such 
file or directory
     8 | #include <klibc/havesyscall.h>
       |          ^~~~~~~~~~~~~~~~~~~~~


Any idea what's missing, what's failing? Perl is available and working;

This is perl 5, version 34, subversion 1 (v5.34.1) built for 
and gcc is working fine for the other stuffs

mips-mti-elf-gcc (Alpine Linux) 11.2.0

Any thoughts or points would be greatly appreciated ...


P.S. I'm not subscribed to the list; so please keep me in the CC :)

More information about the klibc mailing list