Bug 160149 - libtool doesn't pass -fprofile-generate to the linker
Summary: libtool doesn't pass -fprofile-generate to the linker
Alias: None
Product: Fedora
Classification: Fedora
Component: libtool
Version: 3
Hardware: All
OS: Linux
Target Milestone: ---
Assignee: Alexandre Oliva
QA Contact:
Depends On:
TreeView+ depends on / blocked
Reported: 2005-06-11 21:03 UTC by David Juran
Modified: 2007-11-30 22:11 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2005-06-23 17:29:17 UTC
Type: ---

Attachments (Terms of Use)

Description David Juran 2005-06-11 21:03:22 UTC
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):

How reproducible:

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 17:27:11 UTC
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.