You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support PGO in cross-compiles when transparent emulation is available #141926
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.
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.
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.
LLVM_PROFILE_FILE="/Users/zb/workspace/cpython/code-%p.profclangr" ./python.exe -m test --pgo --timeout=
dyld[5686]: Library not loaded: /Users/zb/workspace/cpython/install/lib/libpython3.15.dylib
Referenced from: <51368F0A-5014-3695-8ACB-CDBC35555AFB> /Users/zb/workspace/cpython/python.exe
Reason: tried: '/Users/zb/workspace/cpython/install/lib/libpython3.15.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/zb/workspace/cpython/install/lib/libpython3.15.dylib' (no such file), '/Users/zb/workspace/cpython/install/lib/libpython3.15.dylib' (no such file)
make: *** [profile-run-stamp] Abort trap: 6
because RUNSHARED is cleared. So on HEAD, PGO is not "disabled", but is broken.
I wonder if we should just stop unsetting RUNSHARED entirely 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?
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…