1 |
Access to this information requires level 4 clearance! |
2 |
|
3 |
|
4 |
|
5 |
Nah, just kidding, but with the information in this mail you could |
6 |
seriously break your system, use it carefully. |
7 |
|
8 |
|
9 |
There's very little documentation about how multilib works (in general |
10 |
and in Gentoo), most of it you'll find in mailing list archives. |
11 |
|
12 |
You understood the basics correctly, for multilib a library must be |
13 |
compiled twice, once in 32 bit(with -m32 cflag) and once in 64 bit(with |
14 |
- -m64 cflag). |
15 |
|
16 |
However glibc is a bad example since it's not a "normal" library. To get |
17 |
glibc to compile for a specific bitness you have to pass different |
18 |
configure-hosts. |
19 |
|
20 |
2.8 has these configure-hosts: |
21 |
|
22 |
UltraSPARC CPus: |
23 |
sparcv9-*-linux-gnu: 32 bit |
24 |
sparc64-*-linux-gnu: 64 bit |
25 |
UltraSPARC III CPUs: |
26 |
sparcv9b-*-linux-gnu: 32 bit |
27 |
sparc64b-*-linux-gnu: 64 bit |
28 |
UltraSPARC T1 CPUs: |
29 |
sparcv9v-*-linux-gnu: 32bit |
30 |
sparc64v-*-linux-gnu: 64bit |
31 |
UltraSPARC T2 CPUs: |
32 |
sparcv9v2-*-linux-gnu: 32bit |
33 |
sparc64v2-*-linux-gnu: 64bit |
34 |
|
35 |
The glibc ebuild determines which to use according to your -mcpu cflag. |
36 |
|
37 |
For instance if you have "-mcpu=ultrasparc" a non multilib glibc would |
38 |
be compiled like this: |
39 |
|
40 |
configure --host=sparcv9-unknown-linux-gnu |
41 |
make |
42 |
make install |
43 |
|
44 |
And a multilib one would be compiled like this: |
45 |
|
46 |
configure --host=sparcv9-unknown-linux-gnu |
47 |
make |
48 |
make install |
49 |
configure --host=sparc64-unknown-linux-gnu |
50 |
make |
51 |
make install |
52 |
|
53 |
|
54 |
A "normal" library doesn't really care about bitness, it just trusts the |
55 |
compiler to do it's job right. |
56 |
|
57 |
So a non multilib ncurses would be compiled like this |
58 |
|
59 |
export CFLAGS="${CFLAGS} -m32" |
60 |
configure |
61 |
make |
62 |
make install |
63 |
|
64 |
and a multilib one like this: |
65 |
|
66 |
export CFLAGS="${CFLAGS} -m32" |
67 |
configure |
68 |
make |
69 |
make install |
70 |
export CFLAGS="${CFLAGS} -m64" |
71 |
configure |
72 |
make |
73 |
make install |
74 |
|
75 |
|
76 |
Ok so much about general multilib stuff, now how Gentoo does it: |
77 |
|
78 |
The examples above only work if the library's Makefile respects the |
79 |
user's cflags. Sadly, not all Makefiles do that. |
80 |
|
81 |
Therefore Gentoo's gcc contains a hack to allow one to pass cflags which |
82 |
are _always_ respected, no matted how messed up the Makefile is. |
83 |
|
84 |
If you excute |
85 |
|
86 |
gcc foo.c |
87 |
|
88 |
it really is |
89 |
|
90 |
`eval echo gcc \$CFLAGS_$ABI foo.c` |
91 |
|
92 |
for instance |
93 |
|
94 |
export ABI="sparc64" |
95 |
export CFLAGS_sparc64="-m64" |
96 |
gcc foo.c |
97 |
|
98 |
will have the same effect as |
99 |
|
100 |
gcc -m64 foo.c |
101 |
|
102 |
|
103 |
These variables are set in your profile, if you execute emerge --info |
104 |
- --verbose you'll see: |
105 |
|
106 |
CFLAGS_sparc32="" # -m32 it the default, no need to set it |
107 |
CFLAGS_sparc64="-m64" |
108 |
ABI="sparc32" |
109 |
|
110 |
You may also have noted these variables which are also set in the profile: |
111 |
|
112 |
DEFAULT_ABI="sparc32" |
113 |
KERNEL_ABI="sparc64" |
114 |
MULTILIB_ABIS="sparc32 sparc64" # non multilib profiles have "sparc32" |
115 |
|
116 |
As you can guess a multilib enabled ebuild would need to do: |
117 |
|
118 |
for ABI in ${MULTILIB_ABIS}; do |
119 |
compile_and_install |
120 |
done |
121 |
|
122 |
But that means the ebuild would have to be rewritten to do that, only |
123 |
very few ebuils are written like that. |
124 |
|
125 |
There's also bug #145737 [0] to add native support for this to portage |
126 |
directly and eluminate the need to rewrite the ebuilds but it's far from |
127 |
beeing implemented ;) |
128 |
|
129 |
Back to topic: That means if you want a 64 bit mysql you have 2 options: |
130 |
|
131 |
- - rewrite the mysql ebuild and all ebuilds it depends on |
132 |
|
133 |
Don't do it. It's way to much work and it would never get into the tree. |
134 |
|
135 |
- - use what you learned above and portage's ROOT support to make portage |
136 |
create a /opt/mysql64 dir containing a 64 bit mysql and the 64 bit libraries |
137 |
|
138 |
With the ROOT environment variable you can tell portage to use a ROOT |
139 |
other than /, in this case something like /opt/mysql64. Sort of a |
140 |
second, smaller Gentoo installation. |
141 |
(This is similar to what the Gentoo Prefix project [1] does) |
142 |
|
143 |
export ROOT="/opt/mysql64" |
144 |
|
145 |
Use the ABI environment variable to use the sparc64 ABI. |
146 |
|
147 |
export DEFAULT_ABI="sparc64" |
148 |
export ABI="${DEFAULT_ABI}" |
149 |
|
150 |
And merge mysql: |
151 |
|
152 |
emerge mysql |
153 |
|
154 |
Which will fail because gcc won't find the required 64 bit libraries. |
155 |
|
156 |
You need to tell gcc(and glibc's loader) to also search in |
157 |
/opt/mysql64/lib64 and /opt/mysql64/usr/lib64 for libraries and |
158 |
/opt/mysql64/usr/include for headers, like this: |
159 |
|
160 |
CFLAGS_sparc64="-m64" # keep this |
161 |
CFLAGS_sparc64="${CFLAGS_sparc64} -L/opt/mysql64/lib64" |
162 |
CFLAGS_sparc64="${CFLAGS_sparc64} -L/opt/mysql64/usr/lib64" |
163 |
CFLAGS_sparc64="${CFLAGS_sparc64} -Wl,-rpath=/opt/mysql64/lib64" |
164 |
CFLAGS_sparc64="${CFLAGS_sparc64} -Wl,-rpath=/opt/mysql64/usr/lib64" |
165 |
CFLAGS_sparc64="${CFLAGS_sparc64} -I/opt/mysql64/usr/include" |
166 |
export CFLAGS_sparc64 |
167 |
|
168 |
|
169 |
So much for now. |
170 |
|
171 |
Please note that I didn't really test this, it may not even compile, let |
172 |
alone run. |
173 |
But considering that MySQL works on Linux/SPARC(32 bit) and Linux/AMD64 |
174 |
and Solaris/SPARC(32 and 64 bit) chances are quite good. |
175 |
|
176 |
Just keep in mind that your are probably the only one using a |
177 |
configuration like this so when you hit a bug you may find that nobody |
178 |
is able (or willing) to help you. |
179 |
|
180 |
|
181 |
Ps: Is there a reason you compiled socat in 64 bit? Or just for |
182 |
testing/learning purpose? Afaik the only packages we have in the tree |
183 |
which could benefit from beeing compile in 64 bit are mysql and postgresql. |
184 |
|
185 |
Cheers, |
186 |
Friedrich |
187 |
|
188 |
[0] http://bugs.gentoo.org/show_bug.cgi?id=145737 |
189 |
[1] http://www.gentoo.org/proj/en/gentoo-alt/prefix/ |
190 |
|
191 |
Gustavo Panizzo <gfa> schrieb: |
192 |
> Hi all |
193 |
> i'm using multilib profile (default/linux/sparc/experimental/multilib) |
194 |
> |
195 |
> when i compile something simple, like socat, i'm able to have it on 32 or 64 bit |
196 |
> but i don't found a way to have libraries on 32 AND 64 bit (lib32 and lib64) |
197 |
> |
198 |
> for example |
199 |
> if i want a 64bit mysql, i need a 64bit ncurses, and so on |
200 |
> |
201 |
> if i add -m64 to CFLAGS, portage will refuse to install it to lib32 due to multilib-strict FEATURE (which i think is correct) |
202 |
> |
203 |
> anybody has any workaround for this? i took a look to glibc ebuild, but it wasn't much help |
204 |
> |
205 |
> |
206 |
> thanks |
207 |
> |
208 |
> |