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 — 3.14.0b3 JIT build fails with `KeyError: 'R_X86_64_GOTPCREL'` · Issue #135690 · python/cpython

3.14.0b3 JIT build fails with KeyError: 'R_X86_64_GOTPCREL' #135690

New issue
Copy link
New issue
Copy link
Closed
Closed
3.14.0b3 JIT build fails with KeyError: 'R_X86_64_GOTPCREL'#135690
Copy link
Assignees
brandtbucher
Labels
3.14bugs and security fixesbugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-JITtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@zanieb
zanieb
opened on Jun 18, 2025
Issue body actions

Bug description:

The python-build-standalone experimental JIT build fails on 3.14.0b3 with:

cpython-3.14>     | Traceback (most recent call last):
cpython-3.14>     |   File "/build/Python-3.14.0b3/Tools/jit/_targets.py", line 165, in _compile
cpython-3.14>     |     return await self._parse(o)
cpython-3.14>     |            ^^^^^^^^^^^^^^^^^^^^
cpython-3.14>     |   File "/build/Python-3.14.0b3/Tools/jit/_targets.py", line 106, in _parse
cpython-3.14>     |     self._handle_section(wrapped_section["Section"], group)
cpython-3.14>     |     ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cpython-3.14>     |   File "/build/Python-3.14.0b3/Tools/jit/_targets.py", line 352, in _handle_section
cpython-3.14>     |     hole = self._handle_relocation(base, relocation, stencil.body)
cpython-3.14>     |   File "/build/Python-3.14.0b3/Tools/jit/_targets.py", line 416, in _handle_relocation
cpython-3.14>     |     return _stencils.Hole(offset, kind, value, symbol, addend)
cpython-3.14>     |            ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cpython-3.14>     |   File "<string>", line 9, in __init__
cpython-3.14>     |   File "/build/Python-3.14.0b3/Tools/jit/_stencils.py", line 141, in __post_init__
cpython-3.14>     |     self.func = _PATCH_FUNCS[self.kind]
cpython-3.14>     |                 ~~~~~~~~~~~~^^^^^^^^^^^
cpython-3.14>     | KeyError: 'R_X86_64_GOTPCREL'

ref https://github.com/astral-sh/python-build-standalone/actions/runs/15737844881/job/44355511468?pr=663

I'm sort of confused that it's new? #130097 looks relevant but has been around for a bit. 3.14.0b2 works.

We use LLVM v20.1.4

CPython versions tested on:

3.14

Operating systems tested on:

Linux

