Page 1 of 1

Unable to run make menuconfig for kernel sources[solved]

Posted: Sun Jan 23, 2022 2:26 pm
by Adel Ahmed
I am trying to install gentoo on my sony xperia m mobile phone.
I have downloaded the stage3 archive and extracted, I have git cloned the sources from the following link:
https://github.com/icoolguy1995/sony-xperia-m-kernel

I cd into the directory and run make menuconfig to find the following error:

Code: Select all

localhost ~/kernel/sony-xperia-m-kernel # make menuconfig
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/kconfig/conf.o
  HOSTCC  scripts/kconfig/lxdialog/checklist.o
  HOSTCC  scripts/kconfig/lxdialog/inputbox.o
  HOSTCC  scripts/kconfig/lxdialog/menubox.o
  HOSTCC  scripts/kconfig/lxdialog/textbox.o
  HOSTCC  scripts/kconfig/lxdialog/util.o
  HOSTCC  scripts/kconfig/lxdialog/yesno.o
  HOSTCC  scripts/kconfig/mconf.o
  HOSTCC  scripts/kconfig/zconf.tab.o
  HOSTLD  scripts/kconfig/mconf
/usr/lib/gcc/armv7a-unknown-linux-gnueabihf/11.2.0/../../../../armv7a-unknown-linux-gnueabihf/bin/ld: scripts/kconfig/lxdialog/checklist.o: undefined reference to symbol 'keypad'
/usr/lib/gcc/armv7a-unknown-linux-gnueabihf/11.2.0/../../../../armv7a-unknown-linux-gnueabihf/bin/ld: /lib/libtinfow.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[1]: *** [scripts/Makefile.host:127: scripts/kconfig/mconf] Error 1
make: *** [Makefile:497: menuconfig] Error 2
any help would be appreciated

Posted: Sun Jan 23, 2022 4:56 pm
by alamahant
May be
https://github.com/samtools/samtools/issues/1149

Code: Select all

./configure;make menuconfig

Re: Unable to run make menuconfig for kernel sources

Posted: Sun Jan 23, 2022 5:21 pm
by Hu
Adel Ahmed wrote:I cd into the directory and run make menuconfig to find the following error:

Code: Select all

localhost ~/kernel/sony-xperia-m-kernel # make menuconfig
  HOSTLD  scripts/kconfig/mconf
/usr/lib/gcc/armv7a-unknown-linux-gnueabihf/11.2.0/../../../../armv7a-unknown-linux-gnueabihf/bin/ld: scripts/kconfig/lxdialog/checklist.o: undefined reference to symbol 'keypad'
/usr/lib/gcc/armv7a-unknown-linux-gnueabihf/11.2.0/../../../../armv7a-unknown-linux-gnueabihf/bin/ld: /lib/libtinfow.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[1]: *** [scripts/Makefile.host:127: scripts/kconfig/mconf] Error 1
make: *** [Makefile:497: menuconfig] Error 2
What is the full command line used to invoke the linker for this file? Typically, this error would indicate that you should have linked to an additional DSO, and did not. In this case, the second error even seems to point you in the right direction. Specifically, you should have linked to libtinfow.so.6 to get this symbol, and did not.
alamahant wrote:May be
https://github.com/samtools/samtools/issues/1149

Code: Select all

./configure;make menuconfig
Could you elaborate? The kernel normally doesn't have a configure script at all, so I don't see how to apply this advice. Also, if it did apply, shouldn't it be ./configure && make menuconfig? Usually, running make after configure fails will not be useful.

Posted: Sun Jan 23, 2022 6:03 pm
by alamahant
Well the url refers to Gentoo with the same kind of error.
I should have known better the url case probably concerns some ordinary package whereas here we are dealing with a kernel.
Sorry Hu for my lapse of judgement.

Posted: Sun Jan 23, 2022 9:19 pm
by Hu
You meant well. Maybe next time, check locally whether the instructions make sense? :) New users might see your response, try it, and get confused or frustrated when it doesn't work, because they think they're doing it wrong, rather than that the advice is not applicable to the problem at hand.

Posted: Tue Jan 25, 2022 1:40 am
by Adel Ahmed
the kernel does not indeed have a configure script.
what do you mean by what is the linker command? how can I find this out?

