Skip to content

gh-126877: Fix the configure check for Tcl/Tk with optimizing compilers#153543

Merged
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:gh-126877-tcltk-link-dce
Jul 11, 2026
Merged

gh-126877: Fix the configure check for Tcl/Tk with optimizing compilers#153543
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:gh-126877-tcltk-link-dce

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Jul 11, 2026

Copy link
Copy Markdown
Member

The configure check for Tcl/Tk assigned the addresses of Tcl_Init() and Tk_Init() to unused variables. Optimizing compilers can eliminate these dead stores, dropping the only reference to the symbols, so the check links — and Tcl/Tk is detected as available — even when the libraries are missing.

This calls the functions instead, matching the existing __register_frame() probe in the same file. A call to an external function cannot be optimized away, and the check still only links and never runs, so it stays cross-compile safe.

Verified with gcc at -O2: the old probe links with the symbols absent, the new one correctly fails, and configure then reports _tkinter... missing instead of a false positive.

…ompilers

The check assigned the addresses of Tcl_Init() and Tk_Init() to unused
variables, which optimizing compilers can eliminate, so it linked even
when the libraries were missing.  Call the functions instead.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@serhiy-storchaka serhiy-storchaka force-pushed the gh-126877-tcltk-link-dce branch from 007fd01 to c5c30ab Compare July 11, 2026 07:40
@serhiy-storchaka serhiy-storchaka added build The build process and cross-build needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Jul 11, 2026

@ned-deily ned-deily left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to work OK on macOS.

@serhiy-storchaka serhiy-storchaka enabled auto-merge (squash) July 11, 2026 09:44
@serhiy-storchaka serhiy-storchaka merged commit ff0a9ae into python:main Jul 11, 2026
118 of 122 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Jul 11, 2026

Copy link
Copy Markdown

GH-153553 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jul 11, 2026
@bedevere-app

bedevere-app Bot commented Jul 11, 2026

Copy link
Copy Markdown

GH-153554 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Jul 11, 2026
@bedevere-app

bedevere-app Bot commented Jul 11, 2026

Copy link
Copy Markdown

GH-153555 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Jul 11, 2026
@serhiy-storchaka serhiy-storchaka deleted the gh-126877-tcltk-link-dce branch July 11, 2026 09:55
serhiy-storchaka added a commit that referenced this pull request Jul 11, 2026
…compilers (GH-153543) (GH-153555)

The check assigned the addresses of Tcl_Init() and Tk_Init() to unused
variables, which optimizing compilers can eliminate, so it linked even
when the libraries were missing.  Call the functions instead.
(cherry picked from commit ff0a9ae)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
serhiy-storchaka added a commit that referenced this pull request Jul 11, 2026
…compilers (GH-153543) (GH-153554)

The check assigned the addresses of Tcl_Init() and Tk_Init() to unused
variables, which optimizing compilers can eliminate, so it linked even
when the libraries were missing.  Call the functions instead.
(cherry picked from commit ff0a9ae)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
serhiy-storchaka added a commit that referenced this pull request Jul 11, 2026
…compilers (GH-153543) (GH-153553)

The check assigned the addresses of Tcl_Init() and Tk_Init() to unused
variables, which optimizing compilers can eliminate, so it linked even
when the libraries were missing.  Call the functions instead.
(cherry picked from commit ff0a9ae)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Abhi210 pushed a commit to Abhi210/cpython that referenced this pull request Jul 11, 2026
…ompilers (pythonGH-153543)

The check assigned the addresses of Tcl_Init() and Tk_Init() to unused
variables, which optimizing compilers can eliminate, so it linked even
when the libraries were missing.  Call the functions instead.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants