Gentoo Archives: gentoo-dev

From: Aron Griffis <agriffis@g.o>
To: gentoo-dev@g.o, gentoo-core@g.o
Subject: [gentoo-dev] [drobbins@gentoo.org: Re: 64-bit.eclass]
Date: Wed, 10 Dec 2003 19:07:46
Message-Id: 20031211010744.GO9669@time
1 I think it's important all developers see this, so I'm forwarding it to
2 gentoo-core and gentoo-dev... (I'm referring to the text from Daniel,
3 not necessarily the fact that I screwed up ;-)
4
5 ----- Forwarded message from Daniel Robbins <drobbins@g.o> -----
6
7 From: Daniel Robbins <drobbins@g.o>
8 Organization: Gentoo Technologies, Inc.
9 Date: Wed, 10 Dec 2003 18:02:35 -0700
10 To: Aron Griffis <agriffis@g.o>
11 Cc: alpha@g.o, amd64@g.o, ia64@g.o
12 Subject: Re: 64-bit.eclass
13
14 On Wed, 2003-12-10 at 17:03, Aron Griffis wrote:
15 > Hi all,
16 >
17 > I committed 64-bit.eclass today which contains a single function:
18 > 64-bit. The point is to be able to recognize when you're building for a
19 > 64-bit architecture in a way where we can change the implementation as
20 > needed.
21
22 OK, there are a couple of problems with this approach:
23
24 1) Adding -fPIC to the compile flags makes all the code relocatable,
25 which is not the "right" solution for many packages (unless they are
26 pure libraries)
27
28 2) Lack of -fPIC is not a 64-bit issue in the first place, so there's no
29 reason to have a "fix" associated with 64-bit.eclass. The problems tend
30 to pop up on non-x86 systems, but it's really the fault of the Makefiles
31 in these packages. The shipped Makefiles may (barely) work on x86, but
32 they are not valid for non-x86 systems.
33
34 The Makefiles happen to "work" on x86 because x86 supports non-PIC
35 shared libraries, but it can only support them by doing text relocs.
36
37 When a non-PIC shared library is used on x86, the dynamic loader is
38 forced to create a private in-memory copy of the lib for every process
39 using the library (after fixing up addresses in each copy so it can be
40 used.) This means that if a package breaks during compile due to no
41 -fPIC on alpha, ia64 and amd64, it also happens to be wasting a lot of
42 memory on x86 (but nevertheless, the library does "work" on x86, even
43 though it's technically broken.)
44
45 The correct solution is to:
46
47 1) find the specific sources where -fPIC is needed (and this should just
48 be in cases of library code, not executables)
49
50 2) make a patch to the Makefile/configure stuff to add -fPIC to these
51 areas only.
52
53 3) send patch upstream to fix their standard build scripts
54
55 4) Use the patch on *all* architectures, including x86 (to avoid the
56 text-reloc/memory wastage issue on x86)
57
58 Then you have the right solution.
59
60 Then, the problem is really fixed. Virtually all of the -fPIC issues can
61 be tracked down to a bad Makefile. Again, it isn't a 64-bit or
62 arch-specific quirk, but an issue of a broken Makefile, so the solution
63 needs to be focused on fixing the Makefile for all arches.
64
65 Regards,
66
67 Daniel
68
69
70
71 ----- End forwarded message -----
72
73 --
74 Aron Griffis
75 Gentoo Linux Developer (alpha / ia64 / ruby / vim)
76 Key fingerprint = E3B6 8734 C2D6 B5E5 AE76 FB3A 26B1 C5E3 2010 4EB0

Replies

Subject Author
[gentoo-dev] IMPORTANT: append-flags -fPIC Daniel Robbins <drobbins@g.o>