Posted: Tue Jan 25, 2022 11:16 am
by GDH-gentoo
Adel Ahmed wrote:how can I find this out?
Use make V=1 menuconfig. The build should fail again, but this time it should print the full compiler / linker invocation instead of "HOSTLD scripts/kconfig/mconf".

Posted: Tue Jan 25, 2022 11:35 am
by Adel Ahmed
thanks for the clarification:

Code: Select all

make -f scripts/Makefile.build obj=scripts/basic
rm -f .tmp_quiet_recordmcount
mkdir -p include/linux include/config
make -f scripts/Makefile.build obj=scripts/kconfig menuconfig
/bin/sh /root/kernel/sony-xperia-m-kernel/scripts/kconfig/lxdialog/check-lxdialog.sh -check gcc -I/usr/include/ncursesw -DCURSES_LOC="<ncursesw/curses.h>" -DLOCALE  -lncursesw
  gcc  -o scripts/kconfig/mconf scripts/kconfig/mconf.o scripts/kconfig/zconf.tab.o scripts/kconfig/lxdialog/checklist.o scripts/kconfig/lxdialog/util.o scripts/kconfig/lxdialog/inputbox.o scripts/kconfig/lxdialog/textbox.o scripts/kconfig/lxdialog/yesno.o scripts/kconfig/lxdialog/menubox.o  -lncursesw
/usr/lib/gcc/armv7a-unknown-linux-gnueabihf/11.2.0/../../../../armv7a-unknown-linux-gnueabihf/bin/ld: scripts/kconfig/lxdialog/checklist.o: undefined reference to symbol 'keypad'
/usr/lib/gcc/armv7a-unknown-linux-gnueabihf/11.2.0/../../../../armv7a-unknown-linux-gnueabihf/bin/ld: /lib/libtinfow.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[1]: *** [scripts/Makefile.host:127: scripts/kconfig/mconf] Error 1
make: *** [Makefile:497: menuconfig] Error 2

Posted: Tue Jan 25, 2022 3:46 pm
by GDH-gentoo
The kernel for the Sony Xperia from the Git repository that you are using is based on a old upstream version (3.4.0), and the detection logic for the Ncurses libraries contained in its scripts/kconfig/lxdialog/check-lxdialog.sh script won't work. Newer kernels use a different script (scripts/kconfig/mconf-cfg.sh) with a detection logic based on the pkg-config program, which is more robust. If you really want to use that particular kernel, it looks like you'll have to modify check-lxdialog.sh's ldflags() function so that it returns -lncursesw -ltinfow.

Posted: Wed Jan 26, 2022 9:56 am
by Adel Ahmed
I have changed the ldflags function from :

Code: Select all

ldflags()
{
        for ext in so a dylib ; do
                for lib in ncursesw ncurses curses ; do
                        $cc -print-file-name=lib${lib}.${ext} | grep -q /
                        if [ $? -eq 0 ]; then
                                echo "-l${lib}"
                                exit
                        fi
                done
        done
        exit 1
}
to

Code: Select all

ldflags()
{
        for ext in so a dylib ; do
                for lib in 'ncursesw tinfow' 'ncurses tinfow' 'curses tinfow' ; do
                        $cc -print-file-name=lib${lib}.${ext} | grep -q /
                        if [ $? -eq 0 ]; then
                                echo "-l${lib}"
                                exit
                        fi
                done
        done
        exit 1
}
but now I'm getting:

Code: Select all

localhost ~/kernel/sony-xperia-m-kernel # make V=1 menuconfig                      make -f scripts/Makefile.build obj=scripts/basic
rm -f .tmp_quiet_recordmcount
mkdir -p include/linux include/config
make -f scripts/Makefile.build obj=scripts/kconfig menuconfig
/bin/sh /root/kernel/sony-xperia-m-kernel/scripts/kconfig/lxdialog/check-lxdialog.sh -check gcc -I/usr/include/ncursesw -DCURSES_LOC="<ncursesw/curses.h>" -DLOCALE
  gcc  -o scripts/kconfig/mconf scripts/kconfig/mconf.o scripts/kconfig/zconf.tab.o scripts/kconfig/lxdialog/checklist.o scripts/kconfig/lxdialog/util.o scripts/kconfig/lxdialog/inputbox.o scripts/kconfig/lxdialog/textbox.o scripts/kconfig/lxdialog/yesno.o scripts/kconfig/lxdialog/menubox.o
