Gentoo Archives: gentoo-commits

From: "Michael Haubenwallner (haubi)" <haubi@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-alt r1625 - trunk/toolchain-prefix-wrapper/ld
Date: Mon, 21 Apr 2008 09:39:25
Message-Id: E1JnsUc-0005da-3h@stork.gentoo.org
1 Author: haubi
2 Date: 2008-04-21 09:39:21 +0000 (Mon, 21 Apr 2008)
3 New Revision: 1625
4
5 Modified:
6 trunk/toolchain-prefix-wrapper/ld/ldplugin.h
7 trunk/toolchain-prefix-wrapper/ld/ldwrapper.c
8 Log:
9 provide root (without trailing slash), eprefix and triplet for both host and target in LdPluginIn data
10
11 Modified: trunk/toolchain-prefix-wrapper/ld/ldplugin.h
12 ===================================================================
13 --- trunk/toolchain-prefix-wrapper/ld/ldplugin.h 2008-04-21 09:37:29 UTC (rev 1624)
14 +++ trunk/toolchain-prefix-wrapper/ld/ldplugin.h 2008-04-21 09:39:21 UTC (rev 1625)
15 @@ -13,11 +13,24 @@
16
17 typedef int (*LdPluginFct)(LdPluginData*);
18
19 +typedef struct _HostConfig {
20 + String* eprefix;
21 + String* triplet;
22 +} HostConfig;
23 +
24 typedef struct _LdPluginIn {
25 + HostConfig host;
26 + String* root; /* "${ROOT%/}" */
27 + HostConfig target;
28 StringList* argList;
29 StringList* userLibpath;
30 StringList* sysLibpath;
31 StringList* sysRunpath;
32 +
33 + /* cached flags */
34 + int haveRoot:1;
35 + int isCrossTriplet:1;
36 + int isCrossEprefix:1;
37 } LdPluginIn;
38
39 typedef struct _LdPluginOut {
40
41 Modified: trunk/toolchain-prefix-wrapper/ld/ldwrapper.c
42 ===================================================================
43 --- trunk/toolchain-prefix-wrapper/ld/ldwrapper.c 2008-04-21 09:37:29 UTC (rev 1624)
44 +++ trunk/toolchain-prefix-wrapper/ld/ldwrapper.c 2008-04-21 09:39:21 UTC (rev 1625)
45 @@ -41,25 +41,12 @@
46
47 #define dprintf DEBUG() && fprintf
48
49 -typedef struct _HostConfig {
50 - String* eprefix;
51 - String* triplet;
52 -} HostConfig;
53 -
54 typedef struct _LdWrapperData {
55 String* name; /* basename(argv[0]), mainly for diagnostics */
56 struct stat arg0stat; /* stat(argv[0]) */
57
58 String* bin; /* the target binary to be executed (on host) */
59
60 - HostConfig host;
61 -
62 - String* root; /* ROOT the target is (temporary) installed in */
63 - HostConfig target;
64 -
65 - int isCrossTriplet:1;
66 - int isCrossEprefix:1;
67 -
68 StringList* envpath;
69 String* _ctarget_binutilsbin_; /* cached string "/${CTARGET}/binutils-bin/" */
70
71 @@ -85,7 +72,8 @@
72 /* cache the string "/${CTARGET}/binutils-bin/" */
73 char const binutilsbin[] = "/binutils-bin/";
74 data->_ctarget_binutilsbin_ = StringCreateConcat("/", 1
75 - , StringGetBuffer(data->target.triplet), StringGetLength(data->target.triplet)
76 + , StringGetBuffer(data->pluginIn.target.triplet)
77 + , StringGetLength(data->pluginIn.target.triplet)
78 , "/binutils-bin/", strlen("/binutils-bin/")
79 , NULL);
80 if (data->_ctarget_binutilsbin_ == NULL) {
81 @@ -253,7 +241,8 @@
82
83 envfile = TextfileOpenConcatName(ENVD_BASE_BINUTILS, strlen(ENVD_BASE_BINUTILS),
84 "config-", strlen("config-"),
85 - StringGetBuffer(data->target.triplet), StringGetLength(data->target.triplet),
86 + StringGetBuffer(data->pluginIn.target.triplet),
87 + StringGetLength(data->pluginIn.target.triplet),
88 NULL);
89 if (envfile == NULL && errno != ENOENT) {
90 wrapper_exit("%s wrapper: %s\n",
91 @@ -286,11 +275,12 @@
92 * CHOST == CTARGET: PATH=/gentoo/portage/host.eprefix/usr/${CHOST}/binutils-bin/${BVER}
93 * CHOST != CTARGET: PATH=/gentoo/portage/host.eprefix/usr/${CHOST}/${CTARGET}/binutils-bin/${BVER}
94 */
95 - if (data->isCrossTriplet) {
96 + if (data->pluginIn.isCrossTriplet) {
97 bindir = StringCreateConcat(
98 GENTOO_PORTAGE_EPREFIX, strlen(GENTOO_PORTAGE_EPREFIX),
99 "/usr/", strlen("/usr/"),
100 - StringGetBuffer(data->host.triplet), StringGetLength(data->host.triplet),
101 + StringGetBuffer(data->pluginIn.host.triplet),
102 + StringGetLength(data->pluginIn.host.triplet),
103 StringGetBuffer(data->_ctarget_binutilsbin_),
104 StringGetLength(data->_ctarget_binutilsbin_),
105 StringGetBuffer(currentBVER), StringGetLength(currentBVER),
106 @@ -352,7 +342,8 @@
107 execute the real binary in there... */
108 binpath_command = StringCreateConcat(BINUTILS_CONFIG, strlen(BINUTILS_CONFIG),
109 " --get-bin-path ", strlen(" --get-bin-path "),
110 - StringGetBuffer(data->target.triplet), StringGetLength(data->target.triplet),
111 + StringGetBuffer(data->pluginIn.target.triplet),
112 + StringGetLength(data->pluginIn.target.triplet),
113 NULL);
114 if (binpath_command == NULL) {
115 wrapper_exit("%s wrapper: %s\n",
116 @@ -494,16 +485,20 @@
117 {
118 add_libpath(data, data->pluginIn.sysRunpath, AddLibpath,
119 "append target's toolchain-libdir to sys-runpath",
120 - StringGetBuffer(data->target.eprefix), StringGetLength(data->target.eprefix),
121 + StringGetBuffer(data->pluginIn.target.eprefix),
122 + StringGetLength(data->pluginIn.target.eprefix),
123 "/usr/", strlen("/usr/"),
124 - StringGetBuffer(data->target.triplet), StringGetLength(data->target.triplet),
125 + StringGetBuffer(data->pluginIn.target.triplet),
126 + StringGetLength(data->pluginIn.target.triplet),
127 "/lib/gcc", strlen("/lib/gcc"),
128 NULL);
129 add_libpath(data, data->pluginIn.sysRunpath, AddLibpath,
130 "append target's toolchain-libdir to sys-runpath",
131 - StringGetBuffer(data->target.eprefix), StringGetLength(data->target.eprefix),
132 + StringGetBuffer(data->pluginIn.target.eprefix),
133 + StringGetLength(data->pluginIn.target.eprefix),
134 "/usr/", strlen("/usr/"),
135 - StringGetBuffer(data->target.triplet), StringGetLength(data->target.triplet),
136 + StringGetBuffer(data->pluginIn.target.triplet),
137 + StringGetLength(data->pluginIn.target.triplet),
138 "/lib", strlen("/lib"),
139 NULL);
140 }
141 @@ -529,13 +524,16 @@
142 while(l->path != NULL) {
143 if (add_libpath(data, data->pluginIn.sysLibpath, TestAndAddLibpath,
144 "append target's system-libdir to sys-libpath",
145 - StringGetBuffer(data->root), StringGetLength(data->root),
146 - StringGetBuffer(data->target.eprefix), StringGetLength(data->target.eprefix),
147 + StringGetBuffer(data->pluginIn.root),
148 + StringGetLength(data->pluginIn.root),
149 + StringGetBuffer(data->pluginIn.target.eprefix),
150 + StringGetLength(data->pluginIn.target.eprefix),
151 l->path, l->len,
152 NULL)) {
153 add_libpath(data, data->pluginIn.sysRunpath, AddLibpath,
154 "append target's system-libdir to sys-runpath",
155 - StringGetBuffer(data->target.eprefix), StringGetLength(data->target.eprefix),
156 + StringGetBuffer(data->pluginIn.target.eprefix),
157 + StringGetLength(data->pluginIn.target.eprefix),
158 l->path, l->len,
159 NULL);
160 }
161 @@ -549,38 +547,48 @@
162 /* if "${ROOT}${TPREFIX}/usr/${CTARGET}/lib" exists,
163 * 1) add it to sysLibpath
164 */
165 - if (data->isCrossTriplet) {
166 + if (data->pluginIn.isCrossTriplet) {
167 add_libpath(data, data->pluginIn.sysLibpath, AddLibpath,
168 "append host's target-binutils libdir to sys-libpath",
169 - StringGetBuffer(data->host.eprefix), StringGetLength(data->host.eprefix),
170 + StringGetBuffer(data->pluginIn.host.eprefix),
171 + StringGetLength(data->pluginIn.host.eprefix),
172 "/usr/", strlen("/usr/"),
173 - StringGetBuffer(data->host.triplet), StringGetLength(data->host.triplet),
174 + StringGetBuffer(data->pluginIn.host.triplet),
175 + StringGetLength(data->pluginIn.host.triplet),
176 "/", strlen("/"),
177 - StringGetBuffer(data->target.triplet), StringGetLength(data->target.triplet),
178 + StringGetBuffer(data->pluginIn.target.triplet),
179 + StringGetLength(data->pluginIn.target.triplet),
180 "/lib/gcc", strlen("/lib/gcc"),
181 NULL);
182 add_libpath(data, data->pluginIn.sysLibpath, AddLibpath,
183 "append host's target-binutils libdir to sys-libpath",
184 - StringGetBuffer(data->host.eprefix), StringGetLength(data->host.eprefix),
185 + StringGetBuffer(data->pluginIn.host.eprefix),
186 + StringGetLength(data->pluginIn.host.eprefix),
187 "/usr/", strlen("/usr/"),
188 - StringGetBuffer(data->host.triplet), StringGetLength(data->host.triplet),
189 + StringGetBuffer(data->pluginIn.host.triplet),
190 + StringGetLength(data->pluginIn.host.triplet),
191 "/", strlen("/"),
192 - StringGetBuffer(data->target.triplet), StringGetLength(data->target.triplet),
193 + StringGetBuffer(data->pluginIn.target.triplet),
194 + StringGetLength(data->pluginIn.target.triplet),
195 "/lib", strlen("/lib"),
196 NULL);
197 } else {
198 add_libpath(data, data->pluginIn.sysLibpath, AddLibpath,
199 "append host's target-binutils libdir to sys-libpath",
200 - StringGetBuffer(data->host.eprefix), StringGetLength(data->host.eprefix),
201 + StringGetBuffer(data->pluginIn.host.eprefix),
202 + StringGetLength(data->pluginIn.host.eprefix),
203 "/usr/", strlen("/usr/"),
204 - StringGetBuffer(data->target.triplet), StringGetLength(data->target.triplet),
205 + StringGetBuffer(data->pluginIn.target.triplet),
206 + StringGetLength(data->pluginIn.target.triplet),
207 "/lib/gcc", strlen("/lib/gcc"),
208 NULL);
209 add_libpath(data, data->pluginIn.sysLibpath, AddLibpath,
210 "append host's target-binutils libdir to sys-libpath",
211 - StringGetBuffer(data->host.eprefix), StringGetLength(data->host.eprefix),
212 + StringGetBuffer(data->pluginIn.host.eprefix),
213 + StringGetLength(data->pluginIn.host.eprefix),
214 "/usr/", strlen("/usr/"),
215 - StringGetBuffer(data->target.triplet), StringGetLength(data->target.triplet),
216 + StringGetBuffer(data->pluginIn.target.triplet),
217 + StringGetLength(data->pluginIn.target.triplet),
218 "/lib", strlen("/lib"),
219 NULL);
220 }
221 @@ -613,23 +621,25 @@
222 struct libdir const * l = libdirs;
223
224 /* native build only */
225 - if (data->isCrossTriplet) return;
226 + if (data->pluginIn.isCrossTriplet) return;
227 /* not needed when same-prefix without ROOT */
228 - if (! data->isCrossEprefix && StringGetLength(data->root) == 0) return;
229 + if (! data->pluginIn.isCrossEprefix && !data->pluginIn.haveRoot) return;
230
231 while(l->path != NULL) {
232 if (add_libpath(data, data->pluginIn.sysLibpath, TestAndAddLibpath,
233 "append host's system-libdir to sys-libpath",
234 - StringGetBuffer(data->host.eprefix), StringGetLength(data->host.eprefix),
235 + StringGetBuffer(data->pluginIn.host.eprefix),
236 + StringGetLength(data->pluginIn.host.eprefix),
237 l->path, l->len,
238 NULL)
239 - && data->isCrossEprefix
240 - && StringGetLength(data->root) == 0
241 + && data->pluginIn.isCrossEprefix
242 + && ! data->pluginIn.haveRoot
243 ) {
244 /* add to runpath only when cross-prefix without ROOT */
245 add_libpath(data, data->pluginIn.sysRunpath, AddLibpath,
246 "append host's system-libdir to sys-runpath",
247 - StringGetBuffer(data->host.eprefix), StringGetLength(data->host.eprefix),
248 + StringGetBuffer(data->pluginIn.host.eprefix),
249 + StringGetLength(data->pluginIn.host.eprefix),
250 l->path, l->len,
251 NULL);
252 }
253 @@ -760,23 +770,24 @@
254 }
255
256 /* builtins */
257 - data.host.triplet = StringCreateConcat(CHOST, strlen(CHOST), NULL);
258 - if (data.host.triplet == NULL) {
259 + data.pluginIn.host.triplet = StringCreateConcat(CHOST, strlen(CHOST), NULL);
260 + if (data.pluginIn.host.triplet == NULL) {
261 wrapper_exit("%s wrapper: %s\n",
262 StringGetBuffer(data.name), strerror(errno));
263 }
264
265 - data.host.eprefix = StringCreateConcat(
266 + data.pluginIn.host.eprefix = StringCreateConcat(
267 GENTOO_PORTAGE_EPREFIX, strlen(GENTOO_PORTAGE_EPREFIX),
268 NULL);
269 - if (data.host.eprefix == NULL) {
270 + if (data.pluginIn.host.eprefix == NULL) {
271 wrapper_exit("%s wrapper: %s\n",
272 StringGetBuffer(data.name), strerror(errno));
273 }
274
275 if (stat(argv[0], &data.arg0stat) != 0) {
276 tmpString = StringCreateConcat(
277 - StringGetBuffer(data.host.eprefix), StringGetLength(data.host.eprefix),
278 + StringGetBuffer(data.pluginIn.host.eprefix),
279 + StringGetLength(data.pluginIn.host.eprefix),
280 "/usr/bin/", strlen("/usr/bin/"),
281 StringGetBuffer(data.name), StringGetLength(data.name),
282 NULL);
283 @@ -799,21 +810,22 @@
284 }
285 len = strlen(found);
286 while(len > 0 && found[len-1] == '/') len --;
287 - data.root = StringCreateConcat(found, len, NULL);
288 - if (data.root == NULL) {
289 + data.pluginIn.root = StringCreateConcat(found, len, NULL);
290 + if (data.pluginIn.root == NULL) {
291 wrapper_exit("%s wrapper: %s\n",
292 StringGetBuffer(data.name), strerror(errno));
293 }
294 + data.pluginIn.haveRoot = StringGetLength(data.pluginIn.root) > 0 ? 1 : 0;
295
296 found = getenv("EPREFIX");
297 - if (found && !StringIsEqual(data.host.eprefix, 0, found, -1)) {
298 - data.target.eprefix = StringCreateConcat(found, -1, NULL);
299 - data.isCrossEprefix = 1;
300 + if (found && !StringIsEqual(data.pluginIn.host.eprefix, 0, found, -1)) {
301 + data.pluginIn.target.eprefix = StringCreateConcat(found, -1, NULL);
302 + data.pluginIn.isCrossEprefix = 1;
303 } else {
304 - data.target.eprefix = StringDup(data.host.eprefix);
305 - data.isCrossEprefix = 0;
306 + data.pluginIn.target.eprefix = StringDup(data.pluginIn.host.eprefix);
307 + data.pluginIn.isCrossEprefix = 0;
308 }
309 - if (data.target.eprefix == NULL) {
310 + if (data.pluginIn.target.eprefix == NULL) {
311 wrapper_exit("%s wrapper: %s\n",
312 StringGetBuffer(data.name), strerror(errno));
313 }
314 @@ -822,22 +834,24 @@
315 if (found == NULL) {
316 found = CTARGET();
317 }
318 - data.target.triplet = StringCreateConcat(found, -1, NULL);
319 - if (data.target.triplet == NULL) {
320 + data.pluginIn.target.triplet = StringCreateConcat(found, -1, NULL);
321 + if (data.pluginIn.target.triplet == NULL) {
322 wrapper_exit("%s wrapper: %s\n",
323 StringGetBuffer(data.name), strerror(errno));
324 }
325
326 dprintf(stderr, "%s wrapper: chost '%s'\n",
327 - StringGetBuffer(data.name), StringGetBuffer(data.host.triplet));
328 + StringGetBuffer(data.name), StringGetBuffer(data.pluginIn.host.triplet));
329 dprintf(stderr, "%s wrapper: ctarget '%s'\n",
330 - StringGetBuffer(data.name), StringGetBuffer(data.target.triplet));
331 + StringGetBuffer(data.name), StringGetBuffer(data.pluginIn.target.triplet));
332 dprintf(stderr, "%s wrapper: host eprefix '%s'\n",
333 - StringGetBuffer(data.name), StringGetBuffer(data.host.eprefix));
334 + StringGetBuffer(data.name), StringGetBuffer(data.pluginIn.host.eprefix));
335 dprintf(stderr, "%s wrapper: target eprefix '%s'\n",
336 - StringGetBuffer(data.name), StringGetBuffer(data.target.eprefix));
337 + StringGetBuffer(data.name), StringGetBuffer(data.pluginIn.target.eprefix));
338
339 - data.isCrossTriplet = StringIsEqualString(data.host.triplet, data.target.triplet) ? 0 : 1;
340 + data.pluginIn.isCrossTriplet = StringIsEqualString(
341 + data.pluginIn.host.triplet, data.pluginIn.target.triplet
342 + ) ? 0 : 1;
343
344 find_wrapper_binutils(&data);
345
346 @@ -898,7 +912,10 @@
347
348 /* Ok, lets do it one more time ... */
349 if (execv(StringGetBuffer(data.bin), newargv) < 0)
350 - wrapper_exit("Could not run/locate \"%s/%s\" (%s)\n", StringGetBuffer(data.target.triplet), StringGetBuffer(data.name), StringGetBuffer(data.bin));
351 + wrapper_exit("Could not run/locate \"%s/%s\" (%s)\n",
352 + StringGetBuffer(data.pluginIn.target.triplet),
353 + StringGetBuffer(data.name),
354 + StringGetBuffer(data.bin));
355
356 return 0;
357 }
358
359 --
360 gentoo-commits@l.g.o mailing list