Skip to content

checksharedmods fails on non-glibc cross builds (host interpreter gets target LD_LIBRARY_PATH) #160924

Open

Description

@jaipaulcheernam

Bug report

Cross-compiling 3.15 for a musl target (glibc build machine) fails in make at the checksharedmods target:

nativepython3: error while loading shared libraries: libc.so: cannot open shared object file: No such file or directory
make: *** [Makefile:1801: checksharedmods] Error 127

The rule runs the build python under RUNSHARED:

@$(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/Tools/build/check_extension_modules.py

In a cross build PYTHON_FOR_BUILD is the host interpreter (from --with-build-python) but RUNSHARED points LD_LIBRARY_PATH at the target's build dir, so the host interpreter gets the target libraries. On glibc->glibc nobody notices, but with a musl target the glibc host binary can't load the musl libc.so and dies before Python even starts.

This started with #141926 / GH-141958, which dropped the old

if test "$cross_compiling" = yes; then
  RUNSHARED=
fi

That PR was about getting PGO to work under emulation, but checksharedmods runs in the normal build_all path even without PGO, so now every non-emulated cross build to a different libc breaks here.

As far as I can tell check_extension_modules.py doesn't actually need the target libs on LD_LIBRARY_PATH when cross-compiling — it already takes the cross path (via _PYTHON_HOST_PLATFORM) and only checks that the module files exist, it doesn't import them.

Putting the cross_compiling RUNSHARED reset back makes the build work again. Would it make sense to restore it, or to only use RUNSHARED for the build-python when a HOSTRUNNER is set?

CPython versions tested on:

3.15

Operating systems tested on:

Linux

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