Gentoo Archives: gentoo-sparc

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