Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BOLT fails with --enabled-shared on LLVM 19 with "unable to get new address" #128472

Closed
zanieb opened this issue Jan 4, 2025 · 1 comment · Fixed by #128511
Closed

BOLT fails with --enabled-shared on LLVM 19 with "unable to get new address" #128472

zanieb opened this issue Jan 4, 2025 · 1 comment · Fixed by #128511
Labels
build The build process and cross-build type-bug An unexpected behavior, bug, or error

Comments

@zanieb
Copy link
Contributor

zanieb commented Jan 4, 2025

Bug report

Bug description:

As originally reported in astral-sh/python-build-standalone#463

LLVM 19.x has a hard error when handling PIC compiled functions containing computed gotos. It appears prior versions of LLVM could silently have buggy behavior in this scenario. We need to skip functions with computed gotos to allow LLVM 19.x to work with BOLT.

This results in an error like

BOLT-ERROR: unable to get new address corresponding to input address 0x1af0fa in function _PyEval_EvalFrameDefault.localalias/1(*3). Consider adding this function to --skip-funcs=...

Reproduced with

./configure \
    py_cv_module__openssl=n/a \
    py_cv_module__hashlib=n/a \
    py_cv_module__gdbm=n/a \
    --without-ensurepip \
    --enable-shared \
    --enable-optimizations \
    --enable-bolt

Without --enable-shared, the failure doesn't occur.

There's an upstream fix in progress at llvm/llvm-project#120267 — I'm not sure when it will be available. In the meantime, we should skip the functions. The patch fixing this will extend the common flags proposed in #128455, e.g., zanieb@5448cd9

See also, commentary at #124948 (comment)

Additional logs
BOLT-INFO: Target architecture: x86_64
BOLT-INFO: BOLT version: 6a0964d75628b15bafd078342120888c0e6d126f
BOLT-INFO: first alloc address is 0x400000
BOLT-INFO: creating new program header table at address 0x600000, offset 0x200000
BOLT-WARNING: debug info will be stripped from the binary. Use -update-debug-sections to keep it.
BOLT-INFO: enabling relocation mode
BOLT-INFO: forcing -jump-tables=move for instrumentation
BOLT-INFO: enabling lite mode
BOLT-INFO: 0 out of 6 functions in the binary (0.0%) have non-empty execution profile
BOLT-INSTRUMENTER: Number of indirect call site descriptors: 2
BOLT-INSTRUMENTER: Number of indirect call target descriptors: 4
BOLT-INSTRUMENTER: Number of function descriptors: 4
BOLT-INSTRUMENTER: Number of branch counters: 1
BOLT-INSTRUMENTER: Number of ST leaf node counters: 4
BOLT-INSTRUMENTER: Number of direct call counters: 0
BOLT-INSTRUMENTER: Total number of counters: 5
BOLT-INSTRUMENTER: Total size of counters: 40 bytes (static alloc memory)
BOLT-INSTRUMENTER: Total size of string table emitted: 47 bytes in file
BOLT-INSTRUMENTER: Total size of descriptors: 356 bytes in file
BOLT-INSTRUMENTER: Profile will be saved to file /fast/workspace/cpython/python.bolt
BOLT-INFO: padding code to 0xa00000 to accommodate hot text
BOLT-INFO: output linked against instrumentation runtime library, lib entry point is 0xa06950
BOLT-INFO: clear procedure is 0xa02390
BOLT-INFO: patched build-id (flipped last bit)
BOLT-INFO: setting _end to 0xa0a0bc
BOLT-INFO: setting _end to 0xa0a0bc
BOLT-INFO: setting __bolt_runtime_start to 0xa06900
BOLT-INFO: setting __bolt_runtime_fini to 0xa06950
BOLT-INFO: setting __hot_start to 0x800000
BOLT-INFO: setting __hot_end to 0x80014c
BOLT-INFO: shared object or position-independent executable detected
BOLT-INFO: Target architecture: x86_64
BOLT-INFO: BOLT version: 6a0964d75628b15bafd078342120888c0e6d126f
BOLT-INFO: first alloc address is 0x0
BOLT-INFO: creating new program header table at address 0x600000, offset 0x600000
BOLT-WARNING: debug info will be stripped from the binary. Use -update-debug-sections to keep it.
BOLT-INFO: enabling relocation mode
BOLT-INFO: forcing -jump-tables=move for instrumentation
BOLT-INFO: enabling lite mode
BOLT-WARNING: Failed to analyze 1381 relocations
BOLT-INFO: 0 out of 7363 functions in the binary (0.0%) have non-empty execution profile
BOLT-INSTRUMENTER: Number of indirect call site descriptors: 1508
BOLT-INSTRUMENTER: Number of indirect call target descriptors: 7281
BOLT-INSTRUMENTER: Number of function descriptors: 7281
BOLT-INSTRUMENTER: Number of branch counters: 82352
BOLT-INSTRUMENTER: Number of ST leaf node counters: 43921
BOLT-INSTRUMENTER: Number of direct call counters: 0
BOLT-INSTRUMENTER: Total number of counters: 126273
BOLT-INSTRUMENTER: Total size of counters: 1010184 bytes (static alloc memory)
BOLT-INSTRUMENTER: Total size of string table emitted: 186842 bytes in file
BOLT-INSTRUMENTER: Total size of descriptors: 8306748 bytes in file
BOLT-INSTRUMENTER: Profile will be saved to file /fast/workspace/cpython/libpython3.14.so.1.0.bolt
BOLT-INFO: 62323 instructions were shortened
BOLT-INFO: removed 156 empty blocks
BOLT-INFO: UCE removed 1608 blocks and 99444 bytes of code
BOLT-INFO: padding code to 0x1000000 to accommodate hot text
BOLT-INFO: output linked against instrumentation runtime library, lib entry point is 0x11be950
BOLT-INFO: clear procedure is 0x11ba390
BOLT-INFO: patched build-id (flipped last bit)
BOLT-INFO: setting __bolt_runtime_start to 0x11be900
BOLT-INFO: setting __bolt_runtime_fini to 0x11be950
BOLT-INFO: setting __hot_start to 0x800000
BOLT-INFO: setting __hot_end to 0xe1e116
BOLT-ERROR: unable to get new address corresponding to input address 0x1af0fa in function _PyEval_EvalFrameDefault.localalias/1(*3). Consider adding this function to --skip-funcs=...

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