/usr/lib/gcc/armv7a-unknown-linux-gnueabihf/11.2.0/../../../../armv7a-unknown-linux-gnueabihf/bin/ld: scripts/kconfig/mconf.o: in function `show_help':
mconf.c:(.text+0xadc): undefined reference to `stdscr'
/usr/lib/gcc/armv7a-unknown-linux-gnueabihf/11.2.0/../../../../armv7a-unknown-linux-gnueabihf/bin/ld: scripts/kconfig/mconf.o: in function `main':
mconf.c:(.text.startup+0x88): undefined reference to `initscr'
/usr/lib/gcc/armv7a-unknown-linux-gnueabihf/11.2.0/../../../../armv7a-unknown-linux-gnueabihf/bin/ld: mconf.c:(.text.startup+0x180): undefined reference to `stdscr'
/usr/lib/gcc/armv7a-unknown-linux-gnueabihf/11.2.0/../../../../armv7a-unknown-linux-gnueabihf/bin/ld: scripts/kconfig/lxdialog/checklist.o: in function `print_arrows':
checklist.c:(.text+0x30): undefined reference to `wmove'
/usr/lib/gcc/armv7a-unknown-linux-gnueabihf/11.2.0/../../../../armv7a-unknown-linux-gnueabihf/bin/ld: checklist.c:(.text+0x60): undefined reference to `waddch'
/usr/lib/gcc/armv7a-unknown-linux-gnueabihf/11.2.0/../../../../armv7a-unknown-linux-gnueabihf/bin/ld: checklist.c:(.text+0x74): undefined reference to `waddnstr'
I have not included the entire log as they are mostly undefined reference to errors.
is there any way to get around this without having to work around the errors 1 by 1?
I cannot use the latest gentoo-sources as this is a mobile phone and getting a working kernel that way will involve much more work(not just configuring and compiling, but porting the kernel to the phone).

Posted: Wed Jan 26, 2022 4:23 pm
by Hu
Adel Ahmed wrote:I have changed the ldflags function from :
to

Code: Select all

ldflags()
{
        for ext in so a dylib ; do
                for lib in 'ncursesw tinfow' 'ncurses tinfow' 'curses tinfow' ; do
                        $cc -print-file-name=lib${lib}.${ext} | grep -q /
This change looks wrong to me. I doubt you have a file named libncurses tinfow.so, and even if you did, the $cc line isn't quoted properly to find it. You need the script to print -lncursesw -ltinfow or similar, depending on whether you want narrow or wide ncurses. Since you are already hacking up the build system, you could try replacing the entire function with just:

Code: Select all

ldflags() {
	printf '%s ' -lncurses -ltinfo
}
Again, adjust the narrow/wide as appropriate.
Adel Ahmed wrote:but now I'm getting:

Code: Select all

  gcc  -o scripts/kconfig/mconf scripts/kconfig/mconf.o scripts/kconfig/zconf.tab.o scripts/kconfig/lxdialog/checklist.o scripts/kconfig/lxdialog/util.o scripts/kconfig/lxdialog/inputbox.o scripts/kconfig/lxdialog/textbox.o scripts/kconfig/lxdialog/yesno.o scripts/kconfig/lxdialog/menubox.o
This line shows your change had no effect on the linker, or maybe even negative effect. Now it is not trying to link any ncurses or tinfo libraries at all. That will definitely cause the undefined reference errors you showed.
Adel Ahmed wrote:is there any way to get around this without having to work around the errors 1 by 1?
Use a version where someone has already fixed this, or find and install an ancient toolchain that was current when this kernel was forked from mainline.
Adel Ahmed wrote:I cannot use the latest gentoo-sources as this is a mobile phone and getting a working kernel that way will involve much more work(not just configuring and compiling, but porting the kernel to the phone).
The code for this phone was never merged to mainline?

Posted: Sun Jan 30, 2022 6:00 am
by Adel Ahmed
I have changed the function to :

Code: Select all

ldflags() {
   printf '%s ' -lncurses -ltinfo
}
and it works now thank you.
unfortunately the code was never merged into the mainline :(.