Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
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

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 -rpath /usr/lib foo.lo
rm -fr  .libs/libfoo.a .libs/ .libs/libfoo.lai .libs/ .libs/ .libs/
gcc -shared  .libs/foo.o   -Wl,-soname -Wl, -o .libs/
(cd .libs && rm -f && ln -s
(cd .libs && rm -f && ln -s
ar cru .libs/libfoo.a  foo.o
ranlib .libs/libfoo.a
(cd .libs && rm -f && ln -s ../

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.