Bug 28056

Summary: optimization -O2 does string inlining when it shouldn't
Product: [Retired] Red Hat Linux Reporter: nobody+jrlflah
Component: glibcAssignee: Jakub Jelinek <jakub>
Status: CLOSED NOTABUG QA Contact: David Lawrence <dkl>
Severity: low Docs Contact:
Priority: medium    
Version: 7.0CC: fweimer
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
URL: http://divx.euro.ru/
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2001-02-16 22:51:20 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description nobody+jrlflah 2001-02-16 22:51:16 UTC
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
lib/loader
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
6.2.

Comment 1 Jakub Jelinek 2001-02-16 23:22:52 UTC
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 nobody+jrlflah 2001-02-17 03:35:18 UTC
Well, should it have done the inlining in the first place?  According to the
documentation
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.
*shrug*

Comment 3 Jakub Jelinek 2001-02-17 08:55:22 UTC
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
inline.