Skip to content

Commit 007fd01

Browse files
gh-126877: Fix the configure check for Tcl/Tk with optimizing compilers
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>
1 parent a1ef41a commit 007fd01

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Fix the :program:`configure` check for Tcl/Tk so that it is not defeated by
2+
dead-code elimination in optimizing compilers. The check now calls
3+
``Tcl_Init()`` and ``Tk_Init()`` instead of taking their addresses, which
4+
could be optimized away, causing Tcl/Tk to be wrongly detected as available
5+
when the libraries are missing.

configure

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4618,8 +4618,8 @@ WITH_SAVE_ENV([
46184618
# error "Tk older than 8.5.12 not supported"
46194619
#endif
46204620
], [
4621-
void *x1 = Tcl_Init;
4622-
void *x2 = Tk_Init;
4621+
Tcl_Init(NULL);
4622+
Tk_Init(NULL);
46234623
])
46244624
], [
46254625
have_tcltk=yes

0 commit comments

Comments
 (0)