kconfig: fix static linking of nconf
PATCH 1/1 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'
--- scripts/kconfig/nconf-cfg.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
scripts/kconfig/nconf-cfg.sh +5 -5
@@ -6,8 +6,8 @@ set -eu cflags=$1 libs=$2 -PKG="ncursesw menuw panelw" -PKG2="ncurses menu panel" +PKG="menuw panelw ncursesw" +PKG2="menu panel ncurses" if [ -n "$(command -v ${HOSTPKG_CONFIG})" ]; then if ${HOSTPKG_CONFIG} --exists $PKG; then
@@ -28,19 +28,19 @@ fi # find ncurses by pkg-config.) if [ -f /usr/include/ncursesw/ncurses.h ]; then echo -D_GNU_SOURCE -I/usr/include/ncursesw > ${cflags} - echo -lncursesw -lmenuw -lpanelw > ${libs} + echo -lmenuw -lpanelw -lncursesw > ${libs} exit 0 fi if [ -f /usr/include/ncurses/ncurses.h ]; then echo -D_GNU_SOURCE -I/usr/include/ncurses > ${cflags} - echo -lncurses -lmenu -lpanel > ${libs} + echo -lmenu -lpanel -lncurses > ${libs} exit 0 fi if [ -f /usr/include/ncurses.h ]; then echo -D_GNU_SOURCE > ${cflags} - echo -lncurses -lmenu -lpanel > ${libs} + echo -lmenu -lpanel -lncurses > ${libs} exit 0 fi
Signature · 1 line
2.51.2
Nathan Chancellor
maintainerQuoted 20 lines · Arkadiusz Kozdra
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 <[email protected]>--- scripts/kconfig/nconf-cfg.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)scripts/kconfig/nconf-cfg.sh +0
-0
scripts/kconfig/nconf-cfg.sh set -eu · line 10
Quoted 5 lines
scripts/kconfig/nconf-cfg.sh +0
-2@@ -6,8 +6,8 @@ set -eu cflags=$1 libs=$2 -PKG="ncursesw menuw panelw" -PKG2="ncurses menu panel"
Is it worth a comment that the order of these packages is intentional to support static library builds? I do not mind adding after the fact to save you from sending a v2. I guess this situation is not too common since 1c5af5cf9308 is over six years old at this point but if any other dependencies become necessary in the future, it might help folks place them in the correct order.
Quoted 31 lines
scripts/kconfig/nconf-cfg.sh +5
-3+PKG="menuw panelw ncursesw" +PKG2="menu panel ncurses" if [ -n "$(command -v ${HOSTPKG_CONFIG})" ]; then if ${HOSTPKG_CONFIG} --exists $PKG; then@@ -28,19 +28,19 @@ fi # find ncurses by pkg-config.) if [ -f /usr/include/ncursesw/ncurses.h ]; then echo -D_GNU_SOURCE -I/usr/include/ncursesw > ${cflags} - echo -lncursesw -lmenuw -lpanelw > ${libs} + echo -lmenuw -lpanelw -lncursesw > ${libs} exit 0 fi if [ -f /usr/include/ncurses/ncurses.h ]; then echo -D_GNU_SOURCE -I/usr/include/ncurses > ${cflags} - echo -lncurses -lmenu -lpanel > ${libs} + echo -lmenu -lpanel -lncurses > ${libs} exit 0 fi if [ -f /usr/include/ncurses.h ]; then echo -D_GNU_SOURCE > ${cflags} - echo -lncurses -lmenu -lpanel > ${libs} + echo -lmenu -lpanel -lncurses > ${libs} exit 0 fiSignature · 1 line
2.51.2
W dniu 11.01.2026 o 00:20, Nathan Chancellor pisze:
Quoted 8 lines
scripts/kconfig/nconf-cfg.sh set -eu · line 10
Quoted 2 lines
scripts/kconfig/nconf-cfg.sh +0
-2-PKG="ncursesw menuw panelw" -PKG2="ncurses menu panel"Is it worth a comment that the order of these packages is intentional to support static library builds? I do not mind adding after the fact to save you from sending a v2. I guess this situation is not too common since
1c5af5cf9308is over six years old at this point but if any other dependencies become necessary in the future, it might help folks place them in the correct order.
Sure, this is because ld still only visits each archive once, left-to-right, by design. I think a comment about library dependencies and order would do a lot. Feel free to reword and/or add comments as you please.
Thank you for your help.
- Arusekk
Nicolas Schier
maintainerQuoted 10 lines · Arkadiusz Kozdra
W dniu 11.01.2026 o 00:20, Nathan Chancellor pisze:
Quoted 8 lines
scripts/kconfig/nconf-cfg.sh set -eu · line 10
Quoted 2 lines
scripts/kconfig/nconf-cfg.sh +0
-2-PKG="ncursesw menuw panelw" -PKG2="ncurses menu panel"Is it worth a comment that the order of these packages is intentional to support static library builds? I do not mind adding after the fact to save you from sending a v2. I guess this situation is not too common since
1c5af5cf9308is over six years old at this point but if any other dependencies become necessary in the future, it might help folks place them in the correct order.
Quoted 8 lines
Sure, this is because ld still only visits each archive once, left-to-right, by design.
I think a comment about library dependencies and order would do a lot. Feel free to reword and/or add comments as you please.
Thank you for your help.- Arusekk
I will add this to kbuild-fixes-for-next with this comment added to nconf-cfg.sh:
# Keep library order for static linking (HOSTCC='cc -static')
final inclusion in kbuild-fixes in about a week as long as there are no regressions or vetos.
Kind regards,
Nicolas