andikleen / linux-misc

Various Linux kernel changes
http://halobates.de
Other
64 stars 12 forks source link

MIPS support #29

Open urjaman opened 5 years ago

urjaman commented 5 years ago

Hi, I'm trying to squeeze a 4.14 kernel (+initramfs) onto quite the small flash router, and decided to try LTO'ing the kernel. I based my work on the lto-415-2 branch.

My current attempt ends up like this:

/home/urjaman/openwrt-w268r-2019/staging_dir/toolchain-mipsel_24kc_gcc-7.4.0_uClibc/lib/gcc/mipsel-openwrt-linux-uclibc/7.4.0/../../../../mipsel-openwrt-linux-uclibc/bin/ld: ./ccclqfYP.ltrans0.ltrans.o: in function `__sys_fork':
<artificial>:(.text+0x20): undefined reference to `sys_fork'
/home/urjaman/openwrt-w268r-2019/staging_dir/toolchain-mipsel_24kc_gcc-7.4.0_uClibc/lib/gcc/mipsel-openwrt-linux-uclibc/7.4.0/../../../../mipsel-openwrt-linux-uclibc/bin/ld: ./ccclqfYP.ltrans0.ltrans.o: in function `__sys_clone':
<artificial>:(.text+0x48): undefined reference to `sys_clone'
/home/urjaman/openwrt-w268r-2019/staging_dir/toolchain-mipsel_24kc_gcc-7.4.0_uClibc/lib/gcc/mipsel-openwrt-linux-uclibc/7.4.0/../../../../mipsel-openwrt-linux-uclibc/bin/ld: ./ccclqfYP.ltrans0.ltrans.o: in function `__sys_sysmips':
<artificial>:(.text+0x70): undefined reference to `sys_sysmips'
/home/urjaman/openwrt-w268r-2019/staging_dir/toolchain-mipsel_24kc_gcc-7.4.0_uClibc/lib/gcc/mipsel-openwrt-linux-uclibc/7.4.0/../../../../mipsel-openwrt-linux-uclibc/bin/ld: ./ccclqfYP.ltrans3.ltrans.o: in function `pty_resize':
<artificial>:(.text+0xa8d8): undefined reference to `memcmp'
/home/urjaman/openwrt-w268r-2019/staging_dir/toolchain-mipsel_24kc_gcc-7.4.0_uClibc/lib/gcc/mipsel-openwrt-linux-uclibc/7.4.0/../../../../mipsel-openwrt-linux-uclibc/bin/ld: ./ccclqfYP.ltrans3.ltrans.o: in function `param_setup_earlycon':
<artificial>:(.init.text+0x8ec): undefined reference to `memcmp'
/home/urjaman/openwrt-w268r-2019/staging_dir/toolchain-mipsel_24kc_gcc-7.4.0_uClibc/lib/gcc/mipsel-openwrt-linux-uclibc/7.4.0/../../../../mipsel-openwrt-linux-uclibc/bin/ld: ./ccclqfYP.ltrans4.ltrans.o: in function `nla_strcmp':
<artificial>:(.text+0x6d64): undefined reference to `memcmp'
/home/urjaman/openwrt-w268r-2019/staging_dir/toolchain-mipsel_24kc_gcc-7.4.0_uClibc/lib/gcc/mipsel-openwrt-linux-uclibc/7.4.0/../../../../mipsel-openwrt-linux-uclibc/bin/ld: ./ccclqfYP.ltrans4.ltrans.o: in function `rhashtable_lookup_one':
<artificial>:(.text+0x7f40): undefined reference to `memcmp'
/home/urjaman/openwrt-w268r-2019/staging_dir/toolchain-mipsel_24kc_gcc-7.4.0_uClibc/lib/gcc/mipsel-openwrt-linux-uclibc/7.4.0/../../../../mipsel-openwrt-linux-uclibc/bin/ld: ./ccclqfYP.ltrans4.ltrans.o: in function `tty_ioctl':
<artificial>:(.text+0xb8f0): undefined reference to `memcmp'
/home/urjaman/openwrt-w268r-2019/staging_dir/toolchain-mipsel_24kc_gcc-7.4.0_uClibc/lib/gcc/mipsel-openwrt-linux-uclibc/7.4.0/../../../../mipsel-openwrt-linux-uclibc/bin/ld: ./ccclqfYP.ltrans5.ltrans.o:<artificial>:(.text+0x3b40): more undefined references to `memcmp' follow
/home/urjaman/openwrt-w268r-2019/staging_dir/toolchain-mipsel_24kc_gcc-7.4.0_uClibc/lib/gcc/mipsel-openwrt-linux-uclibc/7.4.0/../../../../mipsel-openwrt-linux-uclibc/bin/ld: arch/mips/kernel/scall32-o32.o: in function `einval':
(.text+0x31c): undefined reference to `sys_alarm'
/home/urjaman/openwrt-w268r-2019/staging_dir/toolchain-mipsel_24kc_gcc-7.4.0_uClibc/lib/gcc/mipsel-openwrt-linux-uclibc/7.4.0/../../../../mipsel-openwrt-linux-uclibc/bin/ld: (.text+0x450): undefined reference to `sys_setitimer'
/home/urjaman/openwrt-w268r-2019/staging_dir/toolchain-mipsel_24kc_gcc-7.4.0_uClibc/lib/gcc/mipsel-openwrt-linux-uclibc/7.4.0/../../../../mipsel-openwrt-linux-uclibc/bin/ld: (.text+0x454): undefined reference to `sys_getitimer'
/home/urjaman/openwrt-w268r-2019/staging_dir/toolchain-mipsel_24kc_gcc-7.4.0_uClibc/lib/gcc/mipsel-openwrt-linux-uclibc/7.4.0/../../../../mipsel-openwrt-linux-uclibc/bin/ld: (.text+0x6b4): undefined reference to `sys_timer_create'
/home/urjaman/openwrt-w268r-2019/staging_dir/toolchain-mipsel_24kc_gcc-7.4.0_uClibc/lib/gcc/mipsel-openwrt-linux-uclibc/7.4.0/../../../../mipsel-openwrt-linux-uclibc/bin/ld: (.text+0x6b8): undefined reference to `sys_timer_settime'
/home/urjaman/openwrt-w268r-2019/staging_dir/toolchain-mipsel_24kc_gcc-7.4.0_uClibc/lib/gcc/mipsel-openwrt-linux-uclibc/7.4.0/../../../../mipsel-openwrt-linux-uclibc/bin/ld: (.text+0x6bc): undefined reference to `sys_timer_gettime'
/home/urjaman/openwrt-w268r-2019/staging_dir/toolchain-mipsel_24kc_gcc-7.4.0_uClibc/lib/gcc/mipsel-openwrt-linux-uclibc/7.4.0/../../../../mipsel-openwrt-linux-uclibc/bin/ld: (.text+0x6c0): undefined reference to `sys_timer_getoverrun'
/home/urjaman/openwrt-w268r-2019/staging_dir/toolchain-mipsel_24kc_gcc-7.4.0_uClibc/lib/gcc/mipsel-openwrt-linux
/ld: (.text+0x6c4): undefined reference to `sys_timer_delete'
/home/urjaman/openwrt-w268r-2019/staging_dir/toolchain-mipsel_24kc_gcc-7.4.0_uClibc/lib/gcc/mipsel-openwrt-linux
/ld: (.text+0x804): undefined reference to `sys_clock_adjtime'
collect2: error: ld returned 1 exit status

I assume these are to do with the syscall table... tho the memcmp ones confuse me.

Anyways the point i was going for was that a very old pdf somewhere told me this was tested on MIPS but my quick lookaround didnt find any patches, so pointers/hints appreciated, and of course anyone who has patches for MIPS support is welcome to point me at them too :)

urjaman commented 5 years ago

So, I ended up just flaffing around until it compiled (and pulled one patch from the 4.20 branch that moved the head file to the front of the kernel binary), and the end result works but is not pretty -- if you really need it is in my openwrt-w268r repo.

Anyways the memcmp maybe had something to do with the weird special casing of that under MIPS (there was an identical version of memcmp from the generic one, but only for MIPS... disabled that), and those timer-related syscalls were actually disabled yet needed by the kernel itself (?) so i guess disabling the posix timers is not a good idea, i just re-enabled them.

ytrezq commented 4 years ago

are you sure your toolchain can build other kernels?