Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 236601 - sci-libs/gsl-1.11 (GNU Scientific Libraries): required to "recompile with -fPIC" option when making a shared object
Summary: sci-libs/gsl-1.11 (GNU Scientific Libraries): required to "recompile with -fP...
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: AMD64 Linux
: High normal
Assignee: Gentoo Science Related Packages
URL:
Whiteboard:
Keywords:
: 236602 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-09-03 18:08 UTC by Hamlet
Modified: 2008-09-04 08:13 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hamlet 2008-09-03 18:08:38 UTC
While trying to compile ROOT libraries (from scratch, not by ebuild) while including GSL/CBLAS support, I get the following error:

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

The library /usr/lib64/libgslcblas.a belongs to sci-libs/gsl.
If I use `CFLAGS="-fPIC" LDFLAGS="-fPIC" emerge sci-libs/gsl`, then the compilation of ROOT works just fine.
I suppose that the -fPIC option in amd64 is somehow expected.


Reproducible: Always

Steps to Reproduce:
1. Write a simple library C code:

cat <<EOC > cblastest.c
#include <gsl/gsl_cblas.h>
void* scopy() {	return (void*) cblas_scopy; }
EOC

2. Try to compile it as a shared library:

gcc -shared -lgslcblas -o libcblastest.so cblastest.c

Actual Results:  
/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/../../../../x86_64-pc-linux-gnu/bin/ld: /tmp/ccSTXDfK.o: relocation R_X86_64_32 against `cblas_scopy' can not be used when making a shared object; recompile with -fPIC
/tmp/ccSTXDfK.o: could not read symbols: Bad value
collect2: ld returned 1 exit status


Expected Results:  
Compilation successful and a pointless libcblastest.so created.


# 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
Comment 1 Jeroen Roovers (RETIRED) gentoo-dev 2008-09-03 22:32:20 UTC
*** Bug 236602 has been marked as a duplicate of this bug. ***
Comment 2 Sébastien Fabbro (RETIRED) gentoo-dev 2008-09-04 08:13:38 UTC
(In reply to comment #0)
> While trying to compile ROOT libraries (from scratch, not by ebuild) while
> including GSL/CBLAS support, I get the following error:
[...]
> /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

By default root will link against the static gsl library, which is correctly compiled non-pic. When you configure root from scratch, use --enable-gsl-shared to link with the shared library.
The root in gentoo is quite feature rich and include some patches. I advise to use it (see also the science overlay). If you want to build your own root, I
recommend using EXTRA_ECONF for options not in use flags. Ex:
EXTRA_ECONF="<my extra config options>" emerge root 

 
> 2. Try to compile it as a shared library:
> 
> gcc -shared -lgslcblas -o libcblastest.so cblastest.c

No, use
 gcc -shared -fPIC -lgslcblas -o libcblastest.so cblastest.c

Note: compiling static objects with pic is often a bad idea.