Bug 160149 - libtool doesn't pass -fprofile-generate to the linker
libtool doesn't pass -fprofile-generate to the linker
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: libtool (Show other bugs)
3
All Linux
medium Severity medium
: ---
: ---
Assigned To: Alexandre Oliva
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2005-06-11 17:03 EDT by David Juran
Modified: 2007-11-30 17:11 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2005-06-23 13:29:17 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description David Juran 2005-06-11 17:03:22 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050513 Fedora/1.0.4-1.3.1 Firefox/1.0.4

Description of problem:
When instrumenting a shared library for gathering profile information with the -fprofile-generate flag to gcc, the flag must be given _both_ at compile and link time. However when linking a shared library using libtool, libtool strips away this flag.

my foo.c only contains the lines
void foo() {
}


Version-Release number of selected component (if applicable):
libtool-1.5.6-4.FC3.2

How reproducible:
Always

Steps to Reproduce:
1.[david@trollet profile]$ libtool --mode=compile gcc -c -o foo.lo -fprofile-generate foo.c
 gcc -c -fprofile-generate foo.c  -fPIC -DPIC -o .libs/foo.o
 gcc -c -fprofile-generate foo.c -o foo.o >/dev/null 2>&1


So far, so good

2. [david@trollet profile]$ libtool --mode=link gcc  -fprofile-generate -o libfoo.la -rpath /usr/lib foo.lo
rm -fr  .libs/libfoo.a .libs/libfoo.la .libs/libfoo.lai .libs/libfoo.so .libs/libfoo.so.0 .libs/libfoo.so.0.0.0
gcc -shared  .libs/foo.o   -Wl,-soname -Wl,libfoo.so.0 -o .libs/libfoo.so.0.0.0
(cd .libs && rm -f libfoo.so.0 && ln -s libfoo.so.0.0.0 libfoo.so.0)
(cd .libs && rm -f libfoo.so && ln -s libfoo.so.0.0.0 libfoo.so)
ar cru .libs/libfoo.a  foo.o
ranlib .libs/libfoo.a
creating libfoo.la
(cd .libs && rm -f libfoo.la && ln -s ../libfoo.la libfoo.la)

Here, do note how the line starting with 'gcc -shared' is missing the -fprofile-generate flag which will cause the profiling run to fail.
  

Additional info:
Comment 1 Alexandre Oliva 2005-06-23 13:27:11 EDT
Flags that must be passed to the compiler driver at link time must be prefixed
by -XCClinker, according to the libtool manual.  Bear in mind that libtool isn't
required to use the CC driver to link archives.  In fact, it won't even run a
linker if requested to create a static library, and on some platforms creating a
shared library runs the linker directly.  I'm afraid this is by design.

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