@zanieb zanieb added type-bug An unexpected behavior, bug, or error build The build process and cross-build labels Jan 4, 2025
@zanieb
Copy link
Contributor Author

zanieb commented Jan 4, 2025

This is also reported in #124948 though less clearly. There's helpful and relevant discussion there. I do not have a preference on which issue is retained, hopefully this one helps with discoverability. We should be able to patch this soon.

corona10 pushed a commit that referenced this issue Jan 7, 2025
…ors (gh-128511)

* Add `-skip-funcs` to BOLT options to fix computed goto errors

Co-authored-by: Gregory Szorc <gregory.szorc@gmail.com>

* NEWS

---------

Co-authored-by: Gregory Szorc <gregory.szorc@gmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jan 7, 2025
…to errors (pythongh-128511)

* Add `-skip-funcs` to BOLT options to fix computed goto errors

Co-authored-by: Gregory Szorc <gregory.szorc@gmail.com>

* NEWS

---------

(cherry picked from commit 24b147a)

Co-authored-by: Zanie Blue <contact@zanie.dev>
Co-authored-by: Gregory Szorc <gregory.szorc@gmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jan 7, 2025
…to errors (pythongh-128511)

* Add `-skip-funcs` to BOLT options to fix computed goto errors

Co-authored-by: Gregory Szorc <gregory.szorc@gmail.com>

* NEWS

---------

(cherry picked from commit 24b147a)

Co-authored-by: Zanie Blue <contact@zanie.dev>
Co-authored-by: Gregory Szorc <gregory.szorc@gmail.com>
corona10 pushed a commit that referenced this issue Jan 7, 2025
…oto errors (gh-128511) (gh-128572)

gh-128472: Add `-skip-funcs` to BOLT options to fix computed goto errors (gh-128511)

* Add `-skip-funcs` to BOLT options to fix computed goto errors



* NEWS

---------

(cherry picked from commit 24b147a)

Co-authored-by: Zanie Blue <contact@zanie.dev>
Co-authored-by: Gregory Szorc <gregory.szorc@gmail.com>
corona10 pushed a commit that referenced this issue Jan 7, 2025
…oto errors (gh-128511) (#128573)

gh-128472: Add `-skip-funcs` to BOLT options to fix computed goto errors (gh-128511)

* Add `-skip-funcs` to BOLT options to fix computed goto errors



* NEWS

---------

(cherry picked from commit 24b147a)

Co-authored-by: Zanie Blue <contact@zanie.dev>
Co-authored-by: Gregory Szorc <gregory.szorc@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build The build process and cross-build type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant