Skip to content

Configuring with LIBS=-lrt leaves _posixshmem without -lrt #162243

Description

@computerquip-work

Bug report

Building Python with LIBS=-lrt leaves _posixshmem without -lrt in its link flags. I think this is meant to work, since the documentation lists -lrt as an example.

The check for shm_open succeeds because it already has -lrt from LIBS, so configure decides it doesn’t need to add anything. That works for the check, but _posixshmem is linked separately and doesn’t use LIBS. It still needs -lrt in its own link flags.

This reproduces on Linux systems where shared-memory functions need librt:

cpython_src="$PWD"
mkdir -p build/shmem-repro
cd build/shmem-repro

"$cpython_src/configure" --with-pydebug LIBS=-lrt LDFLAGS=-Wl,--as-needed
grep '^MODULE__POSIXSHMEM_LDFLAGS=' Makefile
make -j4
./python -c 'from multiprocessing import shared_memory'

MODULE__POSIXSHMEM_LDFLAGS is empty. The build reports undefined symbol: shm_unlink, and the import fails with ModuleNotFoundError for _posixshmem. I’d expect configure to give the module -lrt so it can load.

Clearing LIBS for this check gets configure to record -lrt for the module. LIBS is restored afterward. This looks similar to the curses detection problem fixed in PR #156130.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

Activity

  1. added
    buildThe build process and cross-build
    on Nov 19, 2026
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-buildextension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions