Date: Fri, 26 Sep 2008 14:10:05 GMT From: John Baldwin <jhb@freebsd.org> To: freebsd-amd64@FreeBSD.org Subject: Re: amd64/127640: GCC will not build shared libraries with -fprofile-generate on amd64 Message-ID: <200809261410.m8QEA5YX035451@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR amd64/127640; it has been noted by GNATS. From: John Baldwin <jhb@freebsd.org> To: freebsd-amd64@freebsd.org Cc: Jonathan Briggs <zlynx@acm.org>, freebsd-gnats-submit@freebsd.org Subject: Re: amd64/127640: GCC will not build shared libraries with -fprofile-generate on amd64 Date: Fri, 26 Sep 2008 10:01:43 -0400 On Thursday 25 September 2008 04:50:43 pm Jonathan Briggs wrote: > > >Number: 127640 > >Category: amd64 > >Synopsis: GCC will not build shared libraries with -fprofile-generate on amd64 > >Confidential: no > >Severity: non-critical > >Priority: low > >Responsible: freebsd-amd64 > >State: open > >Quarter: > >Keywords: > >Date-Required: > >Class: sw-bug > >Submitter-Id: current-users > >Arrival-Date: Thu Sep 25 21:00:03 UTC 2008 > >Closed-Date: > >Last-Modified: > >Originator: Jonathan Briggs > >Release: 7.0-RELEASE > >Organization: > >Environment: > FreeBSD freebsd64 7.0-RELEASE FreeBSD 7.0-RELEASE #0: Sun Feb 24 10:35:36 UTC 2008 root@driscoll.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC amd64 > > >Description: > I was porting a specialized database library to FreeBSD and the build failed with this error: > > /usr/bin/ld: /usr/lib/libgcov.a(_gcov_merge_add.o): relocation R_X86_64_32 can not be used when making a shared object; recompile with -fPIC > /usr/lib/libgcov.a: could not read symbols: Bad value > > The library uses -fprofile-generate, runs a test set, then rebuilds with -fprofile-use. It's worth a few ms per lookup. > > Also, this builds very well on i386 FreeBSD 7.0 and on many varieties of Linux and their GCC builds (Debian ia64, Gentoo amd64, CentOS 5.2, Fedora 5, 8, 9). > > I can work around the problem by just not doing a profile build. > >How-To-Repeat: > Put the following in a shell script: > > #!/bin/sh > cat <<EOF | > #include <stdio.h> > > int counter(int count) > { > int i; > > for(i=0; i<count; i++) { > printf("loop %d\n", i); > } > return i; > } > EOF > gcc -O2 -shared -fprofile-generate -fPIC -o t1.so -x c - What if you add -fPIC as the message suggests? -- John Baldwin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200809261410.m8QEA5YX035451>