Skip to content

Conversation

@stratakis
Copy link
Contributor

@stratakis stratakis commented Oct 17, 2025

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 llvm/llvm-project#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.

@stratakis
Copy link
Contributor Author

stratakis commented Oct 20, 2025

With GCC when the -pack-relative-relocs linker flag is used, BOLT fails again on the same functions.

@vstinner
Copy link
Member

cc @corona10

…during BOLT runs

With LLVM >= 21.1.0 BOLT can handle computed gotos in PIC compiled code.

However depending on the combination of --with-lto, --enable-shared,
--enable-optmizations and using packed rellocations on the linker
build configs might still need to skip functions containing computed
gotos.
@stratakis stratakis force-pushed the llvm_bolt_gotos_2110 branch from 41d3a75 to 33effce Compare November 20, 2025 02:38
@stratakis
Copy link
Contributor Author

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: #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

@vstinner
Copy link
Member

vstinner commented Dec 9, 2025

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/.

@stratakis
Copy link
Contributor Author

Added some fixups commits. However some builds are breaking by this change as mentioned in #140250 (comment) so I think it would be ideal to have BOLT fixed first before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants