Skip to content

Building Programs/_freeze_module sometimes fails with missing symbols, like undefined reference to PyErr_CheckSignals #161364

Open

Description

@vstinner

Bug report

Sometimes, when I build Python incrementally (build Python with make, modify C code, run make again), the build fails with errors such as:

gcc     -o Programs/_freeze_module Programs/_freeze_module.o Modules/getpath_noop.o (...) Modules/gcmodule.o  -ldl   -lm 
/usr/bin/ld.bfd: Parser/myreadline.o: in function `my_fgets':
/home/vstinner/python/main/Parser/myreadline.c:105:(.text+0x64): undefined reference to `PyErr_CheckSignals'

The PyErr_CheckSignals() function is implemented by Modules/signalmodule.c, but it seems like Modules/signalmodule.o is not used to build Programs/_freeze_module program.

Programs/_freeze_module rule in Makefile:

Programs/_freeze_module: Programs/_freeze_module.o Modules/getpath_noop.o $(BOOTSTRAP_LIBRARY_OBJS)
	$(LINKCC) $(PY_CORE_LDFLAGS) -o $@ Programs/_freeze_module.o Modules/getpath_noop.o $(BOOTSTRAP_LIBRARY_OBJS) $(LIBS) $(BOOTSTRAP_MODLIBS) $(SYSLIBS)

BOOTSTRAP_LIBRARY_OBJS variable:

BOOTSTRAP_LIBRARY_OBJS=	\
		Modules/getbuildinfo_bootstrap.o \
		$(PARSER_OBJS) \
		$(OBJECT_OBJS) \
		$(PYTHON_OBJS) \
		Modules/config_bootstrap.o \
		$(MODULE_OBJS_COMMON) \
		$(BOOTSTRAP_MODOBJS)

MODULE_OBJS_COMMON and BOOTSTRAP_MODOBJS variables:

MODULE_OBJS_COMMON=	\
		Modules/main.o \
		Modules/gcmodule.o
BOOTSTRAP_MODOBJS= 

Full Makefile file (created on Fedora 45): Makefile

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Activity

  1. vstinner commented on Nov 4, 2026

    @vstinner
    MemberAuthor

    I removed all generated files and I built Python from scratch:

    git clean -fdx
    ./configure --with-pydebug
    make 
    

    It fixed the issue: BOOTSTRAP_MODOBJS now contains Modules/signalmodule.o.

    The question is why/how BOOTSTRAP_MODOBJS can become empty sometimes.

    BOOTSTRAP_MODOBJS variable:

    BOOTSTRAP_MODOBJS=   Modules/atexitmodule.o  Modules/faulthandler.o  Modules/posixmodule.o  Modules/signalmodule.o  Modules/_tracemalloc.o  Modules/_suggestions.o  Modules/_datetimemodule.o  Modules/_codecsmodule.o  Modules/_collectionsmodule.o  Modules/errnomodule.o  Modules/_io/_iomodule.o Modules/_io/iobase.o Modules/_io/fileio.o Modules/_io/bytesio.o Modules/_io/bufferedio.o Modules/_io/textio.o Modules/_io/stringio.o  Modules/itertoolsmodule.o  Modules/_sre/sre.o  Modules/_sysconfig.o  Modules/_threadmodule.o  Modules/timemodule.o  Modules/_typesmodule.o  Modules/_typingmodule.o  Modules/_weakref.o  Modules/_abc.o  Modules/_functoolsmodule.o  Modules/_localemodule.o  Modules/_opcode.o  Modules/_operator.o  Modules/_stat.o  Modules/symtablemodule.o  Modules/pwdmodule.o
    
  2. vstinner commented on Nov 5, 2026

    @vstinner
    MemberAuthor

    Example of the issue on FreeBSD. I updated my Git checkout and ran make, but then the BOOTSTRAP_MODOBJS variable was empty.

    vstinner@freebsd$ git pull
    vstinner@freebsd$ gmake
    ./configure '--cache-file=../python-config.cache' '--with-pydebug' 'OPT=-O0' '--disable-gil' 'CFLAGS='
    (...)
    config.status: creating Makefile.pre
    (...)
    configure: creating Makefile
    (...)
    
    vstinner@freebsd$ grep ^BOOTSTRAP_MODOBJS Makefile
    BOOTSTRAP_MODOBJS=
    

    If I modify Makefile.pre.in, make rebuilds Makefile and this time, it generates properly the BOOTSTRAP_MODOBJS variable:

    vstinner@freebsd$ touch Makefile.pre.in 
    
    vstinner@freebsd$ LANG= LC_ALL= gmake Objects/object.o
    CONFIG_FILES=Makefile.pre CONFIG_HEADERS= ./config.status
    config.status: creating Makefile.pre
    gmake -f Makefile.pre Makefile
    gmake[1]: Entering directory '/home/vstinner/python/main'
    ./Modules/makesetup -c ./Modules/config.c.in \
    			-s Modules \
    			Modules/Setup.local \
    			Modules/Setup.stdlib \
    			-b Modules/Setup.bootstrap \
    			./Modules/Setup
    The Makefile was updated, you may need to re-run make.
    gmake[1]: Leaving directory '/home/vstinner/python/main'
    ./Modules/makesetup -c ./Modules/config.c.in \
    			-s Modules \
    			Modules/Setup.local \
    			Modules/Setup.stdlib \
    			-b Modules/Setup.bootstrap \
    			./Modules/Setup
    The Makefile was updated, you may need to re-run make.
    gmake: 'Objects/object.o' is up to date.
    
    vstinner@freebsd$ grep ^BOOTSTRAP_MODOBJS Makefile
    BOOTSTRAP_MODOBJS=   Modules/atexitmodule.o  Modules/faulthandler.o  (...)
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buildThe build process and cross-buildtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions