I'm working on a shared library, and would like to build it with -fprofile-generate information generated from tests that are built with the library, so I can apply it with -fprofile-use. However, when I build the library with CFLAGS='-O2 -g -fprofile-generate', it fails to link the tests with the library:
gcc -pthread -I/opt/gnome/include/glib-2.0 -I/opt/gnome/lib/glib-2.0/include -Wall -I../flow -O2 -g -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes -Wstrict-prototypes -fprofile-generate -o .libs/benchmark-propagation benchmark-propagation.o ../flow/.libs/libflow.so -L/opt/gnome/lib /opt/gnome/lib/libgobject-2.0.so /opt/gnome/lib/libgthread-2.0.so -lpthread /opt/gnome/lib/libglib-2.0.so /usr/lib/gcc/i586-suse-linux/4.1.0/../../../../i586-suse-linux/bin/ld: .libs/benchmark-propagation: hidden symbol `__gcov_init' in /usr/lib/gcc/i586-suse-linux/4.1.0/libgcov.a(_gcov.o) is referenced by DSO /usr/lib/gcc/i586-suse-linux/4.1.0/../../../../i586-suse-linux/bin/ld: final link failed: Nonrepresentable section on output collect2: ld returned 1 exit status I've tried this with the GCC version 4.1.0 on Fedora Core 4 with the same result. If profiling DSOs is impossible, maybe the documentation for -fprofile-generate should state that. -- Summary: Cannot generate profile information for DSO Product: gcc Version: 4.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: gcov/profile AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: hpj at copyleft dot no GCC build triplet: i686-suse-linux GCC host triplet: i686-suse-linux GCC target triplet: i686-suse-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27545