Bug 28056 - optimization -O2 does string inlining when it shouldn't
optimization -O2 does string inlining when it shouldn't
Product: Red Hat Linux
Classification: Retired
Component: glibc (Show other bugs)
i386 Linux
medium Severity low
: ---
: ---
Assigned To: Jakub Jelinek
David Lawrence
Depends On:
  Show dependency treegraph
Reported: 2001-02-16 17:51 EST by jrlflah
Modified: 2007-04-18 12:31 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2001-02-16 17:51:20 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description jrlflah 2001-02-16 17:51:16 EST
From Bugzilla Helper:
User-Agent: Mozilla/4.76 [en] (X11; U; Linux 2.4.2ac9-low-latency i686)

in avifile-0.53.5/lib/loader ... 

[jrl@cma-d0448 loader]$ make

/bin/sh ../../libtool --silent --mode=compile gcc -DHAVE_CONFIG_H -I. -I.
-I../../include   -g -O2 -march=i586  -I/usr/X11R6/include
-I/usr/include/SDL -D_REENTRANT -w  -I../../include
-DWIN32_PATH=\"/usr/lib/win32\" -D__WINE__ -Ddbg_printf=__vprintf
-DTRACE=__vprintf -fno-omit-frame-pointer -fno-inline -c win32.c

/bin/sh ../../libtool --silent --mode=compile gcc -DHAVE_CONFIG_H -I. -I.
-I../../include   -g -O2 -march=i586  -I/usr/X11R6/include
-I/usr/include/SDL -D_REENTRANT -w  -I../../include
-DWIN32_PATH=\"/usr/lib/win32\" -D__WINE__ -Ddbg_printf=__vprintf
-DTRACE=__vprintf -fno-omit-frame-pointer -fno-inline -c registry.c

[jrl@cma-d0448 loader]$ grep "strcpy_small" *
grep: CVS: Is a directory
Binary file registry.lo matches
Binary file win32.lo matches
[jrl@cma-d0448 loader]$

in avifile-0.53.5/player

/bin/sh ../libtool --silent --mode=link c++  -I../include
-I/usr/X11R6/include -I/usr/lib/qt-2.2.3/include -I/usr/include/SDL
-D_REENTRANT     -DSHARE_PATH=\"/usr/local/share/avifile\"
-DWIN32_PATH=\"/usr/lib/win32\" -march=i586 -lpthread -ldl 
-L/usr/X11R6/lib -lX11 -lXext -L/usr/lib/qt-2.2.3/lib  -lqt-mt -L/usr/lib
-Wl,-rpath,/usr/lib -lSDL -lpthread -o aviplay  main.o renderer.o
mywidget_if.o MyConfig.o MyConfigImpl.o mywidget.o decoder_config.o 	mmx.o
../lib/libaviplay.la -lXxf86vm -lXxf86dga  -lpthread -ldl 
../lib/.libs/libaviplay.so: undefined reference to `__strcpy_small'
collect2: ld returned 1 exit status

Adding -D__NO_STRING_INLINES to our CFLAGS option in the Makefile of
solves this problem.

Reproducible: Always
Steps to Reproduce:
1. ./configure --enable-release --enable-quiet
2. make


Actual Results:  undefined reference to __strcpy_small

Expected Results:  It shouldn't have inlined the string function and
therefore, should've compiled normally.

Bug consistantly occurs with gcc in rawhide, redhat 7.0, and egcs in redhat
Comment 1 Jakub Jelinek 2001-02-16 18:22:52 EST
There is now way how can glibc know you have passed -fno-builtin
unless you tell it (via -D__NO_STRING_INLINES). gcc only defined
__OPTIMIZE__ macro if -O1 or higher is present. I don't think it
is a good idea if gcc defines a macro for each option passed to it,
it would be quite a mess (because it would have to take account
default switch values and also would be changing all the time with
new options being added and old removed).
Comment 2 jrlflah 2001-02-16 22:35:18 EST
Well, should it have done the inlining in the first place?  According to the
stated in both man/info pages, [it] "does not perform loop unrolling or function
inlining when you specify '-O2'".... in the case of O3, does it say to turn on
the inline functions...

In any case, what you said earlier is the workaround I came up with anyways.
Comment 3 Jakub Jelinek 2001-02-17 03:55:22 EST
Yes, it should. At -O1 and above glibc attempts to inline functions
which are marked as inline (and __strcpy_small is marked as such),
at -O3 and above gcc attempts to inline even functions not marked as

Note You need to log in before you can comment on or make changes to this bug.