[Pkg-tcltk-devel] Bug#446335: tcl8.4: GCC unit-at-a-time optimization problem

Johann Glaser glaser at ict.tuwien.ac.at
Fri Oct 12 08:58:41 UTC 2007

Package: tcl8.4
Version: 8.4.16-1
Severity: important

The GCC optimizer "unit-at-a-time" causes problems with the TCL 8.4 library
in our use case. In some setups we experience stack corruption which we
tracked down to happen in the TCL libraries.

We use OMNeT++ (http://www.omnetpp.org/) which itself uses TCL internally
for the GUI. We build a class hierarchy above it which heavily utilizes
coroutines, implemented by OMNeT++'s cCoroutine class, which itself uses
Stig Kofoed's "Portable Coroutines"
section 4.2, pp.34). For my discussion with the OMNeT++ people please see

Debian's precompiled TCL library causes the problem, it is compiled with the
"-O2" GCC option. When we compile TCL from the sources without the "-O2"
optimizer setting, no problems occur. When we use "-O2 -fno-unit-at-a-time"
no problems occur too. When using GCC 3.3, no problems occur.

The new optimizer "unit-at-a-time" was introduced in GCC 3.4
(http://gcc.gnu.org/gcc-3.4/changes.html) but was known to have issues since
then. Starting from GCC 4.2 a new option "-fno-toplevel-reorder"
(http://gcc.gnu.org/gcc-4.2/changes.html) was introduced, which will replace
"-fno-unit-at-a-time" in some future version of GCC. In our case, this
option does _not_ fix the problem. We also observed that libtcl8.4.so
compiled with "-O2" is approx. 20kB smaller than with "-O2
-fno-unit-at-a-time", but we didn't have the time to find out which symbols
were removed or what other differences occur.

We observed the problem on the i386 and the x86_64 platforms.

As a workaround we propose to change the compile scripts to use "-O2
-fno-unit-at-a-time" as compiler flags.

-- System Information:
Debian Release: lenny/sid
  APT prefers testing-proposed-updates
  APT policy: (500, 'testing-proposed-updates'), (500, 'proposed-updates'), (500, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 2.6.21 (PREEMPT)
Locale: LANG=de_AT at euro, LC_CTYPE=de_AT at euro (charmap=ISO-8859-15)
Shell: /bin/sh linked to /bin/bash

Versions of packages tcl8.4 depends on:
ii  libc6                         2.6.1-5    GNU C Library: Shared libraries

tcl8.4 recommends no packages.

-- no debconf information

More information about the Pkg-tcltk-devel mailing list