From owner-freebsd-amd64@FreeBSD.ORG Fri Sep 26 14:14:42 2008 Return-Path: Delivered-To: freebsd-amd64@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 75BFD1065690; Fri, 26 Sep 2008 14:14:42 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.terabit.net.ua (mail.terabit.net.ua [195.137.202.147]) by mx1.freebsd.org (Postfix) with ESMTP id 18B9C8FC26; Fri, 26 Sep 2008 14:14:42 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from skuns.zoral.com.ua ([91.193.166.194] helo=mail.zoral.com.ua) by mail.terabit.net.ua with esmtp (Exim 4.63 (FreeBSD)) (envelope-from ) id 1KjE5g-000BZS-0g; Fri, 26 Sep 2008 17:14:40 +0300 Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id m8QEEUqT069607 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 26 Sep 2008 17:14:30 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.2/8.14.2) with ESMTP id m8QEETxQ032504; Fri, 26 Sep 2008 17:14:29 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.3/8.14.3/Submit) id m8QEET70032503; Fri, 26 Sep 2008 17:14:29 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Fri, 26 Sep 2008 17:14:29 +0300 From: Kostik Belousov To: John Baldwin Message-ID: <20080926141429.GW47828@deviant.kiev.zoral.com.ua> References: <200809252050.m8PKohFr095842@www.freebsd.org> <200809261001.44340.jhb@freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="2Stxnv0JS2q2nyCF" Content-Disposition: inline In-Reply-To: <200809261001.44340.jhb@freebsd.org> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: ClamAV version 0.93.3, clamav-milter version 0.93.3 on skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua X-Virus-Scanned: mail.terabit.net.ua 1KjE5g-000BZS-0g 053a08fa4b52a47bac4cf19a31631199 X-Terabit: YES Cc: Jonathan Briggs , freebsd-amd64@freebsd.org Subject: Re: amd64/127640: GCC will not build shared libraries with -fprofile-generate on amd64 X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Sep 2008 14:14:42 -0000 --2Stxnv0JS2q2nyCF Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Sep 26, 2008 at 10:01:43AM -0400, John Baldwin wrote: > On Thursday 25 September 2008 04:50:43 pm Jonathan Briggs wrote: > >=20 > > >Number: 127640 > > >Category: amd64 > > >Synopsis: GCC will not build shared libraries with -fprofile-gen= erate=20 > on amd64 > > >Confidential: no > > >Severity: non-critical > > >Priority: low > > >Responsible: freebsd-amd64 > > >State: open > > >Quarter: =20 > > >Keywords: =20 > > >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=20 > UTC 2008 root@driscoll.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC = =20 > amd64 > >=20 > > >Description: > > I was porting a specialized database library to FreeBSD and the build f= ailed=20 > with this error: > >=20 > > /usr/bin/ld: /usr/lib/libgcov.a(_gcov_merge_add.o): relocation R_X86_64= _32=20 > can not be used when making a shared object; recompile with -fPIC > > /usr/lib/libgcov.a: could not read symbols: Bad value > >=20 > > The library uses -fprofile-generate, runs a test set, then rebuilds=20 > with -fprofile-use. It's worth a few ms per lookup. > >=20 > > Also, this builds very well on i386 FreeBSD 7.0 and on many varieties o= f=20 > Linux and their GCC builds (Debian ia64, Gentoo amd64, CentOS 5.2, Fedora= 5,=20 > 8, 9). > >=20 > > I can work around the problem by just not doing a profile build. > > >How-To-Repeat: > > Put the following in a shell script: > >=20 > > #!/bin/sh > > cat < > #include > >=20 > > int counter(int count) > > { > > int i; > >=20 > > for(i=3D0; i > printf("loop %d\n", i); > > } > > return i; > > } > > EOF > > gcc -O2 -shared -fprofile-generate -fPIC -o t1.so -x c - >=20 > What if you add -fPIC as the message suggests? Note that libgcov needs to be recompiled with -fPIC. The R_X86_64_32 issue is systematic on amd64. When you build a shared object, better make sure that all .o are compiled with -fPIC. --2Stxnv0JS2q2nyCF Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEARECAAYFAkjc7kUACgkQC3+MBN1Mb4hyxQCgtU49iN4tL4qrrbyWJglCIGWW olsAoKjx60c0jcOcRmf5lsPUuyDy+JjV =PdcL -----END PGP SIGNATURE----- --2Stxnv0JS2q2nyCF--