gh-101525: Check whether to skip functions with computed gotos during BOLT runs
With LLVM >= 21.1.0 BOLT can handle computed gotos in PIC compiled code.
However in some cases computed gotos still produce issues.
This PR handles it this way:
For either GCC or Clang, functions with computed gotos are skipped when LLVM < 21.1.0.
With version >= 21.1.0 where https://github.com/llvm/llvm-project/pull/120267 exists we no longer skip these functions except when packed relocations are involved. The logic handles skipping of the various functions created by either GCC or Clang depending on the type of build.
- Issue: gh-101525
With GCC when the -pack-relative-relocs linker flag is used, BOLT fails again on the same functions.
cc @corona10
I've rebased to add various edge cases and combinations.
Initially I just removed the --skip-funcs flag to test what works and what not.
Tested combinations of --with-lto, --enable-optimizations, --enable-shared and packed-relocations which made things weirder.
Overall out of 32 different build configs that I've tested, 8 didn't work, reported here: https://github.com/python/cpython/issues/141775.
While I think I caught all the edge cases, at least for these combinations, 3 builds configs actually break with this change:
GCC shared build with packed relocs:
CC=gcc LDFLAGS="-Wl,-z,pack-relative-relocs" ./configure --enable-bolt --enable-shared && make -j
Clang shared build with packed relocs:
CC=clang CXX=clang++ CFLAGS="-gdwarf-4" LDFLAGS="-Wl,-z,pack-relative-relocs" ./configure --enable-bolt --enable-shared && make -j
Clang shared build with LTO and packed relocs:
CC=clang CXX=clang++ CFLAGS="-gdwarf-4" LDFLAGS="-Wl,-z,pack-relative-relocs" ./configure --with-lto --enable-bolt --enable-shared && make -j
bedevere/news — No news entry in Misc/NEWS.d/next/ or "skip news" label found
Would you mind to add a NEWS entry in the Build category? You can use blurb-it online service or blurb command line: https://devguide.python.org/.
Added some fixups commits. However some builds are breaking by this change as mentioned in https://github.com/python/cpython/pull/140250#issuecomment-3555530825 so I think it would be ideal to have BOLT fixed first before.