Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2021-01-23
00:08 • Ticket [8c025f8f0d] Run-time error on tcl 8.6.11 32 bits (from cross-compile Cen... artifact: de2a1db748 user: chw
2021-01-22
15:43 • Closed ticket [8c025f8f0d]. artifact: 427f7e22f7 user: jan.nijtmans
05:28 • Ticket [8c025f8f0d]: 3 changes artifact: da3ccc0427 user: chw
2021-01-21
15:56
Fix [8c025f8f0d]: Run-time error on tcl 8.6.11 32 bits (from cross-compile Centos6.9 64-bits) check-in: 615e43f536 user: jan.nijtmans tags: core-8-6-branch
15:54
Fix [8c025f8f0d]: Run-time error on tcl 8.6.11 32 bits (from cross-compile Centos6.9 64-bits) check-in: c5ac9ae3e9 user: jan.nijtmans tags: core-8-5-branch
2021-01-20
08:56 • Pending ticket [8c025f8f0d]: Run-time error on tcl 8.6.11 32 bits (from cross-co... artifact: 3303e28cb7 user: jan.nijtmans
08:52
Possible fix (workaround) for [8c025f8f0d]: Run-time error on tcl 8.6.11 32 bits (from cross-compile... closed check-in: ad9ee07264 user: jan.nijtmans tags: bug-8c025f8f0d
2021-01-19
16:26 • New ticket [8c025f8f0d] Run-time error on tcl 8.6.11 32 bits (from cross-compile... artifact: 1f72e35faa user: anonymous

Run-time error on tcl 8.6.11 32 bits (from cross-compile Centos6.9 64-bits)

Closed / Fixed8c025f8f0d72af49e8b10d12744c2f380861fdc9Created 6 years agoUpdated 6 years ago
Descriptionplain2021-01-19 16:26:15
I am trying to get a 32bits tcl while compiling on a Linux Centos 6.9 64-bits system.
I did:

./configure --disable-64bit --build=i686 -prefix=/home/xx/yy/zz/tcl8.6.11
make CFLAGS="-m32 -D_USE_32BIT_TIME_T=1" LDFLAGS="-m32"
make install
cd ../bin
ln -s tclsh8.6 tclsh

And then:
[jpcaron@dev2-71 bin]$ ./tclsh
% info patchlevel
8.6.11
% clock format [clock seconds]
integer value too large to represent
%

I traced back the issue to the configure file.
The configure determines the system support long for the 64-bits integer and set TCL_WIDE_INT_IS_LONG to 1 to be used by gcc.
:
checking for required early compiler flags...  _LARGEFILE64_SOURCE
checking for 64-bit integer type... using long
checking whether byte ordering is bigendian... no
:

 When the compile comes with -m32, it is too late already since TCL_WIDE_INT_IS_LONG is set (via -D on the gcc command line). Since -DTCL_WIDE_INT_IS_LONG=1, the header file will force the use of long.

As a workaround, I set an environment variable before I run the configure:
export tcl_cv_type_64bit="long long"

When I try again...
:
checking for 64-bit integer type... (cached) long long
:

[jpcaron@dev2-71 bin]$ ./tclsh
% info patchlevel
8.6.11
% clock format [clock seconds]
Tue Jan 19 11:15:19 EST 2021
%

Would be nice if you could either update the configure file to take the build type in consideration or the TCL core overwrite the -DTCL_WIDE_INT_IS_LONG=1 when gcc is using -m32 or document the cross-compile workaround to get the 32-bits program.

Thanks.
Referenced by3
  • 615e43f536Fix [8c025f8f0d]: Run-time error on tcl 8.6.11 32 bits (from cross-compile Centos6.9 64-bits) check-in2021-01-21 15:56:52
  • c5ac9ae3e9Fix [8c025f8f0d]: Run-time error on tcl 8.6.11 32 bits (from cross-compile Centos6.9 64-bits) check-in2021-01-21 15:54:02
  • ad9ee07264Possible fix (workaround) for [8c025f8f0d]: Run-time error on tcl 8.6.11 32 bits (from cross-compile Centos6.9 64-bits). Since autoconf-2.59 has limited support for cross-compilation, a better fix has to wait for Tcl 8.7 (which uses autoconf-2.70) check-in2021-01-20 08:52:10
jan.nijtmanswiki2021-01-20 08:56:37

Proposed fix here: [ad9ee07264c24678]. Can you please test if this works for you? Something better has to wait for 8.7, since 8.6 still uses autoconf-2.59 with very limited cross-compile support.

Thanks for the report!

chwplain2021-01-22 05:28:30
From the c.l.t. thread https://groups.google.com/g/comp.lang.tcl/c/SMkBjGBEUsY

On CentOS 6 x86_64 with 32 bit development packages installed this sequence of
commands produces a perfectly working 32 bit tclsh8.6:

mkdir /tmp/tcl86
cd /tmp/tcl86
wget -c https://prdownloads.sourceforge.net/tcl/tcl8.6.11-src.tar.gz
tar xzf tcl8.6.11-src.tar.gz
cd tcl8.6.11/unix
CC="cc -m32" ./configure --prefix=/tmp/tcl86
make && make install
jan.nijtmanswiki2021-01-22 15:43:55

Thanks, Christian, for this info! Indeed, this isn't really a bug in Tcl, but it's true that the determination of TCL_WIDE_INT_IS_LONG is tricky. So, if a small change in tcl.h can correct (workaroud) a user's mistake, why not ....

chwplain2021-01-23 00:08:14
I'd prefer to present (if possible at all) an #error with
some guidance on how to fix the root cause (passing problematic
compiler flags after configure rendering configure lesser useful).
Log in (anonymous is fine) to add a comment.