Print this page
11461 should use a native link-editor during the build
11463 SUNWonld has passed its use-by date
11464 cmd/sgs/tools should contain tools, not common code
11465 sgsmsg should be built with the rest of the build tools
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/tools/cw/cw.c
+++ new/usr/src/tools/cw/cw.c
1 1
2 2 /*
3 3 * CDDL HEADER START
4 4 *
5 5 * The contents of this file are subject to the terms of the
6 6 * Common Development and Distribution License (the "License").
7 7 * You may not use this file except in compliance with the License.
8 8 *
9 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 * or http://www.opensolaris.org/os/licensing.
11 11 * See the License for the specific language governing permissions
12 12 * and limitations under the License.
13 13 *
14 14 * When distributing Covered Code, include this CDDL HEADER in each
15 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 * If applicable, add the following below this CDDL HEADER, with the
17 17 * fields enclosed by brackets "[]" replaced with your own identifying
18 18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 19 *
20 20 * CDDL HEADER END
21 21 */
22 22
23 23 /*
24 24 * Copyright 2018, Richard Lowe.
25 25 */
26 26 /*
27 27 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
28 28 * Use is subject to license terms.
29 29 *
30 30 * Copyright 2019 Joyent, Inc.
31 31 */
32 32
33 33 /*
34 34 * Wrapper for the GNU C compiler to make it accept the Sun C compiler
35 35 * arguments where possible.
36 36 *
37 37 * Since the translation is inexact, this is something of a work-in-progress.
38 38 *
39 39 */
40 40
41 41 /* If you modify this file, you must increment CW_VERSION */
42 42 #define CW_VERSION "4.0"
43 43
44 44 /*
45 45 * -# Verbose mode
46 46 * -### Show compiler commands built by driver, no compilation
47 47 * -A<name[(tokens)]> Preprocessor predicate assertion
48 48 * -B<[static|dynamic]> Specify dynamic or static binding
49 49 * -C Prevent preprocessor from removing comments
50 50 * -c Compile only - produce .o files, suppress linking
51 51 * -cg92 Alias for -xtarget=ss1000
52 52 * -D<name[=token]> Associate name with token as if by #define
53 53 * -d[y|n] dynamic [-dy] or static [-dn] option to linker
54 54 * -E Compile source through preprocessor only, output to stdout
55 55 * -erroff=<t> Suppress warnings specified by tags t(%none, %all, <tag list>)
56 56 * -errtags=<a> Display messages with tags a(no, yes)
57 57 * -errwarn=<t> Treats warnings specified by tags t(%none, %all, <tag list>)
58 58 * as errors
59 59 * -fast Optimize using a selection of options
60 60 * -fd Report old-style function definitions and declarations
61 61 * -fnonstd Initialize floating-point hardware to non-standard preferences
62 62 * -fns[=<yes|no>] Select non-standard floating point mode
63 63 * -fprecision=<p> Set FP rounding precision mode p(single, double, extended)
64 64 * -fround=<r> Select the IEEE rounding mode in effect at startup
65 65 * -fsimple[=<n>] Select floating-point optimization preferences <n>
66 66 * -fsingle Use single-precision arithmetic (-Xt and -Xs modes only)
67 67 * -ftrap=<t> Select floating-point trapping mode in effect at startup
68 68 * -fstore force floating pt. values to target precision on assignment
69 69 * -G Build a dynamic shared library
70 70 * -g Compile for debugging
71 71 * -H Print path name of each file included during compilation
72 72 * -h <name> Assign <name> to generated dynamic shared library
73 73 * -I<dir> Add <dir> to preprocessor #include file search path
74 74 * -i Passed to linker to ignore any LD_LIBRARY_PATH setting
75 75 * -keeptmp Keep temporary files created during compilation
76 76 * -L<dir> Pass to linker to add <dir> to the library search path
77 77 * -l<name> Link with library lib<name>.a or lib<name>.so
78 78 * -mc Remove duplicate strings from .comment section of output files
79 79 * -mr Remove all strings from .comment section of output files
80 80 * -mr,"string" Remove all strings and append "string" to .comment section
81 81 * -mt Specify options needed when compiling multi-threaded code
82 82 * -native Find available processor, generate code accordingly
83 83 * -nofstore Do not force floating pt. values to target precision
84 84 * on assignment
85 85 * -norunpath Do not build in a runtime path for shared libraries
86 86 * -O Use default optimization level (-xO2 or -xO3. Check man page.)
87 87 * -o <outputfile> Set name of output file to <outputfile>
88 88 * -P Compile source through preprocessor only, output to .i file
89 89 * -p Compile for profiling with prof
90 90 * -Q[y|n] Emit/don't emit identification info to output file
91 91 * -R<dir[:dir]> Build runtime search path list into executable
92 92 * -S Compile and only generate assembly code (.s)
93 93 * -s Strip symbol table from the executable file
94 94 * -t Turn off duplicate symbol warnings when linking
95 95 * -U<name> Delete initial definition of preprocessor symbol <name>
96 96 * -V Report version number of each compilation phase
97 97 * -v Do stricter semantic checking
98 98 * -W<c>,<arg> Pass <arg> to specified component <c> (a,l,m,p,0,2,h,i,u)
99 99 * -w Suppress compiler warning messages
100 100 * -Xa Compile assuming ANSI C conformance, allow K & R extensions
101 101 * (default mode)
102 102 * -Xs Compile assuming (pre-ANSI) K & R C style code
103 103 * -Xt Compile assuming K & R conformance, allow ANSI C
104 104 * -xarch=<a> Specify target architecture instruction set
105 105 * -xbuiltin[=<b>] When profitable inline, or substitute intrinisic functions
106 106 * for system functions, b={%all,%none}
107 107 * -xCC Accept C++ style comments
108 108 * -xchip=<c> Specify the target processor for use by the optimizer
109 109 * -xcode=<c> Generate different code for forming addresses
110 110 * -xcrossfile[=<n>] Enable optimization and inlining across source files,
111 111 * n={0|1}
112 112 * -xe Perform only syntax/semantic checking, no code generation
113 113 * -xF Compile for later mapfile reordering or unused section
114 114 * elimination
115 115 * -xhelp=<f> Display on-line help information f(flags, readme, errors)
116 116 * -xildoff Cancel -xildon
117 117 * -xildon Enable use of the incremental linker, ild
118 118 * -xinline=[<a>,...,<a>] Attempt inlining of specified user routines,
119 119 * <a>={%auto,func,no%func}
120 120 * -xlibmieee Force IEEE 754 return values for math routines in
121 121 * exceptional cases
122 122 * -xlibmil Inline selected libm math routines for optimization
123 123 * -xlic_lib=sunperf Link in the Sun supplied performance libraries
124 124 * -xlicinfo Show license server information
125 125 * -xmaxopt=[off,1,2,3,4,5] maximum optimization level allowed on #pragma opt
126 126 * -xO<n> Generate optimized code (n={1|2|3|4|5})
127 127 * -xP Print prototypes for function definitions
128 128 * -xprofile=<p> Collect data for a profile or use a profile to optimize
129 129 * <p>={{collect,use}[:<path>],tcov}
130 130 * -xregs=<r> Control register allocation
131 131 * -xs Allow debugging without object (.o) files
132 132 * -xsb Compile for use with the WorkShop source browser
133 133 * -xsbfast Generate only WorkShop source browser info, no compilation
134 134 * -xsfpconst Represent unsuffixed floating point constants as single
135 135 * precision
136 136 * -xspace Do not do optimizations that increase code size
137 137 * -xstrconst Place string literals into read-only data segment
138 138 * -xtarget=<t> Specify target system for optimization
139 139 * -xtemp=<dir> Set directory for temporary files to <dir>
140 140 * -xtime Report the execution time for each compilation phase
141 141 * -xunroll=n Enable unrolling loops n times where possible
142 142 * -Y<c>,<dir> Specify <dir> for location of component <c> (a,l,m,p,0,h,i,u)
143 143 * -YA,<dir> Change default directory searched for components
144 144 * -YI,<dir> Change default directory searched for include files
145 145 * -YP,<dir> Change default directory for finding libraries files
146 146 * -YS,<dir> Change default directory for startup object files
147 147 */
148 148
149 149 /*
150 150 * Translation table:
151 151 */
152 152 /*
153 153 * -# -v
154 154 * -### error
155 155 * -A<name[(tokens)]> pass-thru
156 156 * -B<[static|dynamic]> pass-thru (syntax error for anything else)
157 157 * -C pass-thru
158 158 * -c pass-thru
159 159 * -cg92 -m32 -mcpu=v8 -mtune=supersparc (SPARC only)
160 160 * -D<name[=token]> pass-thru
161 161 * -dy or -dn -Wl,-dy or -Wl,-dn
162 162 * -E pass-thru
163 163 * -erroff=E_EMPTY_TRANSLATION_UNIT ignore
164 164 * -errtags=%all -Wall
165 165 * -errwarn=%all -Werror else -Wno-error
166 166 * -fast error
167 167 * -fd error
168 168 * -fnonstd error
169 169 * -fns[=<yes|no>] error
170 170 * -fprecision=<p> error
171 171 * -fround=<r> error
172 172 * -fsimple[=<n>] error
173 173 * -fsingle[=<n>] error
174 174 * -ftrap=<t> error
175 175 * -fstore error
176 176 * -G pass-thru
177 177 * -g pass-thru
178 178 * -H pass-thru
179 179 * -h <name> pass-thru
180 180 * -I<dir> pass-thru
181 181 * -i pass-thru
182 182 * -keeptmp -save-temps
183 183 * -L<dir> pass-thru
184 184 * -l<name> pass-thru
185 185 * -mc error
186 186 * -mr error
187 187 * -mr,"string" error
188 188 * -mt -D_REENTRANT
189 189 * -native error
190 190 * -nofstore error
191 191 * -nolib -nodefaultlibs
192 192 * -norunpath ignore
193 193 * -O -O1 (Check the man page to be certain)
194 194 * -o <outputfile> pass-thru
195 195 * -P -E -o filename.i (or error)
196 196 * -p pass-thru
197 197 * -Q[y|n] error
198 198 * -R<dir[:dir]> pass-thru
199 199 * -S pass-thru
200 200 * -s -Wl,-s
201 201 * -t -Wl,-t
202 202 * -U<name> pass-thru
203 203 * -V --version
204 204 * -v -Wall
205 205 * -Wa,<arg> pass-thru
206 206 * -Wp,<arg> pass-thru except -xc99=<a>
207 207 * -Wl,<arg> pass-thru
208 208 * -W{m,0,2,h,i,u> error/ignore
209 209 * -xmodel=kernel -ffreestanding -mcmodel=kernel -mno-red-zone
210 210 * -Wu,-save_args -msave-args
211 211 * -w pass-thru
212 212 * -Xa -std=iso9899:199409 or -ansi
213 213 * -Xt error
214 214 * -Xs -traditional -std=c89
215 215 * -xarch=<a> table
216 216 * -xbuiltin[=<b>] -fbuiltin (-fno-builtin otherwise)
217 217 * -xCC ignore
218 218 * -xchip=<c> table
219 219 * -xcode=<c> table
220 220 * -xcrossfile[=<n>] ignore
221 221 * -xe error
222 222 * -xF error
223 223 * -xhelp=<f> error
224 224 * -xildoff ignore
225 225 * -xildon ignore
226 226 * -xinline ignore
227 227 * -xlibmieee error
228 228 * -xlibmil error
229 229 * -xlic_lib=sunperf error
230 230 * -xmaxopt=[...] error
231 231 * -xO<n> -O<n>
232 232 * -xP error
233 233 * -xprofile=<p> error
234 234 * -xregs=<r> table
235 235 * -xs error
236 236 * -xsb error
237 237 * -xsbfast error
238 238 * -xsfpconst error
239 239 * -xspace ignore (-not -Os)
240 240 * -xstrconst ignore
241 241 * -xtarget=<t> table
242 242 * -xtemp=<dir> error
243 243 * -xtime error
244 244 * -xtransition -Wtransition
245 245 * -xunroll=n error
246 246 * -W0,-xdbggen=no%usedonly -fno-eliminate-unused-debug-symbols
247 247 * -fno-eliminate-unused-debug-types
248 248 * -Y<c>,<dir> error
249 249 * -YA,<dir> error
250 250 * -YI,<dir> -nostdinc -I<dir>
251 251 * -YP,<dir> error
252 252 * -YS,<dir> error
253 253 */
254 254
255 255 #include <ctype.h>
256 256 #include <err.h>
257 257 #include <errno.h>
258 258 #include <fcntl.h>
259 259 #include <getopt.h>
260 260 #include <stdio.h>
261 261 #include <stdlib.h>
262 262 #include <string.h>
263 263 #include <unistd.h>
264 264 #include <dirent.h>
265 265
266 266 #include <sys/param.h>
267 267 #include <sys/stat.h>
268 268 #include <sys/types.h>
269 269 #include <sys/utsname.h>
270 270 #include <sys/wait.h>
271 271
272 272 #define CW_F_CXX 0x01
273 273 #define CW_F_SHADOW 0x02
274 274 #define CW_F_EXEC 0x04
275 275 #define CW_F_ECHO 0x08
276 276 #define CW_F_XLATE 0x10
277 277 #define CW_F_PROG 0x20
278 278
279 279 typedef enum cw_op {
280 280 CW_O_NONE = 0,
281 281 CW_O_PREPROCESS,
282 282 CW_O_COMPILE,
283 283 CW_O_LINK
284 284 } cw_op_t;
285 285
286 286 struct aelist {
287 287 struct ae {
288 288 struct ae *ae_next;
289 289 char *ae_arg;
290 290 } *ael_head, *ael_tail;
291 291 int ael_argc;
292 292 };
293 293
294 294 typedef enum {
295 295 GNU,
296 296 SUN,
297 297 SMATCH
298 298 } compiler_style_t;
↓ open down ↓ |
298 lines elided |
↑ open up ↑ |
299 299
300 300 typedef struct {
301 301 char *c_name;
302 302 char *c_path;
303 303 compiler_style_t c_style;
304 304 } cw_compiler_t;
305 305
306 306 typedef struct cw_ictx {
307 307 struct cw_ictx *i_next;
308 308 cw_compiler_t *i_compiler;
309 + char *i_linker;
309 310 struct aelist *i_ae;
310 311 uint32_t i_flags;
311 312 int i_oldargc;
312 313 char **i_oldargv;
313 314 pid_t i_pid;
314 315 char *i_tmpdir;
315 316 char *i_stderr;
316 317 } cw_ictx_t;
317 318
318 319 /*
319 320 * Status values to indicate which Studio compiler and associated
320 321 * flags are being used.
321 322 */
322 323 #define M32 0x01 /* -m32 - only on Studio 12 */
323 324 #define M64 0x02 /* -m64 - only on Studio 12 */
324 325 #define SS11 0x100 /* Studio 11 */
325 326 #define SS12 0x200 /* Studio 12 */
326 327
327 328 #define TRANS_ENTRY 5
328 329 /*
329 330 * Translation table definition for the -xarch= flag. The "x_arg"
330 331 * value is translated into the appropriate gcc flags according
331 332 * to the values in x_trans[n]. The x_flags indicates what compiler
332 333 * is being used and what flags have been set via the use of
333 334 * "x_arg".
334 335 */
335 336 typedef struct xarch_table {
336 337 char *x_arg;
337 338 int x_flags;
338 339 char *x_trans[TRANS_ENTRY];
339 340 } xarch_table_t;
340 341
341 342 /*
342 343 * The translation table for the -xarch= flag used in the Studio compilers.
343 344 */
344 345 static const xarch_table_t xtbl[] = {
345 346 #if defined(__x86)
346 347 { "generic", SS11, {NULL} },
347 348 { "generic64", (SS11|M64), { "-m64", "-mtune=opteron" } },
348 349 { "amd64", (SS11|M64), { "-m64", "-mtune=opteron" } },
349 350 { "386", SS11, { "-march=i386" } },
350 351 { "pentium_pro", SS11, { "-march=pentiumpro" } },
351 352 { "sse", SS11, { "-msse", "-mfpmath=sse" } },
352 353 { "sse2", SS11, { "-msse2", "-mfpmath=sse" } },
353 354 #elif defined(__sparc)
354 355 { "generic", (SS11|M32), { "-m32", "-mcpu=v8" } },
355 356 { "generic64", (SS11|M64), { "-m64", "-mcpu=v9" } },
356 357 { "v8", (SS11|M32), { "-m32", "-mcpu=v8", "-mno-v8plus" } },
357 358 { "v8plus", (SS11|M32), { "-m32", "-mcpu=v9", "-mv8plus" } },
358 359 { "v8plusa", (SS11|M32), { "-m32", "-mcpu=ultrasparc", "-mv8plus",
359 360 "-mvis" } },
360 361 { "v8plusb", (SS11|M32), { "-m32", "-mcpu=ultrasparc3", "-mv8plus",
361 362 "-mvis" } },
362 363 { "v9", (SS11|M64), { "-m64", "-mcpu=v9" } },
363 364 { "v9a", (SS11|M64), { "-m64", "-mcpu=ultrasparc", "-mvis" } },
364 365 { "v9b", (SS11|M64), { "-m64", "-mcpu=ultrasparc3", "-mvis" } },
365 366 { "sparc", SS12, { "-mcpu=v9", "-mv8plus" } },
366 367 { "sparcvis", SS12, { "-mcpu=ultrasparc", "-mvis" } },
367 368 { "sparcvis2", SS12, { "-mcpu=ultrasparc3", "-mvis" } }
368 369 #endif
369 370 };
370 371
371 372 static int xtbl_size = sizeof (xtbl) / sizeof (xarch_table_t);
372 373
373 374 static const char *xchip_tbl[] = {
374 375 #if defined(__x86)
375 376 "386", "-mtune=i386", NULL,
376 377 "486", "-mtune=i486", NULL,
377 378 "pentium", "-mtune=pentium", NULL,
378 379 "pentium_pro", "-mtune=pentiumpro", NULL,
379 380 #elif defined(__sparc)
380 381 "super", "-mtune=supersparc", NULL,
381 382 "ultra", "-mtune=ultrasparc", NULL,
382 383 "ultra3", "-mtune=ultrasparc3", NULL,
383 384 #endif
384 385 NULL, NULL
385 386 };
386 387
387 388 static const char *xcode_tbl[] = {
388 389 #if defined(__sparc)
389 390 "abs32", "-fno-pic", "-mcmodel=medlow", NULL,
390 391 "abs44", "-fno-pic", "-mcmodel=medmid", NULL,
391 392 "abs64", "-fno-pic", "-mcmodel=medany", NULL,
392 393 "pic13", "-fpic", NULL,
393 394 "pic32", "-fPIC", NULL,
394 395 #endif
395 396 NULL, NULL
396 397 };
397 398
398 399 static const char *xtarget_tbl[] = {
399 400 #if defined(__x86)
400 401 "pentium_pro", "-march=pentiumpro", NULL,
401 402 #endif /* __x86 */
402 403 NULL, NULL
403 404 };
404 405
405 406 static const char *xregs_tbl[] = {
406 407 #if defined(__sparc)
407 408 "appl", "-mapp-regs", NULL,
408 409 "no%appl", "-mno-app-regs", NULL,
409 410 "float", "-mfpu", NULL,
410 411 "no%float", "-mno-fpu", NULL,
411 412 #endif /* __sparc */
412 413 NULL, NULL
413 414 };
414 415
415 416 static void
416 417 nomem(void)
417 418 {
418 419 errx(1, "out of memory");
419 420 }
420 421
421 422 static void
422 423 newae(struct aelist *ael, const char *arg)
423 424 {
424 425 struct ae *ae;
425 426
426 427 if ((ae = calloc(sizeof (*ae), 1)) == NULL)
427 428 nomem();
428 429 ae->ae_arg = strdup(arg);
429 430 if (ael->ael_tail == NULL)
430 431 ael->ael_head = ae;
431 432 else
432 433 ael->ael_tail->ae_next = ae;
433 434 ael->ael_tail = ae;
434 435 ael->ael_argc++;
435 436 }
436 437
437 438 static cw_ictx_t *
438 439 newictx(void)
439 440 {
440 441 cw_ictx_t *ctx = calloc(sizeof (cw_ictx_t), 1);
441 442 if (ctx)
442 443 if ((ctx->i_ae = calloc(sizeof (struct aelist), 1)) == NULL) {
443 444 free(ctx);
444 445 return (NULL);
445 446 }
446 447
447 448 return (ctx);
448 449 }
449 450
450 451 static void
451 452 error(const char *arg)
452 453 {
453 454 errx(2, "error: mapping failed at or near arg '%s'", arg);
454 455 }
455 456
456 457 /*
457 458 * Add the current favourite set of warnings to the gcc invocation.
458 459 */
459 460 static void
460 461 warnings(struct aelist *h)
461 462 {
462 463 static int warningsonce;
463 464
464 465 if (warningsonce++)
465 466 return;
466 467
467 468 /*
468 469 * Enable as many warnings as exist, then disable those that we never
469 470 * ever want.
470 471 */
471 472 newae(h, "-Wall");
472 473 newae(h, "-Wextra");
473 474 }
474 475
475 476 static void
476 477 optim_disable(struct aelist *h, int level)
477 478 {
478 479 if (level >= 2) {
479 480 newae(h, "-fno-strict-aliasing");
480 481 newae(h, "-fno-unit-at-a-time");
481 482 newae(h, "-fno-optimize-sibling-calls");
482 483 }
483 484 }
484 485
485 486 static void
486 487 Xsmode(struct aelist *h)
487 488 {
488 489 static int xsonce;
489 490
490 491 if (xsonce++)
491 492 return;
492 493
493 494 newae(h, "-traditional");
494 495 newae(h, "-traditional-cpp");
495 496 }
496 497
497 498 static void
498 499 usage()
499 500 {
500 501 extern char *__progname;
501 502 (void) fprintf(stderr,
502 503 "usage: %s [-C] [--versions] --primary <compiler> "
503 504 "[--shadow <compiler>]... -- cflags...\n",
504 505 __progname);
505 506 (void) fprintf(stderr, "compilers take the form: name,path,style\n"
506 507 " - name: a unique name usable in flag specifiers\n"
507 508 " - path: path to the compiler binary\n"
508 509 " - style: the style of flags expected: either sun or gnu\n");
509 510 exit(2);
510 511 }
511 512
512 513 static int
513 514 xlate_xtb(struct aelist *h, const char *xarg)
514 515 {
515 516 int i, j;
516 517
517 518 for (i = 0; i < xtbl_size; i++) {
518 519 if (strcmp(xtbl[i].x_arg, xarg) == 0)
519 520 break;
520 521 }
521 522
522 523 /*
523 524 * At the end of the table and so no matching "arg" entry
524 525 * found and so this must be a bad -xarch= flag.
525 526 */
526 527 if (i == xtbl_size)
527 528 error(xarg);
528 529
529 530 for (j = 0; j < TRANS_ENTRY; j++) {
530 531 if (xtbl[i].x_trans[j] != NULL)
531 532 newae(h, xtbl[i].x_trans[j]);
532 533 else
533 534 break;
534 535 }
535 536 return (xtbl[i].x_flags);
536 537
537 538 }
538 539
539 540 static void
540 541 xlate(struct aelist *h, const char *xarg, const char **table)
541 542 {
542 543 while (*table != NULL && strcmp(xarg, *table) != 0) {
543 544 while (*table != NULL)
544 545 table++;
545 546 table++;
546 547 }
547 548
548 549 if (*table == NULL)
549 550 error(xarg);
550 551
551 552 table++;
552 553
553 554 while (*table != NULL) {
554 555 newae(h, *table);
555 556 table++;
556 557 }
557 558 }
558 559
559 560 /*
560 561 * The compiler wants the output file to end in appropriate extension. If
561 562 * we're generating a name from whole cloth (path == NULL), we assume that
562 563 * extension to be .o, otherwise we match the extension of the caller.
563 564 */
564 565 static char *
565 566 discard_file_name(cw_ictx_t *ctx, const char *path)
566 567 {
567 568 char *ret, *ext;
568 569 char tmpl[] = "cwXXXXXX";
569 570
570 571 if (path == NULL) {
571 572 ext = ".o";
572 573 } else {
573 574 ext = strrchr(path, '.');
574 575 }
575 576
576 577 /*
577 578 * We need absolute control over where the temporary file goes, since
578 579 * we rely on it for cleanup so tempnam(3C) and tmpnam(3C) are
579 580 * inappropriate (they use TMPDIR, preferentially).
580 581 *
581 582 * mkstemp(3C) doesn't actually help us, since the temporary file
582 583 * isn't used by us, only its name.
583 584 */
584 585 if (mktemp(tmpl) == NULL)
585 586 nomem();
586 587
587 588 (void) asprintf(&ret, "%s/%s%s", ctx->i_tmpdir, tmpl,
588 589 (ext != NULL) ? ext : "");
589 590
590 591 if (ret == NULL)
591 592 nomem();
592 593
593 594 return (ret);
594 595 }
595 596
596 597 static boolean_t
597 598 is_source_file(const char *path)
598 599 {
599 600 char *ext = strrchr(path, '.');
600 601
601 602 if ((ext == NULL) || (*(ext + 1) == '\0'))
602 603 return (B_FALSE);
603 604
604 605 ext += 1;
605 606
606 607 if ((strcasecmp(ext, "c") == 0) ||
607 608 (strcmp(ext, "cc") == 0) ||
608 609 (strcmp(ext, "i") == 0) ||
609 610 (strcasecmp(ext, "s") == 0) ||
610 611 (strcmp(ext, "cpp") == 0)) {
611 612 return (B_TRUE);
612 613 }
613 614
614 615 return (B_FALSE);
615 616 }
616 617
617 618
618 619 static void
619 620 do_gcc(cw_ictx_t *ctx)
620 621 {
621 622 int c;
622 623 int nolibc = 0;
623 624 int in_output = 0, seen_o = 0, c_files = 0;
624 625 cw_op_t op = CW_O_LINK;
625 626 char *model = NULL;
626 627 char *nameflag;
627 628 int mflag = 0;
628 629
629 630 if (ctx->i_flags & CW_F_PROG) {
630 631 newae(ctx->i_ae, "--version");
631 632 return;
632 633 }
633 634
634 635 newae(ctx->i_ae, "-fident");
635 636 newae(ctx->i_ae, "-finline");
636 637 newae(ctx->i_ae, "-fno-inline-functions");
637 638 newae(ctx->i_ae, "-fno-builtin");
638 639 newae(ctx->i_ae, "-fno-asm");
639 640 newae(ctx->i_ae, "-fdiagnostics-show-option");
640 641 newae(ctx->i_ae, "-nodefaultlibs");
641 642
642 643 #if defined(__sparc)
643 644 /*
644 645 * The SPARC ldd and std instructions require 8-byte alignment of
645 646 * their address operand. gcc correctly uses them only when the
646 647 * ABI requires 8-byte alignment; unfortunately we have a number of
647 648 * pieces of buggy code that doesn't conform to the ABI. This
648 649 * flag makes gcc work more like Studio with -xmemalign=4.
649 650 */
650 651 newae(ctx->i_ae, "-mno-integer-ldd-std");
651 652 #endif
652 653
653 654 /*
654 655 * This is needed because 'u' is defined
655 656 * under a conditional on 'sun'. Should
656 657 * probably just remove the conditional,
657 658 * or make it be dependent on '__sun'.
658 659 *
659 660 * -Dunix is also missing in enhanced ANSI mode
660 661 */
661 662 newae(ctx->i_ae, "-D__sun");
662 663
663 664 if (asprintf(&nameflag, "-_%s=", ctx->i_compiler->c_name) == -1)
664 665 nomem();
665 666
666 667 /*
667 668 * Walk the argument list, translating as we go ..
668 669 */
669 670 while (--ctx->i_oldargc > 0) {
670 671 char *arg = *++ctx->i_oldargv;
671 672 size_t arglen = strlen(arg);
672 673
673 674 if (*arg == '-') {
674 675 arglen--;
675 676 } else {
676 677 /*
677 678 * Discard inline files that gcc doesn't grok
678 679 */
679 680 if (!in_output && arglen > 3 &&
680 681 strcmp(arg + arglen - 3, ".il") == 0)
681 682 continue;
682 683
683 684 if (!in_output && is_source_file(arg))
684 685 c_files++;
685 686
686 687 /*
687 688 * Otherwise, filenames and partial arguments
688 689 * are passed through for gcc to chew on. However,
689 690 * output is always discarded for the secondary
690 691 * compiler.
691 692 */
692 693 if ((ctx->i_flags & CW_F_SHADOW) && in_output) {
693 694 newae(ctx->i_ae, discard_file_name(ctx, arg));
694 695 } else {
695 696 newae(ctx->i_ae, arg);
696 697 }
697 698 in_output = 0;
698 699 continue;
699 700 }
700 701
701 702 if (ctx->i_flags & CW_F_CXX) {
702 703 if (strncmp(arg, "-_g++=", 6) == 0) {
703 704 newae(ctx->i_ae, strchr(arg, '=') + 1);
704 705 continue;
705 706 }
706 707 if (strncmp(arg, "-compat=", 8) == 0) {
707 708 /* discard -compat=4 and -compat=5 */
708 709 continue;
709 710 }
710 711 if (strcmp(arg, "-Qoption") == 0) {
711 712 /* discard -Qoption and its two arguments */
712 713 if (ctx->i_oldargc < 3)
713 714 error(arg);
714 715 ctx->i_oldargc -= 2;
715 716 ctx->i_oldargv += 2;
716 717 continue;
717 718 }
718 719 if (strcmp(arg, "-xwe") == 0) {
719 720 /* turn warnings into errors */
720 721 newae(ctx->i_ae, "-Werror");
721 722 continue;
722 723 }
723 724 if (strcmp(arg, "-norunpath") == 0) {
724 725 /* gcc has no corresponding option */
725 726 continue;
726 727 }
727 728 if (strcmp(arg, "-nolib") == 0) {
728 729 /* -nodefaultlibs is on by default */
729 730 nolibc = 1;
730 731 continue;
731 732 }
732 733 #if defined(__sparc)
733 734 if (strcmp(arg, "-cg92") == 0) {
734 735 mflag |= xlate_xtb(ctx->i_ae, "v8");
735 736 xlate(ctx->i_ae, "super", xchip_tbl);
736 737 continue;
737 738 }
738 739 #endif /* __sparc */
739 740 }
740 741
741 742 switch ((c = arg[1])) {
742 743 case '_':
743 744 if ((strncmp(arg, nameflag, strlen(nameflag)) == 0) ||
744 745 (strncmp(arg, "-_gcc=", 6) == 0) ||
745 746 (strncmp(arg, "-_gnu=", 6) == 0)) {
746 747 newae(ctx->i_ae, strchr(arg, '=') + 1);
747 748 }
748 749 break;
749 750 case '#':
750 751 if (arglen == 1) {
751 752 newae(ctx->i_ae, "-v");
752 753 break;
753 754 }
754 755 error(arg);
755 756 break;
756 757 case 'f':
757 758 if ((strcmp(arg, "-fpic") == 0) ||
758 759 (strcmp(arg, "-fPIC") == 0)) {
759 760 newae(ctx->i_ae, arg);
760 761 break;
761 762 }
762 763 error(arg);
763 764 break;
764 765 case 'E':
765 766 if (arglen == 1) {
766 767 newae(ctx->i_ae, "-xc");
767 768 newae(ctx->i_ae, arg);
768 769 op = CW_O_PREPROCESS;
769 770 nolibc = 1;
770 771 break;
771 772 }
772 773 error(arg);
773 774 break;
774 775 case 'c':
775 776 case 'S':
776 777 if (arglen == 1) {
777 778 op = CW_O_COMPILE;
778 779 nolibc = 1;
779 780 }
780 781 /* FALLTHROUGH */
781 782 case 'C':
782 783 case 'H':
783 784 case 'p':
784 785 if (arglen == 1) {
785 786 newae(ctx->i_ae, arg);
786 787 break;
787 788 }
788 789 error(arg);
789 790 break;
790 791 case 'A':
791 792 case 'g':
792 793 case 'h':
793 794 case 'I':
794 795 case 'i':
795 796 case 'L':
796 797 case 'l':
797 798 case 'R':
798 799 case 'U':
799 800 case 'u':
800 801 case 'w':
801 802 newae(ctx->i_ae, arg);
802 803 break;
803 804 case 'o':
804 805 seen_o = 1;
805 806 if (arglen == 1) {
806 807 in_output = 1;
807 808 newae(ctx->i_ae, arg);
808 809 } else if (ctx->i_flags & CW_F_SHADOW) {
809 810 newae(ctx->i_ae, "-o");
810 811 newae(ctx->i_ae, discard_file_name(ctx, arg));
811 812 } else {
812 813 newae(ctx->i_ae, arg);
813 814 }
814 815 break;
815 816 case 'D':
816 817 newae(ctx->i_ae, arg);
817 818 /*
818 819 * XXX Clearly a hack ... do we need _KADB too?
819 820 */
820 821 if (strcmp(arg, "-D_KERNEL") == 0 ||
821 822 strcmp(arg, "-D_BOOT") == 0)
822 823 newae(ctx->i_ae, "-ffreestanding");
823 824 break;
824 825 case 'd':
825 826 if (arglen == 2) {
826 827 if (strcmp(arg, "-dy") == 0) {
827 828 newae(ctx->i_ae, "-Wl,-dy");
828 829 break;
829 830 }
830 831 if (strcmp(arg, "-dn") == 0) {
831 832 newae(ctx->i_ae, "-Wl,-dn");
832 833 break;
833 834 }
834 835 }
835 836 if (strcmp(arg, "-dalign") == 0) {
836 837 /*
837 838 * -dalign forces alignment in some cases;
838 839 * gcc does not need any flag to do this.
839 840 */
840 841 break;
841 842 }
842 843 error(arg);
843 844 break;
844 845 case 'e':
845 846 if (strcmp(arg,
846 847 "-erroff=E_EMPTY_TRANSLATION_UNIT") == 0) {
847 848 /*
848 849 * Accept but ignore this -- gcc doesn't
849 850 * seem to complain about empty translation
850 851 * units
851 852 */
852 853 break;
853 854 }
854 855 /* XX64 -- ignore all -erroff= options, for now */
855 856 if (strncmp(arg, "-erroff=", 8) == 0)
856 857 break;
857 858 if (strcmp(arg, "-errtags=yes") == 0) {
858 859 warnings(ctx->i_ae);
859 860 break;
860 861 }
861 862 if (strcmp(arg, "-errwarn=%all") == 0) {
862 863 newae(ctx->i_ae, "-Werror");
863 864 break;
864 865 }
865 866 error(arg);
866 867 break;
867 868 case 'G':
868 869 newae(ctx->i_ae, "-shared");
869 870 nolibc = 1;
870 871 break;
871 872 case 'k':
872 873 if (strcmp(arg, "-keeptmp") == 0) {
873 874 newae(ctx->i_ae, "-save-temps");
874 875 break;
875 876 }
876 877 error(arg);
877 878 break;
878 879 case 'm':
879 880 if (strcmp(arg, "-mt") == 0) {
880 881 newae(ctx->i_ae, "-D_REENTRANT");
881 882 break;
882 883 }
883 884 if (strcmp(arg, "-m64") == 0) {
884 885 newae(ctx->i_ae, "-m64");
885 886 #if defined(__x86)
886 887 newae(ctx->i_ae, "-mtune=opteron");
887 888 #endif
888 889 mflag |= M64;
889 890 break;
890 891 }
891 892 if (strcmp(arg, "-m32") == 0) {
892 893 newae(ctx->i_ae, "-m32");
893 894 mflag |= M32;
894 895 break;
895 896 }
896 897 error(arg);
897 898 break;
898 899 case 'B': /* linker options */
899 900 case 'M':
900 901 case 'z':
901 902 {
902 903 char *opt;
903 904 size_t len;
904 905 char *s;
905 906
906 907 if (arglen == 1) {
907 908 opt = *++ctx->i_oldargv;
908 909 if (opt == NULL || *opt == '\0')
909 910 error(arg);
910 911 ctx->i_oldargc--;
911 912 } else {
912 913 opt = arg + 2;
913 914 }
914 915 len = strlen(opt) + 7;
915 916 if ((s = malloc(len)) == NULL)
916 917 nomem();
917 918 (void) snprintf(s, len, "-Wl,-%c%s", c, opt);
918 919 newae(ctx->i_ae, s);
919 920 free(s);
920 921 }
921 922 break;
922 923 case 'O':
923 924 if (arglen == 1) {
924 925 newae(ctx->i_ae, "-O");
925 926 break;
926 927 }
927 928 error(arg);
928 929 break;
929 930 case 'P':
930 931 /*
931 932 * We could do '-E -o filename.i', but that's hard,
932 933 * and we don't need it for the case that's triggering
933 934 * this addition. We'll require the user to specify
934 935 * -o in the Makefile. If they don't they'll find out
935 936 * in a hurry.
936 937 */
937 938 newae(ctx->i_ae, "-E");
938 939 op = CW_O_PREPROCESS;
939 940 nolibc = 1;
940 941 break;
941 942 case 's':
942 943 if (arglen == 1) {
943 944 newae(ctx->i_ae, "-Wl,-s");
944 945 break;
945 946 }
946 947 error(arg);
947 948 break;
948 949 case 't':
949 950 if (arglen == 1) {
950 951 newae(ctx->i_ae, "-Wl,-t");
951 952 break;
952 953 }
953 954 error(arg);
954 955 break;
955 956 case 'V':
956 957 if (arglen == 1) {
957 958 ctx->i_flags &= ~CW_F_ECHO;
958 959 newae(ctx->i_ae, "--version");
959 960 break;
960 961 }
961 962 error(arg);
962 963 break;
963 964 case 'v':
964 965 if (arglen == 1) {
965 966 warnings(ctx->i_ae);
966 967 break;
967 968 }
968 969 error(arg);
969 970 break;
970 971 case 'W':
971 972 if (strncmp(arg, "-Wp,-xc99", 9) == 0) {
972 973 /*
973 974 * gcc's preprocessor will accept c99
974 975 * regardless, so accept and ignore.
975 976 */
976 977 break;
977 978 }
978 979 if (strncmp(arg, "-Wa,", 4) == 0 ||
979 980 strncmp(arg, "-Wp,", 4) == 0 ||
980 981 strncmp(arg, "-Wl,", 4) == 0) {
981 982 newae(ctx->i_ae, arg);
982 983 break;
983 984 }
984 985 if (strcmp(arg, "-W0,-noglobal") == 0 ||
985 986 strcmp(arg, "-W0,-xglobalstatic") == 0) {
986 987 /*
987 988 * gcc doesn't prefix local symbols
988 989 * in debug mode, so this is not needed.
989 990 */
990 991 break;
991 992 }
992 993 if (strcmp(arg, "-W0,-Lt") == 0) {
993 994 /*
994 995 * Generate tests at the top of loops.
995 996 * There is no direct gcc equivalent, ignore.
996 997 */
997 998 break;
998 999 }
999 1000 if (strcmp(arg, "-W0,-xdbggen=no%usedonly") == 0) {
1000 1001 newae(ctx->i_ae,
1001 1002 "-fno-eliminate-unused-debug-symbols");
1002 1003 newae(ctx->i_ae,
1003 1004 "-fno-eliminate-unused-debug-types");
1004 1005 break;
1005 1006 }
1006 1007 if (strcmp(arg, "-W2,-xwrap_int") == 0) {
1007 1008 /*
1008 1009 * Use the legacy behaviour (pre-SS11)
1009 1010 * for integer wrapping.
1010 1011 * gcc does not need this.
1011 1012 */
1012 1013 break;
1013 1014 }
1014 1015 if (strcmp(arg, "-Wd,-xsafe=unboundsym") == 0) {
1015 1016 /*
1016 1017 * Prevents optimizing away checks for
1017 1018 * unbound weak symbol addresses. gcc does
1018 1019 * not do this, so it's not needed.
1019 1020 */
1020 1021 break;
1021 1022 }
1022 1023 if (strncmp(arg, "-Wc,-xcode=", 11) == 0) {
1023 1024 xlate(ctx->i_ae, arg + 11, xcode_tbl);
1024 1025 break;
1025 1026 }
1026 1027 if (strncmp(arg, "-Wc,-Qiselect", 13) == 0) {
1027 1028 /*
1028 1029 * Prevents insertion of register symbols.
1029 1030 * gcc doesn't do this, so ignore it.
1030 1031 */
1031 1032 break;
1032 1033 }
1033 1034 if (strcmp(arg, "-Wc,-Qassembler-ounrefsym=0") == 0) {
1034 1035 /*
1035 1036 * Prevents optimizing away of static variables.
1036 1037 * gcc does not do this, so it's not needed.
1037 1038 */
1038 1039 break;
1039 1040 }
1040 1041 #if defined(__x86)
1041 1042 if (strcmp(arg, "-Wu,-save_args") == 0) {
1042 1043 newae(ctx->i_ae, "-msave-args");
1043 1044 break;
1044 1045 }
1045 1046 #endif /* __x86 */
1046 1047 error(arg);
1047 1048 break;
1048 1049 case 'X':
1049 1050 if (strcmp(arg, "-Xa") == 0 ||
1050 1051 strcmp(arg, "-Xt") == 0) {
1051 1052 break;
1052 1053 }
1053 1054 if (strcmp(arg, "-Xs") == 0) {
1054 1055 Xsmode(ctx->i_ae);
1055 1056 break;
1056 1057 }
1057 1058 error(arg);
1058 1059 break;
1059 1060 case 'x':
1060 1061 if (arglen == 1)
1061 1062 error(arg);
1062 1063 switch (arg[2]) {
1063 1064 case 'a':
1064 1065 if (strncmp(arg, "-xarch=", 7) == 0) {
1065 1066 mflag |= xlate_xtb(ctx->i_ae, arg + 7);
1066 1067 break;
1067 1068 }
1068 1069 error(arg);
1069 1070 break;
1070 1071 case 'b':
1071 1072 if (strncmp(arg, "-xbuiltin=", 10) == 0) {
1072 1073 if (strcmp(arg + 10, "%all"))
1073 1074 newae(ctx->i_ae, "-fbuiltin");
1074 1075 break;
1075 1076 }
1076 1077 error(arg);
1077 1078 break;
1078 1079 case 'C':
1079 1080 /* Accept C++ style comments -- ignore */
1080 1081 if (strcmp(arg, "-xCC") == 0)
1081 1082 break;
1082 1083 error(arg);
1083 1084 break;
1084 1085 case 'c':
1085 1086 if (strncmp(arg, "-xc99=%all", 10) == 0) {
1086 1087 newae(ctx->i_ae, "-std=gnu99");
1087 1088 break;
1088 1089 }
1089 1090 if (strncmp(arg, "-xc99=%none", 11) == 0) {
1090 1091 newae(ctx->i_ae, "-std=gnu89");
1091 1092 break;
1092 1093 }
1093 1094 if (strncmp(arg, "-xchip=", 7) == 0) {
1094 1095 xlate(ctx->i_ae, arg + 7, xchip_tbl);
1095 1096 break;
1096 1097 }
1097 1098 if (strncmp(arg, "-xcode=", 7) == 0) {
1098 1099 xlate(ctx->i_ae, arg + 7, xcode_tbl);
1099 1100 break;
1100 1101 }
1101 1102 if (strncmp(arg, "-xcrossfile", 11) == 0)
1102 1103 break;
1103 1104 error(arg);
1104 1105 break;
1105 1106 case 'F':
1106 1107 /*
1107 1108 * Compile for mapfile reordering, or unused
1108 1109 * section elimination, syntax can be -xF or
1109 1110 * more complex, like -xF=%all -- ignore.
1110 1111 */
1111 1112 if (strncmp(arg, "-xF", 3) == 0)
1112 1113 break;
1113 1114 error(arg);
1114 1115 break;
1115 1116 case 'i':
1116 1117 if (strncmp(arg, "-xinline", 8) == 0)
1117 1118 /* No inlining; ignore */
1118 1119 break;
1119 1120 if (strcmp(arg, "-xildon") == 0 ||
1120 1121 strcmp(arg, "-xildoff") == 0)
1121 1122 /* No incremental linking; ignore */
1122 1123 break;
1123 1124 error(arg);
1124 1125 break;
1125 1126 #if defined(__x86)
1126 1127 case 'm':
1127 1128 if (strcmp(arg, "-xmodel=kernel") == 0) {
1128 1129 newae(ctx->i_ae, "-ffreestanding");
1129 1130 newae(ctx->i_ae, "-mno-red-zone");
1130 1131 model = "-mcmodel=kernel";
1131 1132 nolibc = 1;
1132 1133 break;
1133 1134 }
1134 1135 error(arg);
1135 1136 break;
1136 1137 #endif /* __x86 */
1137 1138 case 'O':
1138 1139 if (strncmp(arg, "-xO", 3) == 0) {
1139 1140 size_t len = strlen(arg);
1140 1141 char *s = NULL;
1141 1142 int c = *(arg + 3);
1142 1143 int level;
1143 1144
1144 1145 if (len != 4 || !isdigit(c))
1145 1146 error(arg);
1146 1147
1147 1148 level = atoi(arg + 3);
1148 1149 if (level > 5)
1149 1150 error(arg);
1150 1151 if (level >= 2) {
1151 1152 /*
1152 1153 * For gcc-3.4.x at -O2 we
1153 1154 * need to disable optimizations
1154 1155 * that break ON.
1155 1156 */
1156 1157 optim_disable(ctx->i_ae, level);
1157 1158 /*
1158 1159 * limit -xO3 to -O2 as well.
1159 1160 */
1160 1161 level = 2;
1161 1162 }
1162 1163 if (asprintf(&s, "-O%d", level) == -1)
1163 1164 nomem();
1164 1165 newae(ctx->i_ae, s);
1165 1166 free(s);
1166 1167 break;
1167 1168 }
1168 1169 error(arg);
1169 1170 break;
1170 1171 case 'r':
1171 1172 if (strncmp(arg, "-xregs=", 7) == 0) {
1172 1173 xlate(ctx->i_ae, arg + 7, xregs_tbl);
1173 1174 break;
1174 1175 }
1175 1176 error(arg);
1176 1177 break;
1177 1178 case 's':
1178 1179 if (strcmp(arg, "-xs") == 0 ||
1179 1180 strcmp(arg, "-xspace") == 0 ||
1180 1181 strcmp(arg, "-xstrconst") == 0)
1181 1182 break;
1182 1183 error(arg);
1183 1184 break;
1184 1185 case 't':
1185 1186 if (strncmp(arg, "-xtarget=", 9) == 0) {
1186 1187 xlate(ctx->i_ae, arg + 9, xtarget_tbl);
1187 1188 break;
1188 1189 }
1189 1190 error(arg);
1190 1191 break;
1191 1192 case 'e':
1192 1193 case 'h':
1193 1194 case 'l':
1194 1195 default:
1195 1196 error(arg);
1196 1197 break;
1197 1198 }
1198 1199 break;
1199 1200 case 'Y':
1200 1201 if (arglen == 1) {
1201 1202 if ((arg = *++ctx->i_oldargv) == NULL ||
↓ open down ↓ |
883 lines elided |
↑ open up ↑ |
1202 1203 *arg == '\0')
1203 1204 error("-Y");
1204 1205 ctx->i_oldargc--;
1205 1206 arglen = strlen(arg + 1);
1206 1207 } else {
1207 1208 arg += 2;
1208 1209 }
1209 1210 /* Just ignore -YS,... for now */
1210 1211 if (strncmp(arg, "S,", 2) == 0)
1211 1212 break;
1212 - if (strncmp(arg, "l,", 2) == 0) {
1213 - char *s = strdup(arg);
1214 - s[0] = '-';
1215 - s[1] = 'B';
1216 - newae(ctx->i_ae, s);
1217 - free(s);
1218 - break;
1219 - }
1220 1213 if (strncmp(arg, "I,", 2) == 0) {
1221 1214 char *s = strdup(arg);
1222 1215 s[0] = '-';
1223 1216 s[1] = 'I';
1224 1217 newae(ctx->i_ae, "-nostdinc");
1225 1218 newae(ctx->i_ae, s);
1226 1219 free(s);
1227 1220 break;
1228 1221 }
1229 1222 error(arg);
1230 1223 break;
1231 1224 case 'Q':
1232 1225 /*
1233 1226 * We could map -Qy into -Wl,-Qy etc.
1234 1227 */
1235 1228 default:
1236 1229 error(arg);
1237 1230 break;
1238 1231 }
1239 1232 }
1240 1233
1241 1234 free(nameflag);
1242 1235
1243 1236 /*
1244 1237 * When compiling multiple source files in a single invocation some
1245 1238 * compilers output objects into the current directory with
1246 1239 * predictable and conventional names.
1247 1240 *
1248 1241 * We prevent any attempt to compile multiple files at once so that
1249 1242 * any such objects created by a shadow can't escape into a later
1250 1243 * link-edit.
1251 1244 */
1252 1245 if (c_files > 1 && op != CW_O_PREPROCESS) {
1253 1246 errx(2, "multiple source files are "
1254 1247 "allowed only with -E or -P");
1255 1248 }
1256 1249
1257 1250 /*
1258 1251 * Make sure that we do not have any unintended interactions between
1259 1252 * the xarch options passed in and the version of the Studio compiler
1260 1253 * used.
1261 1254 */
1262 1255 if ((mflag & (SS11|SS12)) == (SS11|SS12)) {
1263 1256 errx(2,
1264 1257 "Conflicting \"-xarch=\" flags (both Studio 11 and 12)\n");
1265 1258 }
1266 1259
1267 1260 switch (mflag) {
1268 1261 case 0:
1269 1262 /* FALLTHROUGH */
1270 1263 case M32:
1271 1264 #if defined(__sparc)
1272 1265 /*
1273 1266 * Only -m32 is defined and so put in the missing xarch
1274 1267 * translation.
1275 1268 */
1276 1269 newae(ctx->i_ae, "-mcpu=v8");
1277 1270 newae(ctx->i_ae, "-mno-v8plus");
1278 1271 #endif
1279 1272 break;
1280 1273 case M64:
1281 1274 #if defined(__sparc)
1282 1275 /*
1283 1276 * Only -m64 is defined and so put in the missing xarch
1284 1277 * translation.
1285 1278 */
1286 1279 newae(ctx->i_ae, "-mcpu=v9");
1287 1280 #endif
1288 1281 break;
1289 1282 case SS12:
1290 1283 #if defined(__sparc)
1291 1284 /* no -m32/-m64 flag used - this is an error for sparc builds */
1292 1285 (void) fprintf(stderr, "No -m32/-m64 flag defined\n");
1293 1286 exit(2);
1294 1287 #endif
1295 1288 break;
1296 1289 case SS11:
1297 1290 /* FALLTHROUGH */
1298 1291 case (SS11|M32):
1299 1292 case (SS11|M64):
1300 1293 break;
1301 1294 case (SS12|M32):
1302 1295 #if defined(__sparc)
1303 1296 /*
1304 1297 * Need to add in further 32 bit options because with SS12
1305 1298 * the xarch=sparcvis option can be applied to 32 or 64
1306 1299 * bit, and so the translatation table (xtbl) cannot handle
1307 1300 * that.
1308 1301 */
1309 1302 newae(ctx->i_ae, "-mv8plus");
1310 1303 #endif
1311 1304 break;
1312 1305 case (SS12|M64):
1313 1306 break;
1314 1307 default:
1315 1308 (void) fprintf(stderr,
1316 1309 "Incompatible -xarch= and/or -m32/-m64 options used.\n");
1317 1310 exit(2);
1318 1311 }
1319 1312
1320 1313 if (ctx->i_flags & CW_F_SHADOW) {
1321 1314 if (op == CW_O_PREPROCESS)
1322 1315 exit(0);
1323 1316 else if (op == CW_O_LINK && c_files == 0)
1324 1317 exit(0);
1325 1318 }
1326 1319
1327 1320 if (model != NULL)
1328 1321 newae(ctx->i_ae, model);
1329 1322 if (!nolibc)
1330 1323 newae(ctx->i_ae, "-lc");
1331 1324 if (!seen_o && (ctx->i_flags & CW_F_SHADOW)) {
1332 1325 newae(ctx->i_ae, "-o");
1333 1326 newae(ctx->i_ae, discard_file_name(ctx, NULL));
1334 1327 }
1335 1328 }
1336 1329
1337 1330 static void
1338 1331 do_smatch(cw_ictx_t *ctx)
1339 1332 {
1340 1333 if (ctx->i_flags & CW_F_PROG) {
1341 1334 newae(ctx->i_ae, "--version");
1342 1335 return;
1343 1336 }
1344 1337
1345 1338 /*
1346 1339 * Some sources shouldn't run smatch at all.
1347 1340 */
1348 1341 for (int i = 0; i < ctx->i_oldargc; i++) {
1349 1342 char *arg = ctx->i_oldargv[i];
1350 1343
1351 1344 if (strcmp(arg, "-_smatch=off") == 0) {
1352 1345 ctx->i_flags &= ~ (CW_F_EXEC | CW_F_ECHO);
1353 1346 return;
1354 1347 }
1355 1348 }
1356 1349
1357 1350 /*
1358 1351 * smatch can handle gcc's options.
1359 1352 */
1360 1353 do_gcc(ctx);
1361 1354 }
1362 1355
1363 1356 static void
1364 1357 do_cc(cw_ictx_t *ctx)
1365 1358 {
1366 1359 int in_output = 0, seen_o = 0, c_files = 0;
1367 1360 cw_op_t op = CW_O_LINK;
1368 1361 char *nameflag;
1369 1362
1370 1363 if (ctx->i_flags & CW_F_PROG) {
1371 1364 newae(ctx->i_ae, "-V");
1372 1365 return;
1373 1366 }
1374 1367
1375 1368 if (asprintf(&nameflag, "-_%s=", ctx->i_compiler->c_name) == -1)
1376 1369 nomem();
1377 1370
1378 1371 while (--ctx->i_oldargc > 0) {
1379 1372 char *arg = *++ctx->i_oldargv;
1380 1373
1381 1374 if (strncmp(arg, "-_CC=", 5) == 0) {
1382 1375 newae(ctx->i_ae, strchr(arg, '=') + 1);
1383 1376 continue;
1384 1377 }
1385 1378
1386 1379 if (*arg != '-') {
1387 1380 if (!in_output && is_source_file(arg))
1388 1381 c_files++;
1389 1382
1390 1383 if (in_output == 0 || !(ctx->i_flags & CW_F_SHADOW)) {
1391 1384 newae(ctx->i_ae, arg);
1392 1385 } else {
1393 1386 in_output = 0;
1394 1387 newae(ctx->i_ae, discard_file_name(ctx, arg));
1395 1388 }
1396 1389 continue;
1397 1390 }
1398 1391 switch (*(arg + 1)) {
1399 1392 case '_':
1400 1393 if ((strncmp(arg, nameflag, strlen(nameflag)) == 0) ||
1401 1394 (strncmp(arg, "-_cc=", 5) == 0) ||
1402 1395 (strncmp(arg, "-_sun=", 6) == 0)) {
1403 1396 newae(ctx->i_ae, strchr(arg, '=') + 1);
1404 1397 }
1405 1398 break;
1406 1399
1407 1400 case 'V':
1408 1401 ctx->i_flags &= ~CW_F_ECHO;
1409 1402 newae(ctx->i_ae, arg);
1410 1403 break;
1411 1404 case 'o':
1412 1405 seen_o = 1;
1413 1406 if (strlen(arg) == 2) {
1414 1407 in_output = 1;
1415 1408 newae(ctx->i_ae, arg);
1416 1409 } else if (ctx->i_flags & CW_F_SHADOW) {
1417 1410 newae(ctx->i_ae, "-o");
1418 1411 newae(ctx->i_ae, discard_file_name(ctx, arg));
1419 1412 } else {
1420 1413 newae(ctx->i_ae, arg);
1421 1414 }
1422 1415 break;
1423 1416 case 'c':
1424 1417 case 'S':
1425 1418 if (strlen(arg) == 2)
1426 1419 op = CW_O_COMPILE;
1427 1420 newae(ctx->i_ae, arg);
1428 1421 break;
1429 1422 case 'E':
1430 1423 case 'P':
1431 1424 if (strlen(arg) == 2)
1432 1425 op = CW_O_PREPROCESS;
1433 1426 /*FALLTHROUGH*/
1434 1427 default:
1435 1428 newae(ctx->i_ae, arg);
1436 1429 }
1437 1430 }
1438 1431
1439 1432 free(nameflag);
1440 1433
1441 1434 /* See the comment on this same code in do_gcc() */
1442 1435 if (c_files > 1 && op != CW_O_PREPROCESS) {
1443 1436 errx(2, "multiple source files are "
1444 1437 "allowed only with -E or -P");
1445 1438 }
1446 1439
1447 1440 if (ctx->i_flags & CW_F_SHADOW) {
1448 1441 if (op == CW_O_PREPROCESS)
1449 1442 exit(0);
1450 1443 else if (op == CW_O_LINK && c_files == 0)
1451 1444 exit(0);
1452 1445 }
1453 1446
1454 1447 if (!seen_o && (ctx->i_flags & CW_F_SHADOW)) {
1455 1448 newae(ctx->i_ae, "-o");
1456 1449 newae(ctx->i_ae, discard_file_name(ctx, NULL));
1457 1450 }
1458 1451 }
1459 1452
1460 1453 static void
↓ open down ↓ |
231 lines elided |
↑ open up ↑ |
1461 1454 prepctx(cw_ictx_t *ctx)
1462 1455 {
1463 1456 newae(ctx->i_ae, ctx->i_compiler->c_path);
1464 1457
1465 1458 if (ctx->i_flags & CW_F_PROG) {
1466 1459 (void) printf("%s: %s\n", (ctx->i_flags & CW_F_SHADOW) ?
1467 1460 "shadow" : "primary", ctx->i_compiler->c_path);
1468 1461 (void) fflush(stdout);
1469 1462 }
1470 1463
1464 + if (ctx->i_linker != NULL)
1465 + setenv("LD_ALTEXEC", ctx->i_linker, 1);
1466 +
1471 1467 if (!(ctx->i_flags & CW_F_XLATE))
1472 1468 return;
1473 1469
1474 1470 switch (ctx->i_compiler->c_style) {
1475 1471 case SUN:
1476 1472 do_cc(ctx);
1477 1473 break;
1478 1474 case GNU:
1479 1475 do_gcc(ctx);
1480 1476 break;
1481 1477 case SMATCH:
1482 1478 do_smatch(ctx);
1483 1479 break;
1484 1480 }
1485 1481 }
1486 1482
1487 1483 static int
1488 1484 invoke(cw_ictx_t *ctx)
1489 1485 {
1490 1486 char **newargv;
1491 1487 int ac;
1492 1488 struct ae *a;
1493 1489
1494 1490 if ((newargv = calloc(sizeof (*newargv), ctx->i_ae->ael_argc + 1)) ==
1495 1491 NULL)
1496 1492 nomem();
1497 1493
1498 1494 if (ctx->i_flags & CW_F_ECHO)
1499 1495 (void) fprintf(stderr, "+ ");
1500 1496
1501 1497 for (ac = 0, a = ctx->i_ae->ael_head; a; a = a->ae_next, ac++) {
1502 1498 newargv[ac] = a->ae_arg;
1503 1499 if (ctx->i_flags & CW_F_ECHO)
1504 1500 (void) fprintf(stderr, "%s ", a->ae_arg);
1505 1501 if (a == ctx->i_ae->ael_tail)
1506 1502 break;
1507 1503 }
1508 1504
1509 1505 if (ctx->i_flags & CW_F_ECHO) {
1510 1506 (void) fprintf(stderr, "\n");
1511 1507 (void) fflush(stderr);
1512 1508 }
1513 1509
1514 1510 if (!(ctx->i_flags & CW_F_EXEC))
1515 1511 return (0);
1516 1512
1517 1513 /*
1518 1514 * We must fix up the environment here so that the dependency files are
1519 1515 * not trampled by the shadow compiler. Also take care of GCC
1520 1516 * environment variables that will throw off gcc. This assumes a primary
1521 1517 * gcc.
1522 1518 */
1523 1519 if ((ctx->i_flags & CW_F_SHADOW) &&
1524 1520 (unsetenv("SUNPRO_DEPENDENCIES") != 0 ||
1525 1521 unsetenv("DEPENDENCIES_OUTPUT") != 0 ||
1526 1522 unsetenv("GCC_ROOT") != 0)) {
1527 1523 (void) fprintf(stderr, "error: environment setup failed: %s\n",
1528 1524 strerror(errno));
1529 1525 return (-1);
1530 1526 }
1531 1527
1532 1528 (void) execv(newargv[0], newargv);
1533 1529 warn("couldn't run %s", newargv[0]);
1534 1530
1535 1531 return (-1);
1536 1532 }
1537 1533
1538 1534 static int
1539 1535 reap(cw_ictx_t *ctx)
1540 1536 {
1541 1537 int status, ret = 0;
1542 1538 char buf[1024];
1543 1539 struct stat s;
1544 1540
1545 1541 /*
1546 1542 * Only wait for one specific child.
1547 1543 */
1548 1544 if (ctx->i_pid <= 0)
1549 1545 return (-1);
1550 1546
1551 1547 do {
1552 1548 if (waitpid(ctx->i_pid, &status, 0) < 0) {
1553 1549 warn("cannot reap child");
1554 1550 return (-1);
1555 1551 }
1556 1552 if (status != 0) {
1557 1553 if (WIFSIGNALED(status)) {
1558 1554 ret = -WTERMSIG(status);
1559 1555 break;
1560 1556 } else if (WIFEXITED(status)) {
1561 1557 ret = WEXITSTATUS(status);
1562 1558 break;
1563 1559 }
1564 1560 }
1565 1561 } while (!WIFEXITED(status) && !WIFSIGNALED(status));
1566 1562
1567 1563 if (stat(ctx->i_stderr, &s) < 0) {
1568 1564 warn("stat failed on child cleanup");
1569 1565 return (-1);
1570 1566 }
1571 1567 if (s.st_size != 0) {
1572 1568 FILE *f;
1573 1569
1574 1570 if ((f = fopen(ctx->i_stderr, "r")) != NULL) {
1575 1571 while (fgets(buf, sizeof (buf), f))
1576 1572 (void) fprintf(stderr, "%s", buf);
1577 1573 (void) fflush(stderr);
1578 1574 (void) fclose(f);
1579 1575 }
1580 1576 }
1581 1577 (void) unlink(ctx->i_stderr);
1582 1578 free(ctx->i_stderr);
1583 1579
1584 1580 /*
1585 1581 * cc returns an error code when given -V; we want that to succeed.
1586 1582 */
1587 1583 if (ctx->i_flags & CW_F_PROG)
1588 1584 return (0);
1589 1585
1590 1586 return (ret);
1591 1587 }
1592 1588
1593 1589 static int
1594 1590 exec_ctx(cw_ictx_t *ctx, int block)
1595 1591 {
1596 1592 if ((ctx->i_stderr = tempnam(ctx->i_tmpdir, "cw")) == NULL) {
1597 1593 nomem();
1598 1594 return (-1);
1599 1595 }
1600 1596
1601 1597 if ((ctx->i_pid = fork()) == 0) {
1602 1598 int fd;
1603 1599
1604 1600 (void) fclose(stderr);
1605 1601 if ((fd = open(ctx->i_stderr, O_WRONLY | O_CREAT | O_EXCL,
1606 1602 0666)) < 0) {
1607 1603 err(1, "open failed for standard error");
1608 1604 }
1609 1605 if (dup2(fd, 2) < 0) {
1610 1606 err(1, "dup2 failed for standard error");
1611 1607 }
1612 1608 if (fd != 2)
1613 1609 (void) close(fd);
1614 1610 if (freopen("/dev/fd/2", "w", stderr) == NULL) {
1615 1611 err(1, "freopen failed for /dev/fd/2");
1616 1612 }
1617 1613
1618 1614 prepctx(ctx);
1619 1615 exit(invoke(ctx));
1620 1616 }
1621 1617
1622 1618 if (ctx->i_pid < 0) {
1623 1619 err(1, "fork failed");
1624 1620 }
1625 1621
1626 1622 if (block)
1627 1623 return (reap(ctx));
1628 1624
1629 1625 return (0);
1630 1626 }
1631 1627
1632 1628 static void
1633 1629 parse_compiler(const char *spec, cw_compiler_t *compiler)
1634 1630 {
1635 1631 char *tspec, *token;
1636 1632
1637 1633 if ((tspec = strdup(spec)) == NULL)
1638 1634 nomem();
1639 1635
1640 1636 if ((token = strsep(&tspec, ",")) == NULL)
1641 1637 errx(1, "Compiler is missing a name: %s", spec);
1642 1638 compiler->c_name = token;
1643 1639
1644 1640 if ((token = strsep(&tspec, ",")) == NULL)
1645 1641 errx(1, "Compiler is missing a path: %s", spec);
1646 1642 compiler->c_path = token;
1647 1643
1648 1644 if ((token = strsep(&tspec, ",")) == NULL)
1649 1645 errx(1, "Compiler is missing a style: %s", spec);
1650 1646
1651 1647 if ((strcasecmp(token, "gnu") == 0) ||
1652 1648 (strcasecmp(token, "gcc") == 0)) {
1653 1649 compiler->c_style = GNU;
1654 1650 } else if ((strcasecmp(token, "sun") == 0) ||
1655 1651 (strcasecmp(token, "cc") == 0)) {
1656 1652 compiler->c_style = SUN;
1657 1653 } else if ((strcasecmp(token, "smatch") == 0)) {
1658 1654 compiler->c_style = SMATCH;
1659 1655 } else {
1660 1656 errx(1, "unknown compiler style: %s", token);
1661 1657 }
1662 1658
1663 1659 if (tspec != NULL)
1664 1660 errx(1, "Excess tokens in compiler: %s", spec);
1665 1661 }
1666 1662
1667 1663 static void
1668 1664 cleanup(cw_ictx_t *ctx)
1669 1665 {
1670 1666 DIR *dirp;
1671 1667 struct dirent *dp;
1672 1668 char buf[MAXPATHLEN];
1673 1669
1674 1670 if ((dirp = opendir(ctx->i_tmpdir)) == NULL) {
1675 1671 if (errno != ENOENT) {
1676 1672 err(1, "couldn't open temp directory: %s",
1677 1673 ctx->i_tmpdir);
1678 1674 } else {
1679 1675 return;
1680 1676 }
1681 1677 }
1682 1678
1683 1679 errno = 0;
1684 1680 while ((dp = readdir(dirp)) != NULL) {
1685 1681 (void) snprintf(buf, MAXPATHLEN, "%s/%s", ctx->i_tmpdir,
1686 1682 dp->d_name);
1687 1683
1688 1684 if (strcmp(dp->d_name, ".") == 0 ||
1689 1685 strcmp(dp->d_name, "..") == 0) {
1690 1686 continue;
1691 1687 }
1692 1688
1693 1689 if (unlink(buf) == -1)
1694 1690 err(1, "failed to unlink temp file: %s", dp->d_name);
1695 1691 errno = 0;
1696 1692 }
1697 1693
1698 1694 if (errno != 0) {
1699 1695 err(1, "failed to read temporary directory: %s",
1700 1696 ctx->i_tmpdir);
1701 1697 }
1702 1698
1703 1699 (void) closedir(dirp);
1704 1700 if (rmdir(ctx->i_tmpdir) != 0) {
1705 1701 err(1, "failed to unlink temporary directory: %s",
1706 1702 ctx->i_tmpdir);
1707 1703 }
1708 1704 }
1709 1705
1710 1706 int
1711 1707 main(int argc, char **argv)
1712 1708 {
1713 1709 int ch;
1714 1710 cw_compiler_t primary = { NULL, NULL, 0 };
1715 1711 cw_compiler_t shadows[10];
1716 1712 int nshadows = 0;
1717 1713 int ret = 0;
1718 1714 boolean_t do_serial = B_FALSE;
1719 1715 boolean_t do_exec = B_FALSE;
↓ open down ↓ |
239 lines elided |
↑ open up ↑ |
1720 1716 boolean_t vflg = B_FALSE;
1721 1717 boolean_t Cflg = B_FALSE;
1722 1718 boolean_t cflg = B_FALSE;
1723 1719 boolean_t nflg = B_FALSE;
1724 1720 char *tmpdir;
1725 1721
1726 1722 cw_ictx_t *main_ctx;
1727 1723
1728 1724 static struct option longopts[] = {
1729 1725 { "compiler", no_argument, NULL, 'c' },
1726 + { "linker", required_argument, NULL, 'l' },
1730 1727 { "noecho", no_argument, NULL, 'n' },
1731 1728 { "primary", required_argument, NULL, 'p' },
1732 1729 { "shadow", required_argument, NULL, 's' },
1733 1730 { "versions", no_argument, NULL, 'v' },
1734 1731 { NULL, 0, NULL, 0 },
1735 1732 };
1736 1733
1737 1734
1738 1735 if ((main_ctx = newictx()) == NULL)
1739 1736 nomem();
1740 1737
1741 1738 while ((ch = getopt_long(argc, argv, "C", longopts, NULL)) != -1) {
1742 1739 switch (ch) {
1743 1740 case 'c':
1744 1741 cflg = B_TRUE;
1745 1742 break;
1746 1743 case 'C':
1747 1744 Cflg = B_TRUE;
1745 + break;
1746 + case 'l':
1747 + if ((main_ctx->i_linker = strdup(optarg)) == NULL)
1748 + nomem();
1748 1749 break;
1749 1750 case 'n':
1750 1751 nflg = B_TRUE;
1751 1752 break;
1752 1753 case 'p':
1753 1754 if (primary.c_path != NULL) {
1754 1755 warnx("Only one primary compiler may "
1755 1756 "be specified");
1756 1757 usage();
1757 1758 }
1758 1759
1759 1760 parse_compiler(optarg, &primary);
1760 1761 break;
1761 1762 case 's':
1762 1763 if (nshadows >= 10)
1763 1764 errx(1, "May only use 10 shadows at "
1764 1765 "the moment");
1765 1766 parse_compiler(optarg, &shadows[nshadows]);
1766 1767 nshadows++;
1767 1768 break;
1768 1769 case 'v':
1769 1770 vflg = B_TRUE;
1770 1771 break;
1771 1772 default:
1772 1773 (void) fprintf(stderr, "Did you forget '--'?\n");
1773 1774 usage();
1774 1775 }
1775 1776 }
1776 1777
1777 1778 if (primary.c_path == NULL) {
1778 1779 warnx("A primary compiler must be specified");
1779 1780 usage();
1780 1781 }
1781 1782
1782 1783 do_serial = (getenv("CW_SHADOW_SERIAL") == NULL) ? B_FALSE : B_TRUE;
1783 1784 do_exec = (getenv("CW_NO_EXEC") == NULL) ? B_TRUE : B_FALSE;
1784 1785
1785 1786 /* Leave room for argv[0] */
1786 1787 argc -= (optind - 1);
1787 1788 argv += (optind - 1);
1788 1789
1789 1790 main_ctx->i_oldargc = argc;
1790 1791 main_ctx->i_oldargv = argv;
1791 1792 main_ctx->i_flags = CW_F_XLATE;
1792 1793 if (nflg == 0)
1793 1794 main_ctx->i_flags |= CW_F_ECHO;
1794 1795 if (do_exec)
1795 1796 main_ctx->i_flags |= CW_F_EXEC;
1796 1797 if (Cflg)
1797 1798 main_ctx->i_flags |= CW_F_CXX;
1798 1799 main_ctx->i_compiler = &primary;
1799 1800
1800 1801 if (cflg) {
1801 1802 (void) fputs(primary.c_path, stdout);
1802 1803 }
1803 1804
1804 1805 if (vflg) {
1805 1806 (void) printf("cw version %s\n", CW_VERSION);
1806 1807 (void) fflush(stdout);
1807 1808 main_ctx->i_flags &= ~CW_F_ECHO;
1808 1809 main_ctx->i_flags |= CW_F_PROG | CW_F_EXEC;
1809 1810 do_serial = 1;
1810 1811 }
1811 1812
1812 1813 tmpdir = getenv("TMPDIR");
1813 1814 if (tmpdir == NULL)
1814 1815 tmpdir = "/tmp";
1815 1816
1816 1817 if (asprintf(&main_ctx->i_tmpdir, "%s/cw.XXXXXX", tmpdir) == -1)
1817 1818 nomem();
1818 1819
1819 1820 if ((main_ctx->i_tmpdir = mkdtemp(main_ctx->i_tmpdir)) == NULL)
1820 1821 errx(1, "failed to create temporary directory");
1821 1822
1822 1823 ret |= exec_ctx(main_ctx, do_serial);
1823 1824
1824 1825 for (int i = 0; i < nshadows; i++) {
1825 1826 int r;
1826 1827 cw_ictx_t *shadow_ctx;
1827 1828
1828 1829 if ((shadow_ctx = newictx()) == NULL)
1829 1830 nomem();
1830 1831
1831 1832 (void) memcpy(shadow_ctx, main_ctx, sizeof (cw_ictx_t));
1832 1833
1833 1834 shadow_ctx->i_flags |= CW_F_SHADOW;
1834 1835 shadow_ctx->i_compiler = &shadows[i];
1835 1836
1836 1837 r = exec_ctx(shadow_ctx, do_serial);
1837 1838 if (r == 0) {
1838 1839 shadow_ctx->i_next = main_ctx->i_next;
1839 1840 main_ctx->i_next = shadow_ctx;
1840 1841 }
1841 1842 ret |= r;
1842 1843 }
1843 1844
1844 1845 if (!do_serial) {
1845 1846 cw_ictx_t *next = main_ctx;
1846 1847 while (next != NULL) {
1847 1848 cw_ictx_t *toreap = next;
1848 1849 next = next->i_next;
1849 1850 ret |= reap(toreap);
1850 1851 }
1851 1852 }
1852 1853
1853 1854 cleanup(main_ctx);
1854 1855 return (ret);
1855 1856 }
↓ open down ↓ |
98 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX