Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 33336 - Bind-tools need at least -fPIC to compile on 64-bit processors
Summary: Bind-tools need at least -fPIC to compile on 64-bit processors
Status: RESOLVED WORKSFORME
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: Alpha Linux
: High normal (vote)
Assignee: Stewart (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-11-12 14:31 UTC by Nico Baggus
Modified: 2004-01-07 11:05 UTC (History)
1 user (show)

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


Attachments
Emerge info (emerge.info,1.21 KB, text/plain)
2003-11-17 15:56 UTC, Nico Baggus
Details
build w/o -fPIC (build_wo_fpic,33.44 KB, text/plain)
2003-11-17 15:57 UTC, Nico Baggus
Details
bind-9.2.3-bin-tests-db-t_db.c.patch (bind-9.2.3-bin-tests-db-t_db.c.patch,3.82 KB, patch)
2003-11-28 17:01 UTC, Scott Taylor (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nico Baggus 2003-11-12 14:31:37 UTC
please add : 
 
 [ "${ARCH}" = "alpha" ] && append-flags -fPIC 
 
This is probably also needed for hppa & amd64. 

Reproducible: Always
Steps to Reproduce:
1.
2.
3.
Actual Results:  
errors telling: gp relocation .... during linking 

Expected Results:  
just compile & link
Comment 1 Nico Baggus 2003-11-12 14:32:33 UTC
it's bind-tools-9.2.3
Comment 2 Stewart (RETIRED) gentoo-dev 2003-11-16 23:27:32 UTC
Is this neccesary for the operation of BIND-TOOLS on the Alpha platform? If so, isn't it expected that such users would already have the -fPIC flag in their CFLAGS?
Comment 3 Paul Moore 2003-11-17 07:13:19 UTC
Yes, this is required on Alpha; I was having problems with this package and adding '-fPIC' to the compiler flags solved the problem.  As for assuming that users will  have '-fPIC' in their CFLAGS, I personally think that is a dangerous assumption as  I don't and this is the first package that has required me to add it.

I recommend taking the sumbmitter's advice and fixing the ebuild.
Comment 4 Nico Baggus 2003-11-17 12:54:44 UTC
Well, there is a long and a short story...,
In general routines that are in a library need this.
-fPIC makes sure that call's are done through a jump table, or with an indrect load of an address. On 16/32 bit architectures pointers are kept in registers/code etc. On almost all RISK architectures and certainly the 64bit architectures the instructions have no room for full pointers, therefore large offsets should be defined through some base table (refered to by a register) and some offset into the table (from the instruction). 
BTW. PIC stands for Position Independent Code.
The compiler should known beforehand how the code should be generated. 
If programs are small enough direct references DO work, but if sections are from libraries etc. then -fPIC is needed. This is NOT exclusive for alpha, hppa and others probably need it too (Itanium?, amd64?) Many packages have settings for this in the ebuilds. 
Comment 5 Stewart (RETIRED) gentoo-dev 2003-11-17 15:26:30 UTC
Being as I don't have any Alpha hardware; are there any Alpha developers that
can confirm this? I'll be happy to modify the ebuild, I'm just a bit wary of
adding a flag that reportedly (Bug #33337) breaks compilation of the bind-tools.

Anybody having trouble compiling, please attach your emerge output and the result
of emerge info.

Personally, I compiled with "-fPIC" in my CFLAGS on an Athlon XP processor and all
was well; I'll drag my Mac out of mothballs in the next day or so and check its
behaviour as well.
Comment 6 Nico Baggus 2003-11-17 15:56:21 UTC
Created attachment 20882 [details]
Emerge info
Comment 7 Nico Baggus 2003-11-17 15:57:00 UTC
Created attachment 20883 [details]
build w/o -fPIC
Comment 8 Aron Griffis (RETIRED) gentoo-dev 2003-11-18 04:26:56 UTC
Stewart,

It's pretty standard practice on alpha to add -fPIC for alpha when a package
doesn't add it automatically.  I can verify that it breaks for me building on 
alpha right now.

For an example see app-text/gpdf/gpdf-0.111.ebuild

Now that I'm also working on ia64 I've found this is a general problem for 64-bit
architectures, not limited to alpha.  For the moment you should do something like

src_compile() {
    if use alpha || use amd64 || use ia64; then
        append-flags -fPIC
    fi
}

Hopefully we'll come up with something more general soon, at which point
we'll switch over to it.
Comment 9 Stewart (RETIRED) gentoo-dev 2003-11-18 14:00:47 UTC
I've added it to the ebuild; committed to CVS. Test and lemme know. Also, if this has any impact on Bug #33337, let me know as well.
Comment 10 Scott Taylor (RETIRED) gentoo-dev 2003-11-28 17:01:38 UTC
Created attachment 21424 [details, diff]
bind-9.2.3-bin-tests-db-t_db.c.patch

/usr/portage/net-dns/bind/files/... this applies to 9.2.2 and 9.2.3.
Comment 11 Nico Baggus 2004-01-07 11:05:10 UTC
It now works for me.