Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2007-09-05
23:21 • Closed ticket [440891ffff]: Linux inlining defeats compat/*.c plus 7 other c... artifact: 6a73c1ddd9 user: dgp
2003-11-13
01:28 • Ticket [440891ffff]: 4 changes artifact: 5bb83a8efd user: hobbs
01:28 • Ticket [440891ffff]: 1 change artifact: 766e80d0d3 user: hobbs
2003-11-12
23:37 • Open ticket [440891ffff]. artifact: eded7eeb52 user: dgp
11:49 • Ticket [440891ffff]: 6 changes artifact: d19b48f880 user: dgp
2001-09-18
23:53 • Closed ticket [440891ffff]. artifact: 090b8094da user: mdejong
23:23 • Ticket [440891ffff]: 4 changes artifact: e762d14bbe user: dgp
2001-09-08
12:40 • Ticket [440891ffff]: 4 changes artifact: 3526bd2887 user: mdejong
2001-09-06
08:57 • Ticket [440891ffff]: 4 changes artifact: 227ca77879 user: dgp
05:41 • Ticket [440891ffff]: 4 changes artifact: eaf313e42e user: hobbs
2001-07-17
03:20 • Ticket [440891ffff]: 4 changes artifact: b4e21e019d user: dgp
02:51 • Ticket [440891ffff]: 4 changes artifact: 8e6d36f331 user: mdejong
2001-07-13
08:11 • Ticket [440891ffff]: 5 changes artifact: 8c21ec1300 user: dgp
08:05 • Add attachment inline.patch to ticket [440891ffff] artifact: c06790cf65 user: dgp
08:05 • Ticket [440891ffff] Linux inlining defeats compat/*.c status still Open with... artifact: 74bdf244cc user: dgp
01:05 • New ticket [440891ffff]. artifact: fa03955fa8 user: dgp

Linux inlining defeats compat/*.c

Closed / Out of Date440891ffffffffffffffffffffffffffffffffffCreated 25 years agoUpdated 19 years ago
Descriptionplain2001-07-13 01:05:09
I wanted to test compat/strtod.c on Linux 6.2
on my Alpha XL-300:

$ cd unix
$ setenv LIBOBJS strtod.o
$ ./configure
$ make test

but the resulting tclsh didn't use the strtod()
from compat/strtod.c.

The problem was that with optimization level "-O"
the compiler egcs-2.91.66 and the header files from
glibc-devel-2.1.3-21 automatically inlines the
function strtod() so it can't be replaced.

The attached patch fixes the problem.  It detects
the intent to link in routines from compat/* and
in that case adds to EXTRA_CFLAGS the switch
-fno-inline.
dgpplain2001-07-13 08:05:10
File Added - 8370: inline.patch
dgpplain2001-07-13 08:11:02
Logged In: YES 
user_id=80530

assigning to maintainer for review.
mdejongplain2001-07-17 02:51:09
Logged In: YES 
user_id=90858

Does passing the -fno-builtin also work for your
case? The docs seem to indicate that it will.
I would rather use -fno-builtin instead of -fno-inline
since it will only stop inlining of builtin functions.
dgpplain2001-07-17 03:20:58
Logged In: YES 
user_id=80530


No, -fno-builtin doesn't solve the problem.
hobbsplain2001-09-06 05:41:58
Logged In: YES 
user_id=72656

Tk adds -D__NO_STRING_INLINES and -D__NO_MATH_INLINES which 
may be the right fix.
dgpplain2001-09-06 08:57:52
Logged In: YES 
user_id=80530

Tcl also adds -D__NO_STRING_INLINES and -D__NO_MATH_INLINES
(they come from the shared tcl.m4 file) but that has no
effect on the issue in this report.
mdejongplain2001-09-08 12:40:22
Logged In: YES 
user_id=90858

I took a look at the .h files and it does seem
like something funny is going on. Thing is,
passing -fno-builtin does seem to work for me.

% make tclCmdMZ.o CFLAGS="-O"

% nm tclCmdMZ.o | grep strtod
         U __strtod_internal

% make tclCmdMZ.o CFLAGS=""

% nm tclCmdMZ.o | grep strtod
         U strtod

% make tclCmdMZ.o CFLAGS="-fno-builtin"

% nm tclCmdMZ.o | grep strtod
         U strtod

Do you still get a ref to __strtod_internal
when passing -fno-builtin? If not, what do
you get? I am running on an x86 box with
RH 6.2 in case that matters.
dgpplain2001-09-18 23:23:37
Logged In: YES 
user_id=80530

I see exactly the same thing on my Linux system.
However:

$ make tclCmdMZ.o CFLAGS="-O -fno-builtin"
$ nm tclCmdMZ.o | grep strtod
         U __strtod_internal

So, what is the key to success?  Is it adding -fno-builtin,
or is it just removing -O ?
mdejongplain2001-09-18 23:53:49
Logged In: YES 
user_id=90858

Doh! You are quite right. The -fno-builtin flag
should work but it seems to be broken in this case.
I will go ahead and use the -fno-inline flag.
dgpplain2003-11-12 11:49:09
Logged In: YES 
user_id=80530


Just curious how the commits
of Nov. 11, 2003 will impact
on this report?
dgpplain2003-11-12 23:37:00
Logged In: YES 
user_id=80530

looks like the new commits
went into HEAD only.

On the HEAD, when I follow
the steps in this report, I get
in the Makefile:

COMPAT_OBJS     = strtod$U.o

I have no idea what that $U is
for, but it seems to be produced
by the new autoconf-.2.57 generated
configure script.  Anyhow, it does seem
to work, putting strtod.o on the list
of compiled files that get put into libtcl.

As expected, though, due to the inlining,
the compat/strtod() routine is never called.
This report is re-opened for Tcl 8.5a0.
hobbs Ticket [440891ffff]: 1 change [History diff]2003-11-13 01:28:53
hobbsplain2003-11-13 01:28:54
Logged In: YES 
user_id=72656

Feel free to recorrect, but only with checks for that old 
version.  Newer compilers do not have the bug, and it does 
improve speed to allow inlining.
dgpplain2007-09-05 23:21:06
Logged In: YES 
user_id=80530
Originator: YES


This bug was apparently only
for the egcs-2.91.66 compiler,
and the world has moved on.
Log in (anonymous is fine) to add a comment.

Attachments: