Support PGO in cross-compiles when transparent emulation is available #141926
Copy link
Copy link
Closed
Labels
buildThe build process and cross-buildThe build process and cross-buildtype-featureA feature request or enhancementA feature request or enhancement
Description
A while ago, in 1abe1c5 (from https://bugs.python.org/issue14330) configure was updated to unset RUNSHARED when cross compiling. Unfortunately, this has the effect of disabling PGO during cross-compiles.
In python-build-standalone we patch this out so we can run PGO as we do frequent cross-compilation on systems that support emulated execution of the target binary, e.g., x86-64 macOS can be run on aarch64 via Rosetta.
I'd like to upstream this patch (see astral-sh/python-build-standalone#864) in a generalized form.
This is a subset of #113123 which is about generalized support for PGO in cross-compiles and focuses on setting a variable to wrapper program allowing emulated execution. I intend to look into that separately.
Linked PRs
Metadata
Metadata
Assignees
Labels
buildThe build process and cross-buildThe build process and cross-buildtype-featureA feature request or enhancementA feature request or enhancement
Activity
zanieb commentedon Nov 24, 2025
zanieb commentedon Nov 24, 2025
This may be already supported in some subset of use-cases? e.g., when libpython is statically linked? macOS might also be a bad example, as those aren't always considered cross-builds? I'm going to do some checks and share a basic reproduction.
zanieb commentedon Nov 25, 2025
Well, the simple reproduction for me is
which fails with
because
RUNSHAREDis cleared. So on HEAD, PGO is not "disabled", but is broken.zanieb commentedon Nov 25, 2025
And, as I suspected, without
--enable-shared, PGO works fine — because you don't needRUNSHARED.zanieb commentedon Nov 25, 2025
I wonder if we should just stop unsetting
RUNSHAREDentirely as is done in the python-build-standalone patch? It seems like we'll attempt to run PGO regardless. This would be an alternative to my opt-in approach at #141927 but seems cleaner?brettcannon commentedon Nov 25, 2025
If you're not unsetting it and it's working for PBS and it's passing CI here then it seems like a reasonable thing to do.
pythongh-141926: Do not unset `RUNSHARED` when cross-compiling
pythongh-141926: Do not unset `RUNSHARED` when cross-compiling
gh-141926: Do not unset `RUNSHARED` when cross-compiling (#141958)
pythongh-141926: Do not unset `RUNSHARED` when cross-compiling (pytho…