Activity

  1. zanieb
    assigned
    brandtbucher
    on Jun 18, 2025
  2. zanieb
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    topic-JIT
    on Jun 18, 2025
  3. picnixz
    added
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    3.14bugs and security fixesbugs and security fixes
    on Jun 19, 2025
  4. Zheaoli commented on Jun 20, 2025

    @Zheaoli
    Zheaoli
    on Jun 20, 2025
    Contributor
    More actions

    First, the official llvm support is 19. I think the JIT is not support 20 officially yet.

    BTW, I can not reproduce it on 20.1.4, 20.1.7 and LLVM main branch

    Image

  5. zanieb commented on Jun 20, 2025

    @zanieb
    zanieb
    on Jun 20, 2025
    ContributorAuthor
    More actions

    Did you change the target LLVM version? It's hard-coded to 19

    cpython/Tools/jit/_llvm.py

    Lines 13 to 15 in bfcbb28

    _LLVM_VERSION = 19
    _LLVM_VERSION_PATTERN = re.compile(rf"version\s+{_LLVM_VERSION}\.\d+\.\d+\S*\s+")
    _EXTERNALS_LLVM_TAG = "llvm-19.1.7.0"

  6. Zheaoli commented on Jun 21, 2025

    @Zheaoli
    Zheaoli
    on Jun 21, 2025
    Contributor
    More actions

    Did you change the target LLVM version? It's hard-coded to 19

    Yes

  7. Zheaoli commented on Jun 21, 2025

    @Zheaoli
    Zheaoli
    on Jun 21, 2025
    Contributor
    More actions

    Would you mind giving me a codebase with a patched config?

  8. zanieb commented on Jun 21, 2025

    @zanieb
    zanieb
    on Jun 21, 2025
    ContributorAuthor
    More actions

    You can see the downstream build system at astral-sh/python-build-standalone#663

    The JIT LLVM version patch is at

    • https://github.com/astral-sh/python-build-standalone/blob/main/cpython-unix/patch-jit-llvm-version-3.14.patch

    We also backport #134276

    • https://github.com/astral-sh/python-build-standalone/blob/main/cpython-unix/patch-jit-cflags-314.patch

    so our invocation looks like

    /tools/host/bin/python3.14 ./Tools/jit/build.py x86_64-unknown-linux-gnu --output-dir . --pyconfig-dir . --cflags=" -fdebug-default-version=4 -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw"

  9. Zheaoli commented on Jun 21, 2025

    @Zheaoli
    Zheaoli
    on Jun 21, 2025
    Contributor
    More actions

    Thanks for the information. I might need a little bit time to reproduce it on my local environment

    Reacted by stonebig
  10. Zheaoli commented on Jun 23, 2025

    @Zheaoli
    Zheaoli
    on Jun 23, 2025
    Contributor
    More actions

    Sorry for taking some time. (My desktop crashed So I need to setup a new environment)

    I think the root cause here you use -fPIC here. We don't handle this circumstance on x86_64(only in aarch64 if I'm correct)

    I think the PIC flag will generate R_X86_64_GOTPCREL to calculate the address.(not sure about this

    cc @brandtbucher

  11. AndPuQing commented on Jun 26, 2025

    @AndPuQing
    AndPuQing
    on Jun 26, 2025
    Contributor
    More actions

    I think so. The -fPIC compilation flags were removed in gh-130097, which means that jit no longer uses GOT, so the support for R_X86_64_GOTPCREL was removed in _PATCH_FUNCS. I used the following patch, and now python-build-standalone works well.

    The compilation instructions I used were

    ./build-linux.py --python cpython-3.14 --options pgo+lto --target-triple x86_64-unknown-linux-gnu
    diff --git a/cpython-unix/build-cpython.sh b/cpython-unix/build-cpython.sh
    index 2296f2b..0b7cfda 100755
    --- a/cpython-unix/build-cpython.sh
    +++ b/cpython-unix/build-cpython.sh
    @@ -90,12 +90,6 @@ else
         patch -p1 -i ${ROOT}/patch-xopen-source-ios-legacy.patch
     fi
     
    -# See https://github.com/python/cpython/pull/135146
    -# TODO(zanieb): Drop in 3.14b3
    -if [ -n "${PYTHON_MEETS_MINIMUM_VERSION_3_14}" ]; then
    -    patch -p1 -i ${ROOT}/patch-static-remote-debug-3.14.patch
    -fi
    -
     # LIBTOOL_CRUFT is unused and breaks cross-compiling on macOS. Nuke it.
     # Submitted upstream at https://github.com/python/cpython/pull/101048.
     if [ -n "${PYTHON_MEETS_MAXIMUM_VERSION_3_11}" ]; then
    @@ -653,8 +647,13 @@ fi
     # We patched configure.ac above. Reflect those changes.
     autoconf
     
    +# As of CPython 3.14 (GH-130097), the JIT compiler on x86-64 linux uses a
    +# model that conflicts with -fPIC. We strip it from CFLAGS_JIT to prevent
    +# compilation issues and ensure the correct model is used.
    +CFLAGS_JIT="${CFLAGS//-fPIC/}"
    +
     # Ensure `CFLAGS` are propagated to JIT compilation for 3.13+
    -CFLAGS=$CFLAGS CPPFLAGS=$CFLAGS CFLAGS_JIT=$CFLAGS LDFLAGS=$LDFLAGS \
    +CFLAGS=$CFLAGS CPPFLAGS=$CFLAGS CFLAGS_JIT=$CFLAGS_JIT LDFLAGS=$LDFLAGS \
         ./configure ${CONFIGURE_FLAGS}
     
     # Supplement produced Makefile with our modifications.
  12. zanieb commented on Jun 26, 2025

    @zanieb
    zanieb
    on Jun 26, 2025
    ContributorAuthor
    More actions

    Wonderful, I've implemented that in astral-sh/python-build-standalone@2f5e7c4 and CI is passing.

  13. brandtbucher commented on Jun 26, 2025

    @brandtbucher
    brandtbucher
    on Jun 26, 2025
    Member
    More actions

    Nice, great work everybody!

  14. brandtbucher
    closed this as completedon Jun 26, 2025
  15. zanieb commented on Jun 27, 2025

    @zanieb
    zanieb
    on Jun 27, 2025
    ContributorAuthor
    More actions

    To be clear, it's expected that -fPIC won't be supported for the foreseeable future? I guess we should error ahead of time if that's present in the CFLAGS?

  16. brandtbucher commented on Jun 27, 2025

    @brandtbucher
    brandtbucher
    on Jun 27, 2025
    Member
    More actions

    I don't think it's our job to parse and validate the flags being passed in here. The way I see it, CFLAGS_JIT is just an escape-hatch for distributors who really need it.

    -fPIC, and all of the other flags we do and don't pass to Clang for stencil generation, are a super low-level implementation detail and subject to change in major version bumps without notice. My advice is to figure out the minimum flags that need to be passed to CFLAGS_JIT (in your case, probably just -I/tools/deps/include?) and only pass those to avoid messing up stencil generation in subtle ways.

  17. zanieb commented on Jun 27, 2025

    @zanieb
    zanieb
    on Jun 27, 2025
    ContributorAuthor
    More actions

    I don't think it's our job to parse and validate the flags being passed in here.

    I agree in general, but this error message is quite bad and won't point a distributor to the root cause — if you don't want to parse the flags then there should probably be a better error message when this key (or some other key) is missing from _PATCH_FUNCS.

    My advice is to figure out the minimum flags that need to be passed to CFLAGS_JIT (in your case, probably just -I/tools/deps/include?)

    That feels just as feasible to break us in subtle ways, e.g., we could miss things like #134291 — hard to say one way is definitely better than the other.

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

Metadata

Metadata

Assignees

  • @brandtbucher
    brandtbucher

Labels

3.14bugs and security fixesbugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-JITtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

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.