Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Architectures & Platforms Gentoo on AMD64
  • Search

problems on AMD64 requiring -fPIC

Have an x86-64 problem? Post here.
Locked
Advanced search
5 posts • Page 1 of 1
Author
Message
jsamort
n00b
n00b
Posts: 37
Joined: Thu Jun 17, 2004 10:35 pm

problems on AMD64 requiring -fPIC

  • Quote

Post by jsamort » Wed Jul 19, 2006 10:55 pm

Hi All,

I am having a recurring set of problems on my gentoo AMD64 box, getting errors like:
xxx can not be used when making a shared object; recompile with -fPIC
Specifically, I am developing a shared library, and am attempting to link into it several static libraries (i.e. Boost, ANTLR). On an x86 platform, this is not a problem, however, AMD64 requires the static libraries to have been compiled with the -fPIC option. Now, the general libtool default is to build shared libraries from PIC objects and static archives from non-PIC objects, so anyone attempting to do what I am trying to do runs into a non-trivial task of editing a bunch of ebuilds to get various libraries compiled with the necessary -fPIC. This can involve several time-consuming rebuilds. For example, to attempt to build Boost with the -fPIC option causes trouble with gcc (crtbeginT.o to be specific), and would also require rebuilding gcc with -fPIC.

Now, I am not an expert, and I don't know if there is a downside to compiling a static library with -fPIC versus non-PIC objects, and info on the web is fairly limited. I thought I would consult the gentoo AMD64 community and see if any guidelines exist on the subject. Currently, I am stuck with locally building some libraries, or maintaining some modified ebuilds in /usr/local/portage. I am hoping there may be a better/more accepted way to deal with this across the gentoo AMD64 distribution.

Best,
Scott
Top
loftwyr
l33t
l33t
User avatar
Posts: 970
Joined: Wed Dec 29, 2004 2:51 am
Location: 43°38'23.62"N 79°27'8.60"W

  • Quote

Post by loftwyr » Thu Jul 20, 2006 3:02 am

Can you show us your CFLAGS and LDFLAGS and such (emerge --info will do nicely)

You may have flags that are making things difficult for the linker.
My emerge --info
Have you run revdep-rebuild lately? It's in gentoolkit and it's worth a shot if things don't work well.
Celebrating 5 years of Gentoo-ing.
Top
jsamort
n00b
n00b
Posts: 37
Joined: Thu Jun 17, 2004 10:35 pm

  • Quote

Post by jsamort » Thu Jul 20, 2006 3:45 am

You may have flags that are making things difficult for the linker.
No, my CFLAGS are quite conservative:

Code: Select all

CFLAGS="-march=k8 -O2 -pipe -msse3"
This is a (not well) documented design decision on AMD64. You can read a bit about it here:

http://www.x86-64.org/lists/discuss/msg05760.html
http://www.physics.uq.edu.au/people/fos ... rting.html

In essence, if a user of a static library on AMD64 ever wishes to link that library to a shared library (versus an executable), it must be compiled with -fPIC. And since this is not an issue with x86, very few Gentoo static libraries are compiled with that flag. Ultimately, every ebuild for a static library should have a check for AMD64 and insert -fPIC if necessary. Here is a quote from that first link:
I.e. the rule of thumb for suppliers of libraries: If you only provide static libraries they _must_ be compiled with -fPIC, otherwise the users of them can't link them into shared libs on their own.
Best,
Scott
Top
jsamort
n00b
n00b
Posts: 37
Joined: Thu Jun 17, 2004 10:35 pm

  • Quote

Post by jsamort » Thu Jul 20, 2006 4:05 am

As a follow-up, I discovered some Gentoo-specific documentation here:

http://devmanual.gentoo.org/archs/amd64/index.html

However, while it does discuss the issue with position-dependent code, it focuses on shared libraries. It is a bit redundant, as I believe all shared libraries must use -fPIC, regardless of architecture. Instead, this section should be reworked to apply to static libraries, which is where the AMD64-specific problem exists.
Top
friedmud
Apprentice
Apprentice
User avatar
Posts: 258
Joined: Thu Apr 18, 2002 8:49 pm
Location: Austin, TX USA

  • Quote

Post by friedmud » Mon Oct 09, 2006 1:30 am

Has there been any movement on this since?

I am trying to link a python module against mpich (pypar) and am getting these errors.... is there a Gentooish way to implement this change or do I need to go edit the mpich ebuild?

Thanks!
Friedmud
Top
Locked

5 posts • Page 1 of 1

Return to “Gentoo on AMD64”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic