Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Compiling with fPIC required
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Unsupported Software
View previous topic :: View next topic  
Author Message
Hamlet
Tux's lil' helper
Tux's lil' helper


Joined: 15 Apr 2005
Posts: 136
Location: Turin (Italy)

PostPosted: Tue Sep 02, 2008 9:24 pm    Post subject: Compiling with fPIC required Reply with quote

Hello!

I am trying to compile a program (specificaly, ROOT, also available in sci-physics/root), and I get this failure:
Code:
g++ -shared -Wl,-soname,libTable.so.5.20 -m64 -march=nocona -O2 -pipe -fPIC -o lib/libTable.so.5.20 misc/table/src/TCernLib.o misc/table/src/TChair.o misc/table/src/TColumnView.o misc/table/src/TDataSet.o misc/table/src/TDataSetIter.o misc/table/src/TDsKey.o misc/table/src/TFileIter.o misc/table/src/TFileSet.o misc/table/src/TGenericTable.o misc/table/src/TIndexTable.o misc/table/src/TObjectSet.o misc/table/src/TPoints3D.o misc/table/src/TPointsArray3D.o misc/table/src/TPolyLineShape.o misc/table/src/TResponseTable.o misc/table/src/TTable.o misc/table/src/TTable3Points.o misc/table/src/TTableDescriptor.o misc/table/src/TTableIter.o misc/table/src/TTableMap.o misc/table/src/TTablePadView3D.o misc/table/src/TTablePoints.o misc/table/src/TTableSorter.o misc/table/src/TVolume.o misc/table/src/TVolumePosition.o misc/table/src/TVolumeView.o misc/table/src/TVolumeViewIter.o misc/table/src/G__Table.o
/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib64/libgslcblas.a(sasum.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/lib64/libgslcblas.a: could not read symbols: Bad value
collect2: ld returned 1 exit status

The incriminated library is from sci-libs/gsl package. I actually tried building it with `CFLAGS="-fPIC" LDFLAGS="-fPIC" emerge gsl` and both gsl and the following ROOT compilation succeeded. Yet portage rightfully complains that I am not supposed to use -fPIC flag.
Which is the Gentoo-friendly solution to this issue? are there risks I am ignoring in using -fPIC?

Thank you!

[a Gentoo-friendly solution is one where one is not supposed to rebuild either gsl or ROOT explicitely when one or the other is updated...]
Back to top
View user's profile Send private message
i92guboj
Bodhisattva
Bodhisattva


Joined: 30 Nov 2004
Posts: 10306
Location: Córdoba (Spain)

PostPosted: Tue Sep 02, 2008 9:28 pm    Post subject: Re: Compiling with fPIC required Reply with quote

Hamlet wrote:
Hello!

I am trying to compile a program (specificaly, ROOT, also available in sci-physics/root), and I get this failure:
Code:
g++ -shared -Wl,-soname,libTable.so.5.20 -m64 -march=nocona -O2 -pipe -fPIC -o lib/libTable.so.5.20 misc/table/src/TCernLib.o misc/table/src/TChair.o misc/table/src/TColumnView.o misc/table/src/TDataSet.o misc/table/src/TDataSetIter.o misc/table/src/TDsKey.o misc/table/src/TFileIter.o misc/table/src/TFileSet.o misc/table/src/TGenericTable.o misc/table/src/TIndexTable.o misc/table/src/TObjectSet.o misc/table/src/TPoints3D.o misc/table/src/TPointsArray3D.o misc/table/src/TPolyLineShape.o misc/table/src/TResponseTable.o misc/table/src/TTable.o misc/table/src/TTable3Points.o misc/table/src/TTableDescriptor.o misc/table/src/TTableIter.o misc/table/src/TTableMap.o misc/table/src/TTablePadView3D.o misc/table/src/TTablePoints.o misc/table/src/TTableSorter.o misc/table/src/TVolume.o misc/table/src/TVolumePosition.o misc/table/src/TVolumeView.o misc/table/src/TVolumeViewIter.o misc/table/src/G__Table.o
/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib64/libgslcblas.a(sasum.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/lib64/libgslcblas.a: could not read symbols: Bad value
collect2: ld returned 1 exit status

The incriminated library is from sci-libs/gsl package. I actually tried building it with `CFLAGS="-fPIC" LDFLAGS="-fPIC" emerge gsl` and both gsl and the following ROOT compilation succeeded. Yet portage rightfully complains that I am not supposed to use -fPIC flag.
Which is the Gentoo-friendly solution to this issue? are there risks I am ignoring in using -fPIC?

Thank you!

[a Gentoo-friendly solution is one where one is not supposed to rebuild either gsl or ROOT explicitely when one or the other is updated...]


Provided that your system and build environment are sane, the friendly solution would be to report the issue in bugs.gentoo.org, so it can be fixed on the ebuild(s) and the user don't have to mess with crazy CFLAGS that they are not supposed to toy with. On a quick search I didn't find any related problem in bugzilla. Still, if you decide to report it, try searching yourself in case that there's a similar bug already reported.
_________________
Gentoo Handbook | My website
Back to top
View user's profile Send private message
Hamlet
Tux's lil' helper
Tux's lil' helper


Joined: 15 Apr 2005
Posts: 136
Location: Turin (Italy)

PostPosted: Tue Sep 02, 2008 9:53 pm    Post subject: Re: Compiling with fPIC required Reply with quote

i92guboj wrote:

Provided that your system and build environment are sane


Thank you for your reply!

I believe my environment sane, but that is a "personal" belief - and my amount of USE flags are more toward insanity anyway...
Code:
# emerge --info
Portage 2.1.4.4 (default/linux/amd64/2008.0, gcc-4.1.2, glibc-2.6.1-r0, 2.6.26-tuxonice x86_64)
=================================================================
System uname: 2.6.26-tuxonice x86_64 Intel(R) Core(TM)2 CPU T5600 @ 1.83GHz
Timestamp of tree: Tue, 02 Sep 2008 20:19:01 +0000
app-shells/bash:     3.2_p33
dev-java/java-config: 1.3.7, 2.1.6-r1
dev-lang/python:     2.4.4-r13, 2.5.2-r6
dev-python/pycrypto: 2.0.1-r6
sys-apps/baselayout: 2.0.0
sys-apps/openrc:     0.2.5
sys-apps/sandbox:    1.2.18.1-r3
sys-devel/autoconf:  2.13, 2.62-r1
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10.1-r1
sys-devel/binutils:  2.18-r3
sys-devel/gcc-config: 1.4.0-r4
sys-devel/libtool:   2.2.4
virtual/os-headers:  2.6.26
ACCEPT_KEYWORDS="amd64 ~amd64"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=nocona -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/share/config /var/lib/hsqldb"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/terminfo /etc/texmf/web2c /etc/udev/rules.d"
CXXFLAGS="-march=nocona -O2 -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="distlocks metadata-transfer sandbox sfperms strict unmerge-orphans userfetch"
GENTOO_MIRRORS="http://mirror.switch.ch/ftp/mirror/gentoo http://distfiles.gentoo.org http://www.ibiblio.org/pub/Linux/distributions/gentoo"
LANG="POSIX"
LDFLAGS="-Wl,-O1"
LINGUAS="en it"
MAKEOPTS="-j3"
PKGDIR="/usr/portage/packages"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage"
USE="X Xaw3d a52 aac aalib acl acpi afs aim alsa amd64 apache2 apm arts audiofile avi bash-completion bcmath berkdb browserplugin bzip2 cairo calendar caps cddb cdparanoia cdr cli cracklib crypt ctype cups curl curlwrappers dbus dga dio divx4linux dlloader doc dri dv dvb dvd dvdr dvdread emacs emacs-w3 emul-linux-x86 encode ethereal examples expat fastcgi fbcon ffmpeg fftw flac flash foomaticdb fortran freetds ftp fuse gb gcj gd gdbm ggi gif gimp ginac glut gpm gstreamer gtk gtk2 gtkhtml hal iconv icq ieee1394 imagemagick imap imlib ipv6 isdnlog java javascript joystick jpeg kde kdeenablefinal kdexdeltas kerberos latex ldap libcaca libwww lm_sensors mad maildir mailwrapper mbox mcal mhash midi mikmod mime ming mmap mmx mng motif mozilla mp3 mpeg mpi mudflap multilib mysql mysqli nas ncurses netboot nis nls nptl nptlonly nsplugin ntplonly offensive ogg oggvorbis openal opengl openmp oscar pam pcntl pcre pdf perl php plotutils png portaudio posix povray ppds pppd python qt qt3 quicktime readline recode reflection ruby sasl scanner screen sdl session sharedext sharedmem shorten simplexml skey slang slp sndfile sockets socks5 sox speex spell spl sse sse2 ssl svg sysfs sysvipc szip tcltk tcpd tetex theora threads tiff timidity tk tokenizer truetype unicode usb v4l v4l2 vhosts videos vorbis wifi wma wmf wmv wxwindows xface xine xinerama xml xml2 xmlrpc xorg xosd xpm xscreensaver xulrunner xv xvid zlib" ALSA_CARDS="hda-intel dummy loopback" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic auth_digest authn_anon authn_dbd authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock dbd deflate dir disk_cache env expires ext_filter file_cache filter headers ident imagemap include info log_config logio mem_cache mime mime_magic negotiation proxy proxy_ajp proxy_balancer proxy_connect proxy_http rewrite setenvif so speling status unique_id userdir usertrack vhost_alias" ELIBC="glibc" INPUT_DEVICES="evdev keyboard mouse synaptics vmmouse" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="en it" USERLAND="GNU" VIDEO_CARDS="apm tga v4l vesa vga vmware i810"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, LC_ALL, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS


What I read from your reply is that this could be a problem for anyone trying to build anything against those static libraries (which could be the reason of an absence of complains before this, since people usually prefer to link against dynamic libraries). I wil more carefully check for bug reports, and maybe add another one.
Back to top
View user's profile Send private message
i92guboj
Bodhisattva
Bodhisattva


Joined: 30 Nov 2004
Posts: 10306
Location: Córdoba (Spain)

PostPosted: Tue Sep 02, 2008 9:59 pm    Post subject: Re: Compiling with fPIC required Reply with quote

Hamlet wrote:
i92guboj wrote:

Provided that your system and build environment are sane


Thank you for your reply!

I believe my environment sane, but that is a "personal" belief - and my amount of USE flags are more toward insanity anyway...


It seems sane enough to me. I was mostly talking about crazy C/LDFLAGS settings. USE flags are there so you can use them. Those that are not supposed to be changed are hardcoded into the profiles.

Quote:
What I read from your reply is that this could be a problem for anyone trying to build anything against those static libraries (which could be the reason of an absence of complains before this, since people usually prefer to link against dynamic libraries). I wil more carefully check for bug reports, and maybe add another one.


fPIC related errors are usually due to problems in the ebuild(s) and/or the upstream packages. They are rare on stable packages though. In any case, I hope that you have some luck in bugzilla.
_________________
Gentoo Handbook | My website
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Unsupported Software All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum