GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — BOLT issue with Android: annotation value out of range · Issue #139245 · python/cpython

BOLT issue with Android: annotation value out of range #139245

New issue
Copy link
New issue
Copy link
Open
Open
BOLT issue with Android: annotation value out of range#139245
Copy link
Assignees
corona10
Labels
OS-androidbuildThe build process and cross-buildThe build process and cross-buildpendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is provided

Description

@mgxhhg
mgxhhg
opened on Sep 22, 2025
Issue body actions

A third party has an Android NDK for arm64 linux, so I configured it into an Android chroot container. In order to run pgo (--enable-optimizations), I configured Android's linker64 into the container, but I found that Bolt would crash once it encountered the annotation/relocation section of the dynamic library.

Checked 111 modules (31 built-in, 74 shared, 1 n/a on linux-aarch64, 0 disabled, 5 missing, 0 failed on import)
make[2]: 离开目录“/home/sed/cpython/build”
make[1]: 离开目录“/home/sed/cpython/build”                                         
make profile-bolt-stamp                                                            
make[1]: 进入目录“/home/sed/cpython/build”                                         
# Ensure a pristine, pre-BOLT copy of the binary and no profile data from last run.for bin in python libpython3.12.so.1.0; do \                                         prebolt="${bin}.prebolt"; \                                                        
if [ -e "${prebolt}" ]; then \                                                       
echo "Restoring pre-BOLT binary ${prebolt}"; \                                     
mv "${bin}.prebolt" "${bin}"; \                                                  
fi; \                                                                              
cp "${bin}" "${prebolt}"; \                                                        
rm -f ${bin}.bolt.*.fdata ${bin}.fdata; \                                        
done                                                                               
# Instrument each binary.                                                          
for bin in python libpython3.12.so.1.0; do \                                         
/home/sed/android-ndk-r29-beta2/toolchains/llvm/prebuilt/linux-arm64/bin/aarch64-linux-android-llvm-bolt "${bin}" -instrument -instrumentation-file-append-pid -instrumentation-file=/home/sed/cpython/build/${bin}.bolt -o ${bin}.bolt_inst -update-debug-sections -skip-funcs=_PyEval_EvalFrameDefault,sre_ucs1_match/1,sre_ucs2_match/1,sre_ucs4_match/1 ;
 \                                                                
mv "${bin}.bolt_inst" "${bin}"; \                                                
done                                                                               
BOLT-INFO: shared object or position-independent executable detected               
BOLT-INFO: Target architecture: aarch64                                            
BOLT-INFO: BOLT version: <unknown>                                                 
BOLT-INFO: first alloc address is 0x0                                              
BOLT-INFO: creating new program header table at address 0x200000, offset 0x200000  
BOLT-INFO: enabling relocation mode                                                
BOLT-INFO: forcing -jump-tables=move for instrumentation 
LLVM ERROR: annotation value out of range                                          
LLVM ERROR: annotation value out of range                                          
LLVM ERROR: annotation value out of range                                          
Aborted    
make[1]: *** [Makefile:848:profile-bolt-stamp] 错误 134                           
make[1]: 离开目录“/home/sed/cpython/build”                                         
make: *** [Makefile:877:bolt-opt] 错误 2

AI:

Cause:

ELF layout in Android/PIE mode

Your llvm-bolt is in PIE + relocation mode.

The Android64 linker parses the .note / .annotation section slightly differently than GNU ld/ld.lld, causing BOLT to insert an invalid value for the annotation counter.

"annotation value out of range" means the profile counter number is outside the range it can encode.

aarch64 relocation mode bug

Under AArch64, BOLT's annotation emission does not take into account the alignment/pointer size restrictions of the Android toolchain.

This is a known bug in LLVM upstream (works fine on x86-64, crashes on aarch64/PIE).

libpython3.12.so.1.0 is a PIE shared object.

Therefore, BOLT will definitely trigger relocation mode.

The shared object contains a large number of functions (over 7000). BOLT attempts to write a counter annotation for each function, which causes the annotation section to overflow.

AI:

  1. Bolt is only used for executable programs, dynamic libraries are prohibited from using Bolt
    2.Limiting Bolt Pile Range / Mode

detailed:

https://chatgpt.com/share/68d15677-7658-800c-81a5-504ae7fe874d

Activity

  1. picnixz commented on Sep 22, 2025

    @picnixz
    picnixz
    on Sep 22, 2025
    Member
    More actions

    Is it a known upstream issue or not? please avoid dumping the entire Chat GPT information. If it's an already known upstream issue, I'm going to close it.

  2. picnixz
    added
    buildThe build process and cross-buildThe build process and cross-build
    OS-android
    on Sep 22, 2025
  3. picnixz
    changed the title [-]Bolt Error[/-] [+]BOLT issue with Android[/+] on Sep 22, 2025
  4. picnixz
    added
    pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is provided
    on Sep 22, 2025
  5. mgxhhg commented on Sep 22, 2025

    @mgxhhg
    mgxhhg
    on Sep 22, 2025
    Author
    More actions

    @picnixz

    ai: 🔹 3. Patch BOLT Source Code

    If you want to fix this:
    In bolt/lib/Profile/DataAggregator.cpp or related counter emission code, change the annotation writing logic to write sections in shards, or use 64-bit counters instead of 32-bit ones.

    An issue has been reported upstream.
    (aarch64 PIE crash)(llvm/llvm-project#57669)

    me:

    "However",the content in the link is not, it should be that chatgpt is hallucinating

  6. picnixz commented on Sep 22, 2025

    @picnixz
    picnixz
    on Sep 22, 2025
    Member
    More actions

    Indeed, the linked issue doesn't seem to be relevant and the fix mentions an upstream fix. AFAICT, there is an issue with annotations but that may be because it's on Android and BOLT is not even entirely supported on Tier 1 platforms (I also have segfaults sometimes) (BOLT is still marked as experimental)

    Maybe @corona10 has some idea here.

  7. picnixz
    changed the title [-]BOLT issue with Android[/-] [+]BOLT issue with Android: annotation value out of range[/+] on Sep 22, 2025
  8. corona10
    self-assigned this
    on Sep 22, 2025
  9. corona10 commented on Sep 22, 2025

    @corona10
    corona10
    on Sep 22, 2025
    Member
    More actions

    I will take a look at this issue at Wednesday UTC+9. (At the day, I can spend the whole day for OSS at current company)

  10. corona10 commented on Sep 24, 2025

    @corona10
    corona10
    on Sep 24, 2025
    Member
    More actions

    @mgxhhg I think that you should wait upstream reponse first.
    llvm/llvm-project#160124

    If there is something we have to handle, we can do it but not this moment.

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

Metadata

Metadata

Assignees

  • @corona10
    corona10

Labels

OS-androidbuildThe build process and cross-buildThe build process and cross-buildpendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is provided

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.