Tcl Source Code

View Ticket
Login
Ticket UUID: 8c025f8f0d72af49e8b10d12744c2f380861fdc9
Title: Run-time error on tcl 8.6.11 32 bits (from cross-compile Centos6.9 64-bits)
Type: Bug Created on: 2021-01-19 16:26:15
Submitter: anonymous Assigned to: jan.nijtmans
Subsystem: 53. Configuration and Build Tools Severity: Important
Priority: 5 Medium Last modified: 2021-01-23 00:08:14
Status: Closed Closed by: chw
Resolution: Fixed Closed on: 2021-01-23 00:08:14
Version: 8.6.11
Description:
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.
User Comments:
jan.nijtmans added on 2021-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!


chw added on 2021-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.nijtmans added on 2021-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 ....


chw added on 2021-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).