Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kconfig: fix static linking of nconf

When running make nconfig with a static linking host toolchain,
the libraries are linked in an incorrect order,
resulting in errors similar to the following:

$ MAKEFLAGS='HOSTCC=cc\ -static' make nconfig
/usr/bin/ld: /usr/lib64/gcc/x86_64-unknown-linux-gnu/14.2.1/../../../../lib64/libpanel.a(p_new.o): in function `new_panel':
(.text+0x13): undefined reference to `_nc_panelhook_sp'
/usr/bin/ld: (.text+0x6c): undefined reference to `_nc_panelhook_sp'

Fixes: 1c5af5cf9308 ("kconfig: refactor ncurses package checks for building mconf and nconf")
Signed-off-by: Arusekk <floss@arusekk.pl>
Link: https://patch.msgid.link/20260110114808.22595-1-floss@arusekk.pl
[nsc: Added comment about library order]
Signed-off-by: Nicolas Schier <nsc@kernel.org>

authored by

Arkadiusz Kozdra and committed by
Nicolas Schier
baaecfca 946d4623

+6 -5
+6 -5
scripts/kconfig/nconf-cfg.sh
··· 6 6 cflags=$1 7 7 libs=$2 8 8 9 - PKG="ncursesw menuw panelw" 10 - PKG2="ncurses menu panel" 9 + # Keep library order for static linking (HOSTCC='cc -static') 10 + PKG="menuw panelw ncursesw" 11 + PKG2="menu panel ncurses" 11 12 12 13 if [ -n "$(command -v ${HOSTPKG_CONFIG})" ]; then 13 14 if ${HOSTPKG_CONFIG} --exists $PKG; then ··· 29 28 # find ncurses by pkg-config.) 30 29 if [ -f /usr/include/ncursesw/ncurses.h ]; then 31 30 echo -D_GNU_SOURCE -I/usr/include/ncursesw > ${cflags} 32 - echo -lncursesw -lmenuw -lpanelw > ${libs} 31 + echo -lmenuw -lpanelw -lncursesw > ${libs} 33 32 exit 0 34 33 fi 35 34 36 35 if [ -f /usr/include/ncurses/ncurses.h ]; then 37 36 echo -D_GNU_SOURCE -I/usr/include/ncurses > ${cflags} 38 - echo -lncurses -lmenu -lpanel > ${libs} 37 + echo -lmenu -lpanel -lncurses > ${libs} 39 38 exit 0 40 39 fi 41 40 42 41 if [ -f /usr/include/ncurses.h ]; then 43 42 echo -D_GNU_SOURCE > ${cflags} 44 - echo -lncurses -lmenu -lpanel > ${libs} 43 + echo -lmenu -lpanel -lncurses > ${libs} 45 44 exit 0 46 45 fi 47 46