Bug description:
AC_SEARCH_LIBS tries linking with no extra library first, so when a curses library is already in LIBS it succeeds and sets $ac_cv_search_initscr to the literal none required. When pkg-config found nothing, configure.ac copies that string into CURSES_LIBS and treats it as a curses library it discovered.
The string reaches the linker:
$ PKG_CONFIG=/bin/false ../cpython/configure LIBS="-lncursesw -ltinfo"
$ grep '^MODULE__CURSES_LDFLAGS=' Makefile
MODULE__CURSES_LDFLAGS=none required
$ make Modules/_curses.cpython-316-x86_64-linux-gnu.so
gcc -shared Modules/_cursesmodule.o none required -o Modules/_curses.cpython-316-x86_64-linux-gnu.so
/usr/bin/x86_64-linux-gnu-ld.bfd: cannot find none: No such file or directory
/usr/bin/x86_64-linux-gnu-ld.bfd: cannot find required: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [Makefile:3803: Modules/_curses.cpython-316-x86_64-linux-gnu.so] Error 1
The same result also overrides --without-curses, here with pkg-config working normally:
$ ../cpython/configure --without-curses LIBS="-lncursesw -lpanelw"
checking for --with-curses... no
checking for library containing initscr... none required
checking for library containing update_panels... none required
checking for stdlib extension module _curses... yes
checking for stdlib extension module _curses_panel... yes
Expected: none required names no library, so it should not become a linker flag, and Doc/using/configure.rst says --without-curses does not build the curses and curses.panel modules "even when a curses library is present".
Builds that do not put a curses library in LIBS are unaffected: the search returns -lncursesw and CURSES_LIBS is correct.
CPython versions tested on:
CPython main branch, 3.15
Operating systems tested on:
Linux
Bug description:
AC_SEARCH_LIBStries linking with no extra library first, so when a curses library is already inLIBSit succeeds and sets$ac_cv_search_initscrto the literalnone required. When pkg-config found nothing,configure.accopies that string intoCURSES_LIBSand treats it as a curses library it discovered.The string reaches the linker:
The same result also overrides
--without-curses, here with pkg-config working normally:Expected:
none requirednames no library, so it should not become a linker flag, andDoc/using/configure.rstsays--without-cursesdoes not build thecursesandcurses.panelmodules "even when a curses library is present".Builds that do not put a curses library in
LIBSare unaffected: the search returns-lncurseswandCURSES_LIBSis correct.CPython versions tested on:
CPython main branch, 3.15
Operating systems tested on:
Linux