17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*02e56f3fSwesolows * Common Development and Distribution License (the "License"). 6*02e56f3fSwesolows * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 21*02e56f3fSwesolows 227c478bd9Sstevel@tonic-gate /* 237c478bd9Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate /* 307c478bd9Sstevel@tonic-gate * Wrapper for the GNU C compiler to make it accept the Sun C compiler 317c478bd9Sstevel@tonic-gate * arguments where possible. 327c478bd9Sstevel@tonic-gate * 337c478bd9Sstevel@tonic-gate * Since the translation is inexact, this is something of a work-in-progress. 347c478bd9Sstevel@tonic-gate */ 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate /* 377c478bd9Sstevel@tonic-gate * -# Verbose mode 387c478bd9Sstevel@tonic-gate * -### Show compiler commands built by driver, no compilation 397c478bd9Sstevel@tonic-gate * -A<name[(tokens)]> Preprocessor predicate assertion 407c478bd9Sstevel@tonic-gate * -B<[static|dynamic]> Specify dynamic or static binding 417c478bd9Sstevel@tonic-gate * -C Prevent preprocessor from removing comments 427c478bd9Sstevel@tonic-gate * -c Compile only - produce .o files, suppress linking 437c478bd9Sstevel@tonic-gate * -cg92 Alias for -xtarget=ss1000 447c478bd9Sstevel@tonic-gate * -D<name[=token]> Associate name with token as if by #define 457c478bd9Sstevel@tonic-gate * -d[y|n] dynamic [-dy] or static [-dn] option to linker 467c478bd9Sstevel@tonic-gate * -E Compile source through preprocessor only, output to stdout 477c478bd9Sstevel@tonic-gate * -erroff=<t> Suppress warnings specified by tags t(%none, %all, <tag list>) 487c478bd9Sstevel@tonic-gate * -errtags=<a> Display messages with tags a(no, yes) 497c478bd9Sstevel@tonic-gate * -errwarn=<t> Treats warnings specified by tags t(%none, %all, <tag list>) 507c478bd9Sstevel@tonic-gate * as errors 517c478bd9Sstevel@tonic-gate * -fast Optimize using a selection of options 527c478bd9Sstevel@tonic-gate * -fd Report old-style function definitions and declarations 537c478bd9Sstevel@tonic-gate * -flags Show this summary of compiler options 547c478bd9Sstevel@tonic-gate * -fnonstd Initialize floating-point hardware to non-standard preferences 557c478bd9Sstevel@tonic-gate * -fns[=<yes|no>] Select non-standard floating point mode 567c478bd9Sstevel@tonic-gate * -fprecision=<p> Set FP rounding precision mode p(single, double, extended) 577c478bd9Sstevel@tonic-gate * -fround=<r> Select the IEEE rounding mode in effect at startup 587c478bd9Sstevel@tonic-gate * -fsimple[=<n>] Select floating-point optimization preferences <n> 597c478bd9Sstevel@tonic-gate * -fsingle Use single-precision arithmetic (-Xt and -Xs modes only) 607c478bd9Sstevel@tonic-gate * -ftrap=<t> Select floating-point trapping mode in effect at startup 617c478bd9Sstevel@tonic-gate * -fstore force floating pt. values to target precision on assignment 627c478bd9Sstevel@tonic-gate * -G Build a dynamic shared library 637c478bd9Sstevel@tonic-gate * -g Compile for debugging 647c478bd9Sstevel@tonic-gate * -H Print path name of each file included during compilation 657c478bd9Sstevel@tonic-gate * -h <name> Assign <name> to generated dynamic shared library 667c478bd9Sstevel@tonic-gate * -I<dir> Add <dir> to preprocessor #include file search path 677c478bd9Sstevel@tonic-gate * -i Passed to linker to ignore any LD_LIBRARY_PATH setting 687c478bd9Sstevel@tonic-gate * -keeptmp Keep temporary files created during compilation 697c478bd9Sstevel@tonic-gate * -KPIC Compile position independent code with 32-bit addresses 707c478bd9Sstevel@tonic-gate * -Kpic Compile position independent code 717c478bd9Sstevel@tonic-gate * -L<dir> Pass to linker to add <dir> to the library search path 727c478bd9Sstevel@tonic-gate * -l<name> Link with library lib<name>.a or lib<name>.so 737c478bd9Sstevel@tonic-gate * -mc Remove duplicate strings from .comment section of output files 747c478bd9Sstevel@tonic-gate * -mr Remove all strings from .comment section of output files 757c478bd9Sstevel@tonic-gate * -mr,"string" Remove all strings and append "string" to .comment section 767c478bd9Sstevel@tonic-gate * -mt Specify options needed when compiling multi-threaded code 777c478bd9Sstevel@tonic-gate * -native Find available processor, generate code accordingly 787c478bd9Sstevel@tonic-gate * -nofstore Do not force floating pt. values to target precision 797c478bd9Sstevel@tonic-gate * on assignment 807c478bd9Sstevel@tonic-gate * -nolib Same as -xnolib 817c478bd9Sstevel@tonic-gate * -noqueue Disable queuing of compiler license requests 827c478bd9Sstevel@tonic-gate * -norunpath Do not build in a runtime path for shared libraries 83662492f5Ssherrym * -O Use default optimization level (-xO2 or -xO3. Check man page.) 847c478bd9Sstevel@tonic-gate * -o <outputfile> Set name of output file to <outputfile> 857c478bd9Sstevel@tonic-gate * -P Compile source through preprocessor only, output to .i file 867c478bd9Sstevel@tonic-gate * -PIC Alias for -KPIC or -xcode=pic32 877c478bd9Sstevel@tonic-gate * -p Compile for profiling with prof 887c478bd9Sstevel@tonic-gate * -pic Alias for -Kpic or -xcode=pic13 897c478bd9Sstevel@tonic-gate * -Q[y|n] Emit/don't emit identification info to output file 907c478bd9Sstevel@tonic-gate * -qp Compile for profiling with prof 917c478bd9Sstevel@tonic-gate * -R<dir[:dir]> Build runtime search path list into executable 927c478bd9Sstevel@tonic-gate * -S Compile and only generate assembly code (.s) 937c478bd9Sstevel@tonic-gate * -s Strip symbol table from the executable file 94159cf8a6Swesolows * -t Turn off duplicate symbol warnings when linking 957c478bd9Sstevel@tonic-gate * -U<name> Delete initial definition of preprocessor symbol <name> 967c478bd9Sstevel@tonic-gate * -V Report version number of each compilation phase 977c478bd9Sstevel@tonic-gate * -v Do stricter semantic checking 987c478bd9Sstevel@tonic-gate * -W<c>,<arg> Pass <arg> to specified component <c> (a,l,m,p,0,2,h,i,u) 997c478bd9Sstevel@tonic-gate * -w Suppress compiler warning messages 1007c478bd9Sstevel@tonic-gate * -Xa Compile assuming ANSI C conformance, allow K & R extensions 1017c478bd9Sstevel@tonic-gate * (default mode) 1027c478bd9Sstevel@tonic-gate * -Xc Compile assuming strict ANSI C conformance 1037c478bd9Sstevel@tonic-gate * -Xs Compile assuming (pre-ANSI) K & R C style code 1047c478bd9Sstevel@tonic-gate * -Xt Compile assuming K & R conformance, allow ANSI C 1057c478bd9Sstevel@tonic-gate * -x386 Generate code for the 80386 processor 1067c478bd9Sstevel@tonic-gate * -x486 Generate code for the 80486 processor 1077c478bd9Sstevel@tonic-gate * -xarch=<a> Specify target architecture instruction set 1087c478bd9Sstevel@tonic-gate * -xbuiltin[=<b>] When profitable inline, or substitute intrinisic functions 1097c478bd9Sstevel@tonic-gate * for system functions, b={%all,%none} 1107c478bd9Sstevel@tonic-gate * -xCC Accept C++ style comments 1117c478bd9Sstevel@tonic-gate * -xchar_byte_order=<o> Specify multi-char byte order <o> (default, high, low) 1127c478bd9Sstevel@tonic-gate * -xchip=<c> Specify the target processor for use by the optimizer 1137c478bd9Sstevel@tonic-gate * -xcode=<c> Generate different code for forming addresses 1147c478bd9Sstevel@tonic-gate * -xcrossfile[=<n>] Enable optimization and inlining across source files, 1157c478bd9Sstevel@tonic-gate * n={0|1} 1167c478bd9Sstevel@tonic-gate * -xe Perform only syntax/semantic checking, no code generation 1177c478bd9Sstevel@tonic-gate * -xF Compile for later mapfile reordering 1187c478bd9Sstevel@tonic-gate * -xhelp=<f> Display on-line help information f(flags, readme, errors) 1197c478bd9Sstevel@tonic-gate * -xildoff Cancel -xildon 1207c478bd9Sstevel@tonic-gate * -xildon Enable use of the incremental linker, ild 1217c478bd9Sstevel@tonic-gate * -xinline=[<a>,...,<a>] Attempt inlining of specified user routines, 1227c478bd9Sstevel@tonic-gate * <a>={%auto,func,no%func} 1237c478bd9Sstevel@tonic-gate * -xlibmieee Force IEEE 754 return values for math routines in 1247c478bd9Sstevel@tonic-gate * exceptional cases 1257c478bd9Sstevel@tonic-gate * -xlibmil Inline selected libm math routines for optimization 1267c478bd9Sstevel@tonic-gate * -xlic_lib=sunperf Link in the Sun supplied performance libraries 1277c478bd9Sstevel@tonic-gate * -xlicinfo Show license server information 1287c478bd9Sstevel@tonic-gate * -xM Generate makefile dependencies 1297c478bd9Sstevel@tonic-gate * -xM1 Generate makefile dependencies, but exclude /usr/include 1307c478bd9Sstevel@tonic-gate * -xmaxopt=[off,1,2,3,4,5] maximum optimization level allowed on #pragma opt 1317c478bd9Sstevel@tonic-gate * -xnolib Do not link with default system libraries 1327c478bd9Sstevel@tonic-gate * -xnolibmil Cancel -xlibmil on command line 1337c478bd9Sstevel@tonic-gate * -xO<n> Generate optimized code (n={1|2|3|4|5}) 1347c478bd9Sstevel@tonic-gate * -xP Print prototypes for function definitions 1357c478bd9Sstevel@tonic-gate * -xpentium Generate code for the pentium processor 1367c478bd9Sstevel@tonic-gate * -xpg Compile for profiling with gprof 1377c478bd9Sstevel@tonic-gate * -xprofile=<p> Collect data for a profile or use a profile to optimize 1387c478bd9Sstevel@tonic-gate * <p>={{collect,use}[:<path>],tcov} 1397c478bd9Sstevel@tonic-gate * -xregs=<r> Control register allocation 1407c478bd9Sstevel@tonic-gate * -xs Allow debugging without object (.o) files 1417c478bd9Sstevel@tonic-gate * -xsb Compile for use with the WorkShop source browser 1427c478bd9Sstevel@tonic-gate * -xsbfast Generate only WorkShop source browser info, no compilation 1437c478bd9Sstevel@tonic-gate * -xsfpconst Represent unsuffixed floating point constants as single 1447c478bd9Sstevel@tonic-gate * precision 1457c478bd9Sstevel@tonic-gate * -xspace Do not do optimizations that increase code size 1467c478bd9Sstevel@tonic-gate * -xstrconst Place string literals into read-only data segment 1477c478bd9Sstevel@tonic-gate * -xtarget=<t> Specify target system for optimization 1487c478bd9Sstevel@tonic-gate * -xtemp=<dir> Set directory for temporary files to <dir> 1497c478bd9Sstevel@tonic-gate * -xtime Report the execution time for each compilation phase 1507c478bd9Sstevel@tonic-gate * -xtransition Emit warnings for differences between K&R C and ANSI C 1517c478bd9Sstevel@tonic-gate * -xtrigraphs[=<yes|no>] Enable|disable trigraph translation 1527c478bd9Sstevel@tonic-gate * -xunroll=n Enable unrolling loops n times where possible 1537c478bd9Sstevel@tonic-gate * -Y<c>,<dir> Specify <dir> for location of component <c> (a,l,m,p,0,h,i,u) 1547c478bd9Sstevel@tonic-gate * -YA,<dir> Change default directory searched for components 1557c478bd9Sstevel@tonic-gate * -YI,<dir> Change default directory searched for include files 1567c478bd9Sstevel@tonic-gate * -YP,<dir> Change default directory for finding libraries files 1577c478bd9Sstevel@tonic-gate * -YS,<dir> Change default directory for startup object files 1587c478bd9Sstevel@tonic-gate */ 1597c478bd9Sstevel@tonic-gate 1607c478bd9Sstevel@tonic-gate /* 1617c478bd9Sstevel@tonic-gate * Translation table: 1627c478bd9Sstevel@tonic-gate */ 1637c478bd9Sstevel@tonic-gate /* 1647c478bd9Sstevel@tonic-gate * -# -v 1657c478bd9Sstevel@tonic-gate * -### error 1667c478bd9Sstevel@tonic-gate * -A<name[(tokens)]> pass-thru 1677c478bd9Sstevel@tonic-gate * -B<[static|dynamic]> pass-thru (syntax error for anything else) 1687c478bd9Sstevel@tonic-gate * -C pass-thru 1697c478bd9Sstevel@tonic-gate * -c pass-thru 1707c478bd9Sstevel@tonic-gate * -cg92 -m32 -mcpu=v8 -mtune=supersparc (SPARC only) 1717c478bd9Sstevel@tonic-gate * -D<name[=token]> pass-thru 1727c478bd9Sstevel@tonic-gate * -dy or -dn -Wl,-dy or -Wl,-dn 1737c478bd9Sstevel@tonic-gate * -E pass-thru 1747c478bd9Sstevel@tonic-gate * -erroff=E_EMPTY_TRANSLATION_UNIT ignore 1757c478bd9Sstevel@tonic-gate * -errtags=%all -Wall 1767c478bd9Sstevel@tonic-gate * -errwarn=%all -Werror else -Wno-error 1777c478bd9Sstevel@tonic-gate * -fast error 1787c478bd9Sstevel@tonic-gate * -fd error 1797c478bd9Sstevel@tonic-gate * -flags --help 1807c478bd9Sstevel@tonic-gate * -fnonstd error 1817c478bd9Sstevel@tonic-gate * -fns[=<yes|no>] error 1827c478bd9Sstevel@tonic-gate * -fprecision=<p> error 1837c478bd9Sstevel@tonic-gate * -fround=<r> error 1847c478bd9Sstevel@tonic-gate * -fsimple[=<n>] error 1857c478bd9Sstevel@tonic-gate * -fsingle[=<n>] error 1867c478bd9Sstevel@tonic-gate * -ftrap=<t> error 1877c478bd9Sstevel@tonic-gate * -fstore error 1887c478bd9Sstevel@tonic-gate * -G pass-thru 1897c478bd9Sstevel@tonic-gate * -g pass-thru 1907c478bd9Sstevel@tonic-gate * -H pass-thru 1917c478bd9Sstevel@tonic-gate * -h <name> pass-thru 1927c478bd9Sstevel@tonic-gate * -I<dir> pass-thru 1937c478bd9Sstevel@tonic-gate * -i pass-thru 1947c478bd9Sstevel@tonic-gate * -keeptmp -save-temps 1957c478bd9Sstevel@tonic-gate * -KPIC -fPIC 1967c478bd9Sstevel@tonic-gate * -Kpic -fpic 1977c478bd9Sstevel@tonic-gate * -L<dir> pass-thru 1987c478bd9Sstevel@tonic-gate * -l<name> pass-thru 1997c478bd9Sstevel@tonic-gate * -mc error 2007c478bd9Sstevel@tonic-gate * -mr error 2017c478bd9Sstevel@tonic-gate * -mr,"string" error 2027c478bd9Sstevel@tonic-gate * -mt -D_REENTRANT 2037c478bd9Sstevel@tonic-gate * -native error 2047c478bd9Sstevel@tonic-gate * -nofstore error 2057c478bd9Sstevel@tonic-gate * -nolib -nodefaultlibs 2067c478bd9Sstevel@tonic-gate * -noqueue ignore 2077c478bd9Sstevel@tonic-gate * -norunpath ignore 208662492f5Ssherrym * -O -O1 (Check the man page to be certain) 2097c478bd9Sstevel@tonic-gate * -o <outputfile> pass-thru 2107c478bd9Sstevel@tonic-gate * -P -E -o filename.i (or error) 2117c478bd9Sstevel@tonic-gate * -PIC -fPIC (C++ only) 2127c478bd9Sstevel@tonic-gate * -p pass-thru 2137c478bd9Sstevel@tonic-gate * -pic -fpic (C++ only) 2147c478bd9Sstevel@tonic-gate * -Q[y|n] error 2157c478bd9Sstevel@tonic-gate * -qp -p 2167c478bd9Sstevel@tonic-gate * -R<dir[:dir]> pass-thru 2177c478bd9Sstevel@tonic-gate * -S pass-thru 2187c478bd9Sstevel@tonic-gate * -s -Wl,-s 219159cf8a6Swesolows * -t -Wl,-t 2207c478bd9Sstevel@tonic-gate * -U<name> pass-thru 2217c478bd9Sstevel@tonic-gate * -V --version 2227c478bd9Sstevel@tonic-gate * -v -Wall 2237c478bd9Sstevel@tonic-gate * -Wa,<arg> pass-thru 2247c478bd9Sstevel@tonic-gate * -Wp,<arg> pass-thru except -xc99=<a> 2257c478bd9Sstevel@tonic-gate * -Wl,<arg> pass-thru 2267c478bd9Sstevel@tonic-gate * -W{m,0,2,h,i,u> error/ignore 2277c478bd9Sstevel@tonic-gate * -Wu,-xmodel=kernel -ffreestanding -mcmodel=kernel -mno-red-zone 228d430274bSsherrym * -Wu,-save_args -msave-args 2297c478bd9Sstevel@tonic-gate * -w pass-thru 2307c478bd9Sstevel@tonic-gate * -Xa -std=iso9899:199409 or -ansi 2317c478bd9Sstevel@tonic-gate * -Xc -ansi -pedantic 2327c478bd9Sstevel@tonic-gate * -Xt error 2337c478bd9Sstevel@tonic-gate * -Xs -traditional -std=c89 2347c478bd9Sstevel@tonic-gate * -x386 -march=i386 (x86 only) 2357c478bd9Sstevel@tonic-gate * -x486 -march=i486 (x86 only) 2367c478bd9Sstevel@tonic-gate * -xarch=<a> table 237*02e56f3fSwesolows * -xbuiltin[=<b>] -fbuiltin (-fno-builtin otherwise) 2387c478bd9Sstevel@tonic-gate * -xCC ignore 2397c478bd9Sstevel@tonic-gate * -xchar_byte_order=<o> error 2407c478bd9Sstevel@tonic-gate * -xchip=<c> table 2417c478bd9Sstevel@tonic-gate * -xcode=<c> table 2428c1a3716Ssherrym * -xdebugformat=<format> ignore (always use dwarf-2 for gcc) 243159cf8a6Swesolows * -xcrossfile[=<n>] ignore 2447c478bd9Sstevel@tonic-gate * -xe error 2457c478bd9Sstevel@tonic-gate * -xF error 2467c478bd9Sstevel@tonic-gate * -xhelp=<f> error 2477c478bd9Sstevel@tonic-gate * -xildoff ignore 2487c478bd9Sstevel@tonic-gate * -xildon ignore 2497c478bd9Sstevel@tonic-gate * -xinline ignore 2507c478bd9Sstevel@tonic-gate * -xlibmieee error 2517c478bd9Sstevel@tonic-gate * -xlibmil error 2527c478bd9Sstevel@tonic-gate * -xlic_lib=sunperf error 2537c478bd9Sstevel@tonic-gate * -xM -M 2547c478bd9Sstevel@tonic-gate * -xM1 -MM 2557c478bd9Sstevel@tonic-gate * -xmaxopt=[...] error 2567c478bd9Sstevel@tonic-gate * -xnolib -nodefaultlibs 2577c478bd9Sstevel@tonic-gate * -xnolibmil error 2587c478bd9Sstevel@tonic-gate * -xO<n> -O<n> 2597c478bd9Sstevel@tonic-gate * -xP error 2607c478bd9Sstevel@tonic-gate * -xpentium -march=pentium (x86 only) 2617c478bd9Sstevel@tonic-gate * -xpg error 2627c478bd9Sstevel@tonic-gate * -xprofile=<p> error 2637c478bd9Sstevel@tonic-gate * -xregs=<r> table 2647c478bd9Sstevel@tonic-gate * -xs error 2657c478bd9Sstevel@tonic-gate * -xsb error 2667c478bd9Sstevel@tonic-gate * -xsbfast error 2677c478bd9Sstevel@tonic-gate * -xsfpconst error 2687c478bd9Sstevel@tonic-gate * -xspace ignore (-not -Os) 2697c478bd9Sstevel@tonic-gate * -xstrconst ignore 2707c478bd9Sstevel@tonic-gate * -xtarget=<t> table 2717c478bd9Sstevel@tonic-gate * -xtemp=<dir> error 2727c478bd9Sstevel@tonic-gate * -xtime error 2737c478bd9Sstevel@tonic-gate * -xtransition -Wtransition 2747c478bd9Sstevel@tonic-gate * -xtrigraphs=<yes|no> -trigraphs -notrigraphs 2757c478bd9Sstevel@tonic-gate * -xunroll=n error 2768c1a3716Ssherrym * -W0,-xdbggen=no%usedonly -fno-eliminate-unused-debug-symbols 2778c1a3716Ssherrym * -fno-eliminate-unused-debug-types 2787c478bd9Sstevel@tonic-gate * -Y<c>,<dir> error 2797c478bd9Sstevel@tonic-gate * -YA,<dir> error 2807c478bd9Sstevel@tonic-gate * -YI,<dir> -nostdinc -I<dir> 2817c478bd9Sstevel@tonic-gate * -YP,<dir> error 2827c478bd9Sstevel@tonic-gate * -YS,<dir> error 2837c478bd9Sstevel@tonic-gate */ 2847c478bd9Sstevel@tonic-gate 2857c478bd9Sstevel@tonic-gate #include <stdio.h> 2867c478bd9Sstevel@tonic-gate #include <sys/types.h> 2877c478bd9Sstevel@tonic-gate #include <unistd.h> 2887c478bd9Sstevel@tonic-gate #include <string.h> 2897c478bd9Sstevel@tonic-gate #include <stdlib.h> 2907c478bd9Sstevel@tonic-gate #include <ctype.h> 2917c478bd9Sstevel@tonic-gate #include <sys/utsname.h> 2927c478bd9Sstevel@tonic-gate #include <sys/param.h> 2937c478bd9Sstevel@tonic-gate #include <sys/isa_defs.h> 2947c478bd9Sstevel@tonic-gate 2957c478bd9Sstevel@tonic-gate static int echo = 1; 2967c478bd9Sstevel@tonic-gate static int newargc; 2977c478bd9Sstevel@tonic-gate static const char *progname; 2987c478bd9Sstevel@tonic-gate 2997c478bd9Sstevel@tonic-gate static char *default_cc_dir; 3007c478bd9Sstevel@tonic-gate static char *default_gcc_dir; 3017c478bd9Sstevel@tonic-gate 3027c478bd9Sstevel@tonic-gate static char *default_cplusplus_dir; 3037c478bd9Sstevel@tonic-gate static char *default_gplusplus_dir; 3047c478bd9Sstevel@tonic-gate 3057c478bd9Sstevel@tonic-gate static const char *xarch_tbl[] = { 3067c478bd9Sstevel@tonic-gate #if defined(__x86) 3077c478bd9Sstevel@tonic-gate "generic", NULL, 3087c478bd9Sstevel@tonic-gate "generic64", "-m64", "-mtune=opteron", NULL, 3097c478bd9Sstevel@tonic-gate "amd64", "-m64", "-mtune=opteron", NULL, 3107c478bd9Sstevel@tonic-gate "386", "-march=i386", NULL, 3117c478bd9Sstevel@tonic-gate "pentium_pro", "-march=pentiumpro", NULL, 3127c478bd9Sstevel@tonic-gate #elif defined(__sparc) 3137c478bd9Sstevel@tonic-gate "generic", "-m32", "-mcpu=v8", NULL, 3147c478bd9Sstevel@tonic-gate "generic64", "-m64", "-mcpu=v9", NULL, 3157c478bd9Sstevel@tonic-gate "v8", "-m32", "-mcpu=v8", "-mno-v8plus", NULL, 3167c478bd9Sstevel@tonic-gate "v8plus", "-m32", "-mcpu=v9", "-mv8plus", NULL, 3177c478bd9Sstevel@tonic-gate "v8plusa", "-m32", "-mcpu=ultrasparc", "-mv8plus", "-mvis", NULL, 3187c478bd9Sstevel@tonic-gate "v8plusb", "-m32", "-mcpu=ultrasparc3", "-mv8plus", "-mvis", NULL, 3197c478bd9Sstevel@tonic-gate "v9", "-m64", "-mcpu=v9", NULL, 3207c478bd9Sstevel@tonic-gate "v9a", "-m64", "-mcpu=ultrasparc", "-mvis", NULL, 3217c478bd9Sstevel@tonic-gate "v9b", "-m64", "-mcpu=ultrasparc3", "-mvis", NULL, 3227c478bd9Sstevel@tonic-gate #endif 3237c478bd9Sstevel@tonic-gate NULL, NULL 3247c478bd9Sstevel@tonic-gate }; 3257c478bd9Sstevel@tonic-gate 3267c478bd9Sstevel@tonic-gate static const char *xchip_tbl[] = { 3277c478bd9Sstevel@tonic-gate #if defined(__x86) 3287c478bd9Sstevel@tonic-gate "386", "-mtune=i386", NULL, 3297c478bd9Sstevel@tonic-gate "486", "-mtune=i486", NULL, 3307c478bd9Sstevel@tonic-gate "pentium", "-mtune=pentium", NULL, 3317c478bd9Sstevel@tonic-gate "pentium_pro", "-mtune=pentiumpro", NULL, 3327c478bd9Sstevel@tonic-gate #elif defined(__sparc) 3337c478bd9Sstevel@tonic-gate "super", "-mtune=supersparc", NULL, 3347c478bd9Sstevel@tonic-gate "ultra", "-mtune=ultrasparc", NULL, 3357c478bd9Sstevel@tonic-gate "ultra3", "-mtune=ultrasparc3", NULL, 3367c478bd9Sstevel@tonic-gate #endif 3377c478bd9Sstevel@tonic-gate NULL, NULL 3387c478bd9Sstevel@tonic-gate }; 3397c478bd9Sstevel@tonic-gate 3407c478bd9Sstevel@tonic-gate static const char *xcode_tbl[] = { 3417c478bd9Sstevel@tonic-gate #if defined(__sparc) 3427c478bd9Sstevel@tonic-gate "abs32", "-fno-pic", "-mcmodel=medlow", NULL, 3437c478bd9Sstevel@tonic-gate "abs44", "-fno-pic", "-mcmodel=medmid", NULL, 3447c478bd9Sstevel@tonic-gate "abs64", "-fno-pic", "-mcmodel=medany", NULL, 3457c478bd9Sstevel@tonic-gate "pic13", "-fpic", NULL, 3467c478bd9Sstevel@tonic-gate "pic32", "-fPIC", NULL, 3477c478bd9Sstevel@tonic-gate #endif 3487c478bd9Sstevel@tonic-gate NULL, NULL 3497c478bd9Sstevel@tonic-gate }; 3507c478bd9Sstevel@tonic-gate 3517c478bd9Sstevel@tonic-gate static const char *xtarget_tbl[] = { 3527c478bd9Sstevel@tonic-gate #if defined(__x86) 3537c478bd9Sstevel@tonic-gate "pentium_pro", "-march=pentiumpro", NULL, 3547c478bd9Sstevel@tonic-gate #endif /* __x86 */ 3557c478bd9Sstevel@tonic-gate NULL, NULL 3567c478bd9Sstevel@tonic-gate }; 3577c478bd9Sstevel@tonic-gate 3587c478bd9Sstevel@tonic-gate static const char *xregs_tbl[] = { 3597c478bd9Sstevel@tonic-gate #if defined(__sparc) 3607c478bd9Sstevel@tonic-gate "appl", "-mapp-regs", NULL, 3617c478bd9Sstevel@tonic-gate "no%appl", "-mno-app-regs", NULL, 3627c478bd9Sstevel@tonic-gate "float", "-mfpu", NULL, 3637c478bd9Sstevel@tonic-gate "no%float", "-mno-fpu", NULL, 3647c478bd9Sstevel@tonic-gate #endif /* __sparc */ 3657c478bd9Sstevel@tonic-gate NULL, NULL 3667c478bd9Sstevel@tonic-gate }; 3677c478bd9Sstevel@tonic-gate 3687c478bd9Sstevel@tonic-gate struct aelist { 3697c478bd9Sstevel@tonic-gate struct ae { 3707c478bd9Sstevel@tonic-gate struct ae *ae_next; 3717c478bd9Sstevel@tonic-gate char *ae_arg; 3727c478bd9Sstevel@tonic-gate } *ael_head, *ael_tail; 3737c478bd9Sstevel@tonic-gate }; 3747c478bd9Sstevel@tonic-gate 3757c478bd9Sstevel@tonic-gate static struct aelist * 3767c478bd9Sstevel@tonic-gate newael(void) 3777c478bd9Sstevel@tonic-gate { 3787c478bd9Sstevel@tonic-gate return (calloc(sizeof (struct aelist), 1)); 3797c478bd9Sstevel@tonic-gate } 3807c478bd9Sstevel@tonic-gate 3817c478bd9Sstevel@tonic-gate static void 3827c478bd9Sstevel@tonic-gate newae(struct aelist *ael, const char *arg) 3837c478bd9Sstevel@tonic-gate { 3847c478bd9Sstevel@tonic-gate struct ae *ae; 3857c478bd9Sstevel@tonic-gate 3867c478bd9Sstevel@tonic-gate ae = calloc(sizeof (*ae), 1); 3877c478bd9Sstevel@tonic-gate ae->ae_arg = strdup(arg); 3887c478bd9Sstevel@tonic-gate if (ael->ael_tail == NULL) 3897c478bd9Sstevel@tonic-gate ael->ael_head = ae; 3907c478bd9Sstevel@tonic-gate else 3917c478bd9Sstevel@tonic-gate ael->ael_tail->ae_next = ae; 3927c478bd9Sstevel@tonic-gate ael->ael_tail = ae; 3937c478bd9Sstevel@tonic-gate newargc++; 3947c478bd9Sstevel@tonic-gate } 3957c478bd9Sstevel@tonic-gate 3967c478bd9Sstevel@tonic-gate static void 3977c478bd9Sstevel@tonic-gate error(const char *arg) 3987c478bd9Sstevel@tonic-gate { 3997c478bd9Sstevel@tonic-gate (void) fprintf(stderr, 4007c478bd9Sstevel@tonic-gate "%s: mapping failed at or near arg '%s'\n", progname, arg); 4017c478bd9Sstevel@tonic-gate exit(2); 4027c478bd9Sstevel@tonic-gate } 4037c478bd9Sstevel@tonic-gate 4047c478bd9Sstevel@tonic-gate /* 4057c478bd9Sstevel@tonic-gate * Add the current favourite set of warnings to the gcc invocation. 4067c478bd9Sstevel@tonic-gate */ 4077c478bd9Sstevel@tonic-gate static void 4087c478bd9Sstevel@tonic-gate warnings(struct aelist *h) 4097c478bd9Sstevel@tonic-gate { 4107c478bd9Sstevel@tonic-gate static int warningsonce; 4117c478bd9Sstevel@tonic-gate 4127c478bd9Sstevel@tonic-gate if (warningsonce++) 4137c478bd9Sstevel@tonic-gate return; 4147c478bd9Sstevel@tonic-gate 4157c478bd9Sstevel@tonic-gate newae(h, "-Wall"); 4167c478bd9Sstevel@tonic-gate newae(h, "-Wno-unknown-pragmas"); 4177c478bd9Sstevel@tonic-gate newae(h, "-Wno-missing-braces"); 4187c478bd9Sstevel@tonic-gate newae(h, "-Wno-sign-compare"); 4197c478bd9Sstevel@tonic-gate newae(h, "-Wno-parentheses"); 4207c478bd9Sstevel@tonic-gate newae(h, "-Wno-uninitialized"); 4217c478bd9Sstevel@tonic-gate newae(h, "-Wno-implicit-function-declaration"); 4227c478bd9Sstevel@tonic-gate newae(h, "-Wno-unused"); 4237c478bd9Sstevel@tonic-gate newae(h, "-Wno-trigraphs"); 4247c478bd9Sstevel@tonic-gate newae(h, "-Wno-char-subscripts"); 4257c478bd9Sstevel@tonic-gate newae(h, "-Wno-switch"); 4267c478bd9Sstevel@tonic-gate } 4277c478bd9Sstevel@tonic-gate 4287c478bd9Sstevel@tonic-gate static void 4297c478bd9Sstevel@tonic-gate optim_disable(struct aelist *h, int level) 4307c478bd9Sstevel@tonic-gate { 4317c478bd9Sstevel@tonic-gate if (level >= 2) { 4327c478bd9Sstevel@tonic-gate newae(h, "-fno-strict-aliasing"); 4337c478bd9Sstevel@tonic-gate newae(h, "-fno-unit-at-a-time"); 4347c478bd9Sstevel@tonic-gate newae(h, "-fno-optimize-sibling-calls"); 4357c478bd9Sstevel@tonic-gate } 4367c478bd9Sstevel@tonic-gate } 4377c478bd9Sstevel@tonic-gate 4387c478bd9Sstevel@tonic-gate /* ARGSUSED */ 4397c478bd9Sstevel@tonic-gate static void 4407c478bd9Sstevel@tonic-gate Xamode(struct aelist *h) 4417c478bd9Sstevel@tonic-gate { 4427c478bd9Sstevel@tonic-gate } 4437c478bd9Sstevel@tonic-gate 4447c478bd9Sstevel@tonic-gate static void 4457c478bd9Sstevel@tonic-gate Xcmode(struct aelist *h) 4467c478bd9Sstevel@tonic-gate { 4477c478bd9Sstevel@tonic-gate static int xconce; 4487c478bd9Sstevel@tonic-gate 4497c478bd9Sstevel@tonic-gate if (xconce++) 4507c478bd9Sstevel@tonic-gate return; 4517c478bd9Sstevel@tonic-gate 4527c478bd9Sstevel@tonic-gate newae(h, "-ansi"); 4537c478bd9Sstevel@tonic-gate newae(h, "-pedantic-errors"); 4547c478bd9Sstevel@tonic-gate } 4557c478bd9Sstevel@tonic-gate 4567c478bd9Sstevel@tonic-gate static void 4577c478bd9Sstevel@tonic-gate Xsmode(struct aelist *h) 4587c478bd9Sstevel@tonic-gate { 4597c478bd9Sstevel@tonic-gate static int xsonce; 4607c478bd9Sstevel@tonic-gate 4617c478bd9Sstevel@tonic-gate if (xsonce++) 4627c478bd9Sstevel@tonic-gate return; 4637c478bd9Sstevel@tonic-gate 4647c478bd9Sstevel@tonic-gate newae(h, "-traditional"); 4657c478bd9Sstevel@tonic-gate newae(h, "-traditional-cpp"); 4667c478bd9Sstevel@tonic-gate } 4677c478bd9Sstevel@tonic-gate 4687c478bd9Sstevel@tonic-gate static void 4697c478bd9Sstevel@tonic-gate usage() 4707c478bd9Sstevel@tonic-gate { 4717c478bd9Sstevel@tonic-gate (void) fprintf(stderr, 4727c478bd9Sstevel@tonic-gate "usage: %s { -_cc | -_gcc | -_CC | -_g++ } [ -_compiler | ... ]\n", 4737c478bd9Sstevel@tonic-gate progname); 4747c478bd9Sstevel@tonic-gate exit(2); 4757c478bd9Sstevel@tonic-gate } 4767c478bd9Sstevel@tonic-gate 4777c478bd9Sstevel@tonic-gate static void 4787c478bd9Sstevel@tonic-gate xlate(struct aelist *h, const char *xarg, const char **table) 4797c478bd9Sstevel@tonic-gate { 4807c478bd9Sstevel@tonic-gate while (*table != NULL && strcmp(xarg, *table) != 0) { 4817c478bd9Sstevel@tonic-gate while (*table != NULL) 4827c478bd9Sstevel@tonic-gate table++; 4837c478bd9Sstevel@tonic-gate table++; 4847c478bd9Sstevel@tonic-gate } 4857c478bd9Sstevel@tonic-gate 4867c478bd9Sstevel@tonic-gate if (*table == NULL) 4877c478bd9Sstevel@tonic-gate error(xarg); 4887c478bd9Sstevel@tonic-gate 4897c478bd9Sstevel@tonic-gate table++; 4907c478bd9Sstevel@tonic-gate 4917c478bd9Sstevel@tonic-gate while (*table != NULL) { 4927c478bd9Sstevel@tonic-gate newae(h, *table); 4937c478bd9Sstevel@tonic-gate table++; 4947c478bd9Sstevel@tonic-gate } 4957c478bd9Sstevel@tonic-gate } 4967c478bd9Sstevel@tonic-gate 4977c478bd9Sstevel@tonic-gate static void 4987c478bd9Sstevel@tonic-gate do_gcc(const char *dir, const char *cmd, int argc, char **argv, 4997c478bd9Sstevel@tonic-gate struct aelist *h, int cplusplus) 5007c478bd9Sstevel@tonic-gate { 5017c478bd9Sstevel@tonic-gate int c; 5027c478bd9Sstevel@tonic-gate int pic = 0; 5037c478bd9Sstevel@tonic-gate int nolibc = 0; 5047c478bd9Sstevel@tonic-gate char *model = NULL; 5057c478bd9Sstevel@tonic-gate char *program; 5067c478bd9Sstevel@tonic-gate size_t len = strlen(dir) + strlen(cmd) + 2; 5077c478bd9Sstevel@tonic-gate 5087c478bd9Sstevel@tonic-gate program = malloc(len); 5097c478bd9Sstevel@tonic-gate (void) snprintf(program, len, "%s/%s", dir, cmd); 5107c478bd9Sstevel@tonic-gate 5117c478bd9Sstevel@tonic-gate /* 5127c478bd9Sstevel@tonic-gate * Basic defaults for ON compilation 5137c478bd9Sstevel@tonic-gate */ 5147c478bd9Sstevel@tonic-gate newae(h, program); 5157c478bd9Sstevel@tonic-gate 5167c478bd9Sstevel@tonic-gate newae(h, "-fident"); 5177c478bd9Sstevel@tonic-gate newae(h, "-finline"); 5187c478bd9Sstevel@tonic-gate newae(h, "-fno-inline-functions"); 5197c478bd9Sstevel@tonic-gate newae(h, "-fno-builtin"); 5207c478bd9Sstevel@tonic-gate newae(h, "-fno-asm"); 5217c478bd9Sstevel@tonic-gate newae(h, "-nodefaultlibs"); 5227c478bd9Sstevel@tonic-gate 523*02e56f3fSwesolows #if defined(__sparc) 524*02e56f3fSwesolows /* 525*02e56f3fSwesolows * The SPARC ldd and std instructions require 8-byte alignment of 526*02e56f3fSwesolows * their address operand. gcc correctly uses them only when the 527*02e56f3fSwesolows * ABI requires 8-byte alignment; unfortunately we have a number of 528*02e56f3fSwesolows * pieces of buggy code that doesn't conform to the ABI. This 529*02e56f3fSwesolows * flag makes gcc work more like Studio with -xmemalign=4. 530*02e56f3fSwesolows */ 531*02e56f3fSwesolows newae(h, "-mno-integer-ldd-std"); 532*02e56f3fSwesolows #endif 533*02e56f3fSwesolows 5347c478bd9Sstevel@tonic-gate /* 5357c478bd9Sstevel@tonic-gate * This is needed because 'u' is defined 5367c478bd9Sstevel@tonic-gate * under a conditional on 'sun'. Should 5377c478bd9Sstevel@tonic-gate * probably just remove the conditional, 5387c478bd9Sstevel@tonic-gate * or make it be dependent on '__sun'. 5397c478bd9Sstevel@tonic-gate * 5407c478bd9Sstevel@tonic-gate * -Dunix is also missing in enhanced ANSI mode 5417c478bd9Sstevel@tonic-gate */ 5427c478bd9Sstevel@tonic-gate newae(h, "-D__sun"); 5437c478bd9Sstevel@tonic-gate 5447c478bd9Sstevel@tonic-gate /* 5457c478bd9Sstevel@tonic-gate * Walk the argument list, translating as we go .. 5467c478bd9Sstevel@tonic-gate */ 5477c478bd9Sstevel@tonic-gate 5487c478bd9Sstevel@tonic-gate while (--argc > 0) { 5497c478bd9Sstevel@tonic-gate char *arg = *++argv; 5507c478bd9Sstevel@tonic-gate size_t arglen = strlen(arg); 5517c478bd9Sstevel@tonic-gate 5527c478bd9Sstevel@tonic-gate if (*arg == '-') 5537c478bd9Sstevel@tonic-gate arglen--; 5547c478bd9Sstevel@tonic-gate else { 5557c478bd9Sstevel@tonic-gate /* 5567c478bd9Sstevel@tonic-gate * Discard inline files that gcc doesn't grok 5577c478bd9Sstevel@tonic-gate */ 5587c478bd9Sstevel@tonic-gate if (arglen > 3 && 5597c478bd9Sstevel@tonic-gate strcmp(arg + arglen - 3, ".il") == 0) 5607c478bd9Sstevel@tonic-gate continue; 5617c478bd9Sstevel@tonic-gate 5627c478bd9Sstevel@tonic-gate /* 5637c478bd9Sstevel@tonic-gate * Otherwise, filenames, and partial arguments 5647c478bd9Sstevel@tonic-gate * are simply passed through for gcc to chew on. 5657c478bd9Sstevel@tonic-gate */ 5667c478bd9Sstevel@tonic-gate newae(h, arg); 5677c478bd9Sstevel@tonic-gate continue; 5687c478bd9Sstevel@tonic-gate } 5697c478bd9Sstevel@tonic-gate 5707c478bd9Sstevel@tonic-gate if (cplusplus) { 5717c478bd9Sstevel@tonic-gate if (strncmp(arg, "-compat=", 8) == 0) { 5727c478bd9Sstevel@tonic-gate /* discard -compat=4 and -compat=5 */ 5737c478bd9Sstevel@tonic-gate continue; 5747c478bd9Sstevel@tonic-gate } 5757c478bd9Sstevel@tonic-gate if (strcmp(arg, "-Qoption") == 0) { 5767c478bd9Sstevel@tonic-gate /* discard -Qoption and its two arguments */ 5777c478bd9Sstevel@tonic-gate if (argc < 3) 5787c478bd9Sstevel@tonic-gate error(arg); 5797c478bd9Sstevel@tonic-gate argc -= 2; 5807c478bd9Sstevel@tonic-gate argv += 2; 5817c478bd9Sstevel@tonic-gate continue; 5827c478bd9Sstevel@tonic-gate } 5837c478bd9Sstevel@tonic-gate if (strcmp(arg, "-xwe") == 0) { 5847c478bd9Sstevel@tonic-gate /* turn warnings into errors */ 5857c478bd9Sstevel@tonic-gate /* newae(h, "-Werror"); */ 5867c478bd9Sstevel@tonic-gate continue; 5877c478bd9Sstevel@tonic-gate } 5887c478bd9Sstevel@tonic-gate if (strcmp(arg, "-noex") == 0) { 5897c478bd9Sstevel@tonic-gate /* no exceptions */ 5907c478bd9Sstevel@tonic-gate newae(h, "-fno-exceptions"); 5917c478bd9Sstevel@tonic-gate /* no run time type descriptor information */ 5927c478bd9Sstevel@tonic-gate newae(h, "-fno-rtti"); 5937c478bd9Sstevel@tonic-gate continue; 5947c478bd9Sstevel@tonic-gate } 5957c478bd9Sstevel@tonic-gate if (strcmp(arg, "-pic") == 0) { 5967c478bd9Sstevel@tonic-gate newae(h, "-fpic"); 5977c478bd9Sstevel@tonic-gate pic = 1; 5987c478bd9Sstevel@tonic-gate continue; 5997c478bd9Sstevel@tonic-gate } 6007c478bd9Sstevel@tonic-gate if (strcmp(arg, "-PIC") == 0) { 6017c478bd9Sstevel@tonic-gate newae(h, "-fPIC"); 6027c478bd9Sstevel@tonic-gate pic = 1; 6037c478bd9Sstevel@tonic-gate continue; 6047c478bd9Sstevel@tonic-gate } 6057c478bd9Sstevel@tonic-gate if (strcmp(arg, "-norunpath") == 0) { 6067c478bd9Sstevel@tonic-gate /* gcc has no corresponding option */ 6077c478bd9Sstevel@tonic-gate continue; 6087c478bd9Sstevel@tonic-gate } 6097c478bd9Sstevel@tonic-gate if (strcmp(arg, "-nolib") == 0) { 6107c478bd9Sstevel@tonic-gate /* -nodefaultlibs is on by default */ 6117c478bd9Sstevel@tonic-gate nolibc = 1; 6127c478bd9Sstevel@tonic-gate continue; 6137c478bd9Sstevel@tonic-gate } 6147c478bd9Sstevel@tonic-gate #if defined(__sparc) 6157c478bd9Sstevel@tonic-gate if (strcmp(arg, "-cg92") == 0) { 6167c478bd9Sstevel@tonic-gate xlate(h, "v8", xarch_tbl); 6177c478bd9Sstevel@tonic-gate xlate(h, "super", xchip_tbl); 6187c478bd9Sstevel@tonic-gate continue; 6197c478bd9Sstevel@tonic-gate } 6207c478bd9Sstevel@tonic-gate #endif /* __sparc */ 6217c478bd9Sstevel@tonic-gate } 6227c478bd9Sstevel@tonic-gate 6237c478bd9Sstevel@tonic-gate switch ((c = arg[1])) { 6247c478bd9Sstevel@tonic-gate case '_': 6257c478bd9Sstevel@tonic-gate if (strcmp(arg, "-_noecho") == 0) 6267c478bd9Sstevel@tonic-gate echo = 0; 6277c478bd9Sstevel@tonic-gate else if (strncmp(arg, "-_cc=", 5) == 0 || 6287c478bd9Sstevel@tonic-gate strncmp(arg, "-_CC=", 5) == 0) 6297c478bd9Sstevel@tonic-gate /* EMPTY */; 6307c478bd9Sstevel@tonic-gate else if (strncmp(arg, "-_gcc=", 6) == 0 || 6317c478bd9Sstevel@tonic-gate strncmp(arg, "-_g++=", 6) == 0) 6327c478bd9Sstevel@tonic-gate newae(h, arg + 6); 6337c478bd9Sstevel@tonic-gate else if (strcmp(arg, "-_compiler") == 0) { 6347c478bd9Sstevel@tonic-gate (void) printf("%s\n", program); 6357c478bd9Sstevel@tonic-gate exit(0); 6367c478bd9Sstevel@tonic-gate } else 6377c478bd9Sstevel@tonic-gate error(arg); 6387c478bd9Sstevel@tonic-gate break; 6397c478bd9Sstevel@tonic-gate case '#': 6407c478bd9Sstevel@tonic-gate if (arglen == 1) { 6417c478bd9Sstevel@tonic-gate newae(h, "-v"); 6427c478bd9Sstevel@tonic-gate break; 6437c478bd9Sstevel@tonic-gate } 6447c478bd9Sstevel@tonic-gate error(arg); 6457c478bd9Sstevel@tonic-gate break; 6467c478bd9Sstevel@tonic-gate case 'g': 6477c478bd9Sstevel@tonic-gate newae(h, "-gdwarf-2"); 6487c478bd9Sstevel@tonic-gate break; 6497c478bd9Sstevel@tonic-gate case 'E': 6507c478bd9Sstevel@tonic-gate if (arglen == 1) { 6517c478bd9Sstevel@tonic-gate newae(h, "-xc"); 6527c478bd9Sstevel@tonic-gate newae(h, arg); 6537c478bd9Sstevel@tonic-gate nolibc = 1; 6547c478bd9Sstevel@tonic-gate break; 6557c478bd9Sstevel@tonic-gate } 6567c478bd9Sstevel@tonic-gate error(arg); 6577c478bd9Sstevel@tonic-gate break; 6587c478bd9Sstevel@tonic-gate case 'c': 6597c478bd9Sstevel@tonic-gate case 'S': 6607c478bd9Sstevel@tonic-gate if (arglen == 1) 6617c478bd9Sstevel@tonic-gate nolibc = 1; 6627c478bd9Sstevel@tonic-gate /* FALLTHROUGH */ 6637c478bd9Sstevel@tonic-gate case 'C': 6647c478bd9Sstevel@tonic-gate case 'H': 6657c478bd9Sstevel@tonic-gate case 'p': 6667c478bd9Sstevel@tonic-gate if (arglen == 1) { 6677c478bd9Sstevel@tonic-gate newae(h, arg); 6687c478bd9Sstevel@tonic-gate break; 6697c478bd9Sstevel@tonic-gate } 6707c478bd9Sstevel@tonic-gate error(arg); 6717c478bd9Sstevel@tonic-gate break; 6727c478bd9Sstevel@tonic-gate case 'A': 6737c478bd9Sstevel@tonic-gate case 'h': 6747c478bd9Sstevel@tonic-gate case 'I': 6757c478bd9Sstevel@tonic-gate case 'i': 6767c478bd9Sstevel@tonic-gate case 'L': 6777c478bd9Sstevel@tonic-gate case 'l': 6787c478bd9Sstevel@tonic-gate case 'o': 6797c478bd9Sstevel@tonic-gate case 'R': 6807c478bd9Sstevel@tonic-gate case 'U': 6817c478bd9Sstevel@tonic-gate case 'u': 6827c478bd9Sstevel@tonic-gate case 'w': 6837c478bd9Sstevel@tonic-gate newae(h, arg); 6847c478bd9Sstevel@tonic-gate break; 6857c478bd9Sstevel@tonic-gate case 'D': 6867c478bd9Sstevel@tonic-gate newae(h, arg); 6877c478bd9Sstevel@tonic-gate /* 6887c478bd9Sstevel@tonic-gate * XXX Clearly a hack ... do we need _KADB too? 6897c478bd9Sstevel@tonic-gate */ 6907c478bd9Sstevel@tonic-gate if (strcmp(arg, "-D_KERNEL") == 0 || 6917c478bd9Sstevel@tonic-gate strcmp(arg, "-D_BOOT") == 0) 6927c478bd9Sstevel@tonic-gate newae(h, "-ffreestanding"); 6937c478bd9Sstevel@tonic-gate break; 6947c478bd9Sstevel@tonic-gate case 'd': 6957c478bd9Sstevel@tonic-gate if (arglen == 2) { 6967c478bd9Sstevel@tonic-gate if (strcmp(arg, "-dy") == 0) { 6977c478bd9Sstevel@tonic-gate newae(h, "-Wl,-dy"); 6987c478bd9Sstevel@tonic-gate break; 6997c478bd9Sstevel@tonic-gate } 7007c478bd9Sstevel@tonic-gate if (strcmp(arg, "-dn") == 0) { 7017c478bd9Sstevel@tonic-gate newae(h, "-Wl,-dn"); 7027c478bd9Sstevel@tonic-gate break; 7037c478bd9Sstevel@tonic-gate } 7047c478bd9Sstevel@tonic-gate } 7057c478bd9Sstevel@tonic-gate if (strcmp(arg, "-dalign") == 0) { 7067c478bd9Sstevel@tonic-gate /* 7077c478bd9Sstevel@tonic-gate * -dalign forces alignment in some cases; 7087c478bd9Sstevel@tonic-gate * gcc does not need any flag to do this. 7097c478bd9Sstevel@tonic-gate */ 7107c478bd9Sstevel@tonic-gate break; 7117c478bd9Sstevel@tonic-gate } 7127c478bd9Sstevel@tonic-gate error(arg); 7137c478bd9Sstevel@tonic-gate break; 7147c478bd9Sstevel@tonic-gate case 'e': 7157c478bd9Sstevel@tonic-gate if (strcmp(arg, 7167c478bd9Sstevel@tonic-gate "-erroff=E_EMPTY_TRANSLATION_UNIT") == 0) { 7177c478bd9Sstevel@tonic-gate /* 7187c478bd9Sstevel@tonic-gate * Accept but ignore this -- gcc doesn't 7197c478bd9Sstevel@tonic-gate * seem to complain about empty translation 7207c478bd9Sstevel@tonic-gate * units 7217c478bd9Sstevel@tonic-gate */ 7227c478bd9Sstevel@tonic-gate break; 7237c478bd9Sstevel@tonic-gate } 7247c478bd9Sstevel@tonic-gate /* XX64 -- ignore all -erroff= options, for now */ 7257c478bd9Sstevel@tonic-gate if (strncmp(arg, "-erroff=", 8) == 0) 7267c478bd9Sstevel@tonic-gate break; 7277c478bd9Sstevel@tonic-gate if (strcmp(arg, "-errtags=yes") == 0) { 7287c478bd9Sstevel@tonic-gate warnings(h); 7297c478bd9Sstevel@tonic-gate break; 7307c478bd9Sstevel@tonic-gate } 7317c478bd9Sstevel@tonic-gate if (strcmp(arg, "-errwarn=%all") == 0) { 7327c478bd9Sstevel@tonic-gate newae(h, "-Werror"); 7337c478bd9Sstevel@tonic-gate break; 7347c478bd9Sstevel@tonic-gate } 7357c478bd9Sstevel@tonic-gate error(arg); 7367c478bd9Sstevel@tonic-gate break; 7377c478bd9Sstevel@tonic-gate case 'f': 7387c478bd9Sstevel@tonic-gate if (strcmp(arg, "-flags") == 0) { 7397c478bd9Sstevel@tonic-gate newae(h, "--help"); 7407c478bd9Sstevel@tonic-gate break; 7417c478bd9Sstevel@tonic-gate } 7427c478bd9Sstevel@tonic-gate error(arg); 7437c478bd9Sstevel@tonic-gate break; 7447c478bd9Sstevel@tonic-gate case 'G': 7457c478bd9Sstevel@tonic-gate newae(h, "-shared"); 7467c478bd9Sstevel@tonic-gate nolibc = 1; 7477c478bd9Sstevel@tonic-gate break; 7487c478bd9Sstevel@tonic-gate case 'k': 7497c478bd9Sstevel@tonic-gate if (strcmp(arg, "-keeptmp") == 0) { 7507c478bd9Sstevel@tonic-gate newae(h, "-save-temps"); 7517c478bd9Sstevel@tonic-gate break; 7527c478bd9Sstevel@tonic-gate } 7537c478bd9Sstevel@tonic-gate error(arg); 7547c478bd9Sstevel@tonic-gate break; 7557c478bd9Sstevel@tonic-gate case 'K': 7567c478bd9Sstevel@tonic-gate if (arglen == 1) { 7577c478bd9Sstevel@tonic-gate if ((arg = *++argv) == NULL || *arg == '\0') 7587c478bd9Sstevel@tonic-gate error("-K"); 7597c478bd9Sstevel@tonic-gate argc--; 7607c478bd9Sstevel@tonic-gate } else { 7617c478bd9Sstevel@tonic-gate arg += 2; 7627c478bd9Sstevel@tonic-gate } 7637c478bd9Sstevel@tonic-gate if (strcmp(arg, "pic") == 0) { 7647c478bd9Sstevel@tonic-gate newae(h, "-fpic"); 7657c478bd9Sstevel@tonic-gate pic = 1; 7667c478bd9Sstevel@tonic-gate break; 7677c478bd9Sstevel@tonic-gate } 7687c478bd9Sstevel@tonic-gate if (strcmp(arg, "PIC") == 0) { 7697c478bd9Sstevel@tonic-gate newae(h, "-fPIC"); 7707c478bd9Sstevel@tonic-gate pic = 1; 7717c478bd9Sstevel@tonic-gate break; 7727c478bd9Sstevel@tonic-gate } 7737c478bd9Sstevel@tonic-gate error("-K"); 7747c478bd9Sstevel@tonic-gate break; 7757c478bd9Sstevel@tonic-gate case 'm': 7767c478bd9Sstevel@tonic-gate if (strcmp(arg, "-mt") == 0) { 7777c478bd9Sstevel@tonic-gate newae(h, "-D_REENTRANT"); 7787c478bd9Sstevel@tonic-gate break; 7797c478bd9Sstevel@tonic-gate } 7807c478bd9Sstevel@tonic-gate error(arg); 7817c478bd9Sstevel@tonic-gate break; 7827c478bd9Sstevel@tonic-gate case 'B': /* linker options */ 7837c478bd9Sstevel@tonic-gate case 'M': 7847c478bd9Sstevel@tonic-gate case 'z': 7857c478bd9Sstevel@tonic-gate { 7867c478bd9Sstevel@tonic-gate char *opt; 7877c478bd9Sstevel@tonic-gate size_t len; 7887c478bd9Sstevel@tonic-gate char *s; 7897c478bd9Sstevel@tonic-gate 7907c478bd9Sstevel@tonic-gate if (arglen == 1) { 7917c478bd9Sstevel@tonic-gate opt = *++argv; 7927c478bd9Sstevel@tonic-gate if (opt == NULL || *opt == '\0') 7937c478bd9Sstevel@tonic-gate error(arg); 7947c478bd9Sstevel@tonic-gate argc--; 7957c478bd9Sstevel@tonic-gate } else { 7967c478bd9Sstevel@tonic-gate opt = arg + 2; 7977c478bd9Sstevel@tonic-gate } 7987c478bd9Sstevel@tonic-gate len = strlen(opt) + 7; 7997c478bd9Sstevel@tonic-gate s = malloc(len); 8007c478bd9Sstevel@tonic-gate (void) snprintf(s, len, "-Wl,-%c%s", c, opt); 8017c478bd9Sstevel@tonic-gate newae(h, s); 8027c478bd9Sstevel@tonic-gate free(s); 8037c478bd9Sstevel@tonic-gate } 8047c478bd9Sstevel@tonic-gate break; 8057c478bd9Sstevel@tonic-gate case 'n': 8067c478bd9Sstevel@tonic-gate if (strcmp(arg, "-noqueue") == 0) { 8077c478bd9Sstevel@tonic-gate /* 8087c478bd9Sstevel@tonic-gate * Horrid license server stuff - n/a 8097c478bd9Sstevel@tonic-gate */ 8107c478bd9Sstevel@tonic-gate break; 8117c478bd9Sstevel@tonic-gate } 8127c478bd9Sstevel@tonic-gate error(arg); 8137c478bd9Sstevel@tonic-gate break; 8147c478bd9Sstevel@tonic-gate case 'O': 8157c478bd9Sstevel@tonic-gate if (arglen == 1) { 8167c478bd9Sstevel@tonic-gate newae(h, "-O"); 8177c478bd9Sstevel@tonic-gate break; 8187c478bd9Sstevel@tonic-gate } 8197c478bd9Sstevel@tonic-gate error(arg); 8207c478bd9Sstevel@tonic-gate break; 8217c478bd9Sstevel@tonic-gate case 'P': 8227c478bd9Sstevel@tonic-gate /* 8237c478bd9Sstevel@tonic-gate * We could do '-E -o filename.i', but that's hard, 8247c478bd9Sstevel@tonic-gate * and we don't need it for the case that's triggering 8257c478bd9Sstevel@tonic-gate * this addition. We'll require the user to specify 8267c478bd9Sstevel@tonic-gate * -o in the Makefile. If they don't they'll find out 8277c478bd9Sstevel@tonic-gate * in a hurry. 8287c478bd9Sstevel@tonic-gate */ 8297c478bd9Sstevel@tonic-gate newae(h, "-E"); 8307c478bd9Sstevel@tonic-gate nolibc = 1; 8317c478bd9Sstevel@tonic-gate break; 8327c478bd9Sstevel@tonic-gate case 'q': 8337c478bd9Sstevel@tonic-gate if (strcmp(arg, "-qp") == 0) { 8347c478bd9Sstevel@tonic-gate newae(h, "-p"); 8357c478bd9Sstevel@tonic-gate break; 8367c478bd9Sstevel@tonic-gate } 8377c478bd9Sstevel@tonic-gate error(arg); 8387c478bd9Sstevel@tonic-gate break; 8397c478bd9Sstevel@tonic-gate case 's': 8407c478bd9Sstevel@tonic-gate if (arglen == 1) { 8417c478bd9Sstevel@tonic-gate newae(h, "-Wl,-s"); 8427c478bd9Sstevel@tonic-gate break; 8437c478bd9Sstevel@tonic-gate } 8447c478bd9Sstevel@tonic-gate error(arg); 8457c478bd9Sstevel@tonic-gate break; 846159cf8a6Swesolows case 't': 847159cf8a6Swesolows if (arglen == 1) { 848159cf8a6Swesolows newae(h, "-Wl,-t"); 849159cf8a6Swesolows break; 850159cf8a6Swesolows } 851159cf8a6Swesolows error(arg); 852159cf8a6Swesolows break; 8537c478bd9Sstevel@tonic-gate case 'V': 8547c478bd9Sstevel@tonic-gate if (arglen == 1) { 8557c478bd9Sstevel@tonic-gate echo = 0; 8567c478bd9Sstevel@tonic-gate newae(h, "--version"); 8577c478bd9Sstevel@tonic-gate break; 8587c478bd9Sstevel@tonic-gate } 8597c478bd9Sstevel@tonic-gate error(arg); 8607c478bd9Sstevel@tonic-gate break; 8617c478bd9Sstevel@tonic-gate case 'v': 8627c478bd9Sstevel@tonic-gate if (arglen == 1) { 8637c478bd9Sstevel@tonic-gate warnings(h); 8647c478bd9Sstevel@tonic-gate break; 8657c478bd9Sstevel@tonic-gate } 8667c478bd9Sstevel@tonic-gate error(arg); 8677c478bd9Sstevel@tonic-gate break; 8687c478bd9Sstevel@tonic-gate case 'W': 8697c478bd9Sstevel@tonic-gate if (strncmp(arg, "-Wp,-xc99", 9) == 0) { 8707c478bd9Sstevel@tonic-gate /* 8717c478bd9Sstevel@tonic-gate * gcc's preprocessor will accept c99 8727c478bd9Sstevel@tonic-gate * regardless, so accept and ignore. 8737c478bd9Sstevel@tonic-gate */ 8747c478bd9Sstevel@tonic-gate break; 8757c478bd9Sstevel@tonic-gate } 8767c478bd9Sstevel@tonic-gate if (strncmp(arg, "-Wa,", 4) == 0 || 8777c478bd9Sstevel@tonic-gate strncmp(arg, "-Wp,", 4) == 0 || 8787c478bd9Sstevel@tonic-gate strncmp(arg, "-Wl,", 4) == 0) { 8797c478bd9Sstevel@tonic-gate newae(h, arg); 8807c478bd9Sstevel@tonic-gate break; 8817c478bd9Sstevel@tonic-gate } 8827c478bd9Sstevel@tonic-gate if (strcmp(arg, "-W0,-xc99=pragma") == 0) { 8837c478bd9Sstevel@tonic-gate /* (undocumented) enables _Pragma */ 8847c478bd9Sstevel@tonic-gate break; 8857c478bd9Sstevel@tonic-gate } 8867c478bd9Sstevel@tonic-gate if (strcmp(arg, "-W0,-xc99=%none") == 0) { 8877c478bd9Sstevel@tonic-gate /* 8887c478bd9Sstevel@tonic-gate * This is a polite way of saying 8897c478bd9Sstevel@tonic-gate * "no c99 constructs allowed!" 8907c478bd9Sstevel@tonic-gate * For now, just accept and ignore this. 8917c478bd9Sstevel@tonic-gate */ 8927c478bd9Sstevel@tonic-gate break; 8937c478bd9Sstevel@tonic-gate } 8947c478bd9Sstevel@tonic-gate if (strcmp(arg, "-W0,-noglobal") == 0) { 8957c478bd9Sstevel@tonic-gate /* 8967c478bd9Sstevel@tonic-gate * gcc doesn't prefix local symbols 8977c478bd9Sstevel@tonic-gate * in debug mode, so this is not needed. 8987c478bd9Sstevel@tonic-gate */ 8997c478bd9Sstevel@tonic-gate break; 9007c478bd9Sstevel@tonic-gate } 9017c478bd9Sstevel@tonic-gate if (strcmp(arg, "-W0,-Lt") == 0) { 9027c478bd9Sstevel@tonic-gate /* 9037c478bd9Sstevel@tonic-gate * Generate tests at the top of loops. 9047c478bd9Sstevel@tonic-gate * There is no direct gcc equivalent, ignore. 9057c478bd9Sstevel@tonic-gate */ 9067c478bd9Sstevel@tonic-gate break; 9077c478bd9Sstevel@tonic-gate } 9088c1a3716Ssherrym if (strcmp(arg, "-W0,-xdbggen=no%usedonly") == 0) { 9098c1a3716Ssherrym newae(h, "-fno-eliminate-unused-debug-symbols"); 9108c1a3716Ssherrym newae(h, "-fno-eliminate-unused-debug-types"); 9118c1a3716Ssherrym break; 9128c1a3716Ssherrym } 9137c478bd9Sstevel@tonic-gate if (strcmp(arg, "-W2,-Rcond_elim") == 0) { 9147c478bd9Sstevel@tonic-gate /* 9157c478bd9Sstevel@tonic-gate * Elimination and expansion of conditionals; 9167c478bd9Sstevel@tonic-gate * gcc has no direct equivalent. 9177c478bd9Sstevel@tonic-gate */ 9187c478bd9Sstevel@tonic-gate break; 9197c478bd9Sstevel@tonic-gate } 9207c478bd9Sstevel@tonic-gate if (strcmp(arg, "-Wd,-xsafe=unboundsym") == 0) { 9217c478bd9Sstevel@tonic-gate /* 9227c478bd9Sstevel@tonic-gate * Prevents optimizing away checks for 9237c478bd9Sstevel@tonic-gate * unbound weak symbol addresses. gcc does 9247c478bd9Sstevel@tonic-gate * not do this, so it's not needed. 9257c478bd9Sstevel@tonic-gate */ 9267c478bd9Sstevel@tonic-gate break; 9277c478bd9Sstevel@tonic-gate } 9287c478bd9Sstevel@tonic-gate if (strncmp(arg, "-Wc,-xcode=", 11) == 0) { 9297c478bd9Sstevel@tonic-gate xlate(h, arg + 11, xcode_tbl); 9307c478bd9Sstevel@tonic-gate if (strncmp(arg + 11, "pic", 3) == 0) 9317c478bd9Sstevel@tonic-gate pic = 1; 9327c478bd9Sstevel@tonic-gate break; 9337c478bd9Sstevel@tonic-gate } 9347c478bd9Sstevel@tonic-gate if (strncmp(arg, "-Wc,-Qiselect", 13) == 0) { 9357c478bd9Sstevel@tonic-gate /* 9367c478bd9Sstevel@tonic-gate * Prevents insertion of register symbols. 9377c478bd9Sstevel@tonic-gate * gcc doesn't do this, so ignore it. 9387c478bd9Sstevel@tonic-gate */ 9397c478bd9Sstevel@tonic-gate break; 9407c478bd9Sstevel@tonic-gate } 9417c478bd9Sstevel@tonic-gate #if defined(__x86) 9427c478bd9Sstevel@tonic-gate if (strcmp(arg, "-Wu,-no_got_reloc") == 0) { 943*02e56f3fSwesolows newae(h, "-fno-jump-tables"); 944*02e56f3fSwesolows newae(h, "-fno-constant-pools"); 9457c478bd9Sstevel@tonic-gate break; 9467c478bd9Sstevel@tonic-gate } 9477c478bd9Sstevel@tonic-gate if (strcmp(arg, "-Wu,-xmodel=kernel") == 0) { 9487c478bd9Sstevel@tonic-gate newae(h, "-ffreestanding"); 9497c478bd9Sstevel@tonic-gate newae(h, "-mno-red-zone"); 9507c478bd9Sstevel@tonic-gate model = "-mcmodel=kernel"; 9517c478bd9Sstevel@tonic-gate nolibc = 1; 9527c478bd9Sstevel@tonic-gate break; 9537c478bd9Sstevel@tonic-gate } 954d430274bSsherrym if (strcmp(arg, "-Wu,-save_args") == 0) { 955d430274bSsherrym newae(h, "-msave-args"); 956d430274bSsherrym break; 957d430274bSsherrym } 9587c478bd9Sstevel@tonic-gate #endif /* __x86 */ 9597c478bd9Sstevel@tonic-gate error(arg); 9607c478bd9Sstevel@tonic-gate break; 9617c478bd9Sstevel@tonic-gate case 'X': 9627c478bd9Sstevel@tonic-gate if (strcmp(arg, "-Xa") == 0 || 9637c478bd9Sstevel@tonic-gate strcmp(arg, "-Xt") == 0) { 9647c478bd9Sstevel@tonic-gate Xamode(h); 9657c478bd9Sstevel@tonic-gate break; 9667c478bd9Sstevel@tonic-gate } 9677c478bd9Sstevel@tonic-gate if (strcmp(arg, "-Xc") == 0) { 9687c478bd9Sstevel@tonic-gate Xcmode(h); 9697c478bd9Sstevel@tonic-gate break; 9707c478bd9Sstevel@tonic-gate } 9717c478bd9Sstevel@tonic-gate if (strcmp(arg, "-Xs") == 0) { 9727c478bd9Sstevel@tonic-gate Xsmode(h); 9737c478bd9Sstevel@tonic-gate break; 9747c478bd9Sstevel@tonic-gate } 9757c478bd9Sstevel@tonic-gate error(arg); 9767c478bd9Sstevel@tonic-gate break; 9777c478bd9Sstevel@tonic-gate case 'x': 9787c478bd9Sstevel@tonic-gate if (arglen == 1) 9797c478bd9Sstevel@tonic-gate error(arg); 9807c478bd9Sstevel@tonic-gate switch (arg[2]) { 9817c478bd9Sstevel@tonic-gate #if defined(__x86) 9827c478bd9Sstevel@tonic-gate case '3': 9837c478bd9Sstevel@tonic-gate if (strcmp(arg, "-x386") == 0) { 9847c478bd9Sstevel@tonic-gate newae(h, "-march=i386"); 9857c478bd9Sstevel@tonic-gate break; 9867c478bd9Sstevel@tonic-gate } 9877c478bd9Sstevel@tonic-gate error(arg); 9887c478bd9Sstevel@tonic-gate break; 9897c478bd9Sstevel@tonic-gate case '4': 9907c478bd9Sstevel@tonic-gate if (strcmp(arg, "-x486") == 0) { 9917c478bd9Sstevel@tonic-gate newae(h, "-march=i486"); 9927c478bd9Sstevel@tonic-gate break; 9937c478bd9Sstevel@tonic-gate } 9947c478bd9Sstevel@tonic-gate error(arg); 9957c478bd9Sstevel@tonic-gate break; 9967c478bd9Sstevel@tonic-gate #endif /* __x86 */ 9977c478bd9Sstevel@tonic-gate case 'a': 9987c478bd9Sstevel@tonic-gate if (strncmp(arg, "-xarch=", 7) == 0) { 9997c478bd9Sstevel@tonic-gate xlate(h, arg + 7, xarch_tbl); 10007c478bd9Sstevel@tonic-gate break; 10017c478bd9Sstevel@tonic-gate } 10027c478bd9Sstevel@tonic-gate error(arg); 10037c478bd9Sstevel@tonic-gate break; 1004*02e56f3fSwesolows case 'b': 1005*02e56f3fSwesolows if (strncmp(arg, "-xbuiltin=", 10) == 0) { 1006*02e56f3fSwesolows if (strcmp(arg + 10, "%all")) 1007*02e56f3fSwesolows newae(h, "-fbuiltin"); 1008*02e56f3fSwesolows break; 1009*02e56f3fSwesolows } 1010*02e56f3fSwesolows error(arg); 1011*02e56f3fSwesolows break; 10127c478bd9Sstevel@tonic-gate case 'C': 10137c478bd9Sstevel@tonic-gate /* Accept C++ style comments -- ignore */ 10147c478bd9Sstevel@tonic-gate if (strcmp(arg, "-xCC") == 0) 10157c478bd9Sstevel@tonic-gate break; 10167c478bd9Sstevel@tonic-gate error(arg); 10177c478bd9Sstevel@tonic-gate break; 10187c478bd9Sstevel@tonic-gate case 'c': 10197c478bd9Sstevel@tonic-gate if (strncmp(arg, "-xc99=%all", 10) == 0) { 10207c478bd9Sstevel@tonic-gate newae(h, "-std=gnu99"); 10217c478bd9Sstevel@tonic-gate break; 10227c478bd9Sstevel@tonic-gate } 10237c478bd9Sstevel@tonic-gate if (strncmp(arg, "-xc99=%none", 11) == 0) { 10247c478bd9Sstevel@tonic-gate newae(h, "-std=gnu89"); 10257c478bd9Sstevel@tonic-gate break; 10267c478bd9Sstevel@tonic-gate } 10277c478bd9Sstevel@tonic-gate if (strncmp(arg, "-xchip=", 7) == 0) { 10287c478bd9Sstevel@tonic-gate xlate(h, arg + 7, xchip_tbl); 10297c478bd9Sstevel@tonic-gate break; 10307c478bd9Sstevel@tonic-gate } 10317c478bd9Sstevel@tonic-gate if (strncmp(arg, "-xcode=", 7) == 0) { 10327c478bd9Sstevel@tonic-gate xlate(h, arg + 7, xcode_tbl); 10337c478bd9Sstevel@tonic-gate if (strncmp(arg + 7, "pic", 3) == 0) 10347c478bd9Sstevel@tonic-gate pic = 1; 10357c478bd9Sstevel@tonic-gate break; 10367c478bd9Sstevel@tonic-gate } 10377c478bd9Sstevel@tonic-gate if (strncmp(arg, "-xcache=", 8) == 0) 10387c478bd9Sstevel@tonic-gate break; 1039159cf8a6Swesolows if (strncmp(arg, "-xcrossfile", 11) == 0) 1040159cf8a6Swesolows break; 10417c478bd9Sstevel@tonic-gate error(arg); 10427c478bd9Sstevel@tonic-gate break; 10437c478bd9Sstevel@tonic-gate case 'd': 10447c478bd9Sstevel@tonic-gate if (strcmp(arg, "-xdepend") == 0) 10457c478bd9Sstevel@tonic-gate break; 10468c1a3716Ssherrym if (strncmp(arg, "-xdebugformat=", 14) == 0) 10478c1a3716Ssherrym break; 10487c478bd9Sstevel@tonic-gate error(arg); 10497c478bd9Sstevel@tonic-gate break; 10507c478bd9Sstevel@tonic-gate case 'F': 10517c478bd9Sstevel@tonic-gate /* compile for mapfile reordering -- ignore */ 10527c478bd9Sstevel@tonic-gate if (strcmp(arg, "-xF") == 0) 10537c478bd9Sstevel@tonic-gate break; 10547c478bd9Sstevel@tonic-gate error(arg); 10557c478bd9Sstevel@tonic-gate break; 10567c478bd9Sstevel@tonic-gate case 'i': 10577c478bd9Sstevel@tonic-gate if (strncmp(arg, "-xinline", 8) == 0) 10587c478bd9Sstevel@tonic-gate /* No inlining; ignore */ 10597c478bd9Sstevel@tonic-gate break; 10607c478bd9Sstevel@tonic-gate if (strcmp(arg, "-xildon") == 0 || 10617c478bd9Sstevel@tonic-gate strcmp(arg, "-xildoff") == 0) 10627c478bd9Sstevel@tonic-gate /* No incremental linking; ignore */ 10637c478bd9Sstevel@tonic-gate break; 10647c478bd9Sstevel@tonic-gate error(arg); 10657c478bd9Sstevel@tonic-gate break; 10667c478bd9Sstevel@tonic-gate case 'M': 10677c478bd9Sstevel@tonic-gate if (strcmp(arg, "-xM") == 0) { 10687c478bd9Sstevel@tonic-gate newae(h, "-M"); 10697c478bd9Sstevel@tonic-gate break; 10707c478bd9Sstevel@tonic-gate } 10717c478bd9Sstevel@tonic-gate if (strcmp(arg, "-xM1") == 0) { 10727c478bd9Sstevel@tonic-gate newae(h, "-MM"); 10737c478bd9Sstevel@tonic-gate break; 10747c478bd9Sstevel@tonic-gate } 10757c478bd9Sstevel@tonic-gate error(arg); 10767c478bd9Sstevel@tonic-gate break; 10777c478bd9Sstevel@tonic-gate case 'n': 10787c478bd9Sstevel@tonic-gate if (strcmp(arg, "-xnolib") == 0) { 10797c478bd9Sstevel@tonic-gate nolibc = 1; 10807c478bd9Sstevel@tonic-gate break; 10817c478bd9Sstevel@tonic-gate } 10827c478bd9Sstevel@tonic-gate error(arg); 10837c478bd9Sstevel@tonic-gate break; 10847c478bd9Sstevel@tonic-gate case 'O': 10857c478bd9Sstevel@tonic-gate if (strncmp(arg, "-xO", 3) == 0) { 10867c478bd9Sstevel@tonic-gate size_t len = strlen(arg); 10877c478bd9Sstevel@tonic-gate char *s = malloc(len); 10887c478bd9Sstevel@tonic-gate int c = *(arg + 3); 10897c478bd9Sstevel@tonic-gate int level; 10907c478bd9Sstevel@tonic-gate 10917c478bd9Sstevel@tonic-gate if (len != 4 || !isdigit(c)) 10927c478bd9Sstevel@tonic-gate error(arg); 10937c478bd9Sstevel@tonic-gate 10947c478bd9Sstevel@tonic-gate level = atoi(arg + 3); 10957c478bd9Sstevel@tonic-gate if (level > 5) 10967c478bd9Sstevel@tonic-gate error(arg); 10977c478bd9Sstevel@tonic-gate if (level >= 2) { 10987c478bd9Sstevel@tonic-gate /* 10997c478bd9Sstevel@tonic-gate * For gcc-3.4.x at -O2 we 11007c478bd9Sstevel@tonic-gate * need to disable optimizations 11017c478bd9Sstevel@tonic-gate * that break ON. 11027c478bd9Sstevel@tonic-gate */ 11037c478bd9Sstevel@tonic-gate optim_disable(h, level); 11047c478bd9Sstevel@tonic-gate /* 11057c478bd9Sstevel@tonic-gate * limit -xO3 to -O2 as well. 11067c478bd9Sstevel@tonic-gate */ 11077c478bd9Sstevel@tonic-gate level = 2; 11087c478bd9Sstevel@tonic-gate } 11097c478bd9Sstevel@tonic-gate (void) snprintf(s, len, "-O%d", level); 11107c478bd9Sstevel@tonic-gate newae(h, s); 11117c478bd9Sstevel@tonic-gate free(s); 11127c478bd9Sstevel@tonic-gate break; 11137c478bd9Sstevel@tonic-gate } 11147c478bd9Sstevel@tonic-gate error(arg); 11157c478bd9Sstevel@tonic-gate break; 11167c478bd9Sstevel@tonic-gate case 'p': 11177c478bd9Sstevel@tonic-gate if (strcmp(arg, "-xpentium") == 0) { 11187c478bd9Sstevel@tonic-gate newae(h, "-march=pentium"); 11197c478bd9Sstevel@tonic-gate break; 11207c478bd9Sstevel@tonic-gate } 11217c478bd9Sstevel@tonic-gate if (strcmp(arg, "-xpg") == 0) { 11227c478bd9Sstevel@tonic-gate newae(h, "-pg"); 11237c478bd9Sstevel@tonic-gate break; 11247c478bd9Sstevel@tonic-gate } 11257c478bd9Sstevel@tonic-gate error(arg); 11267c478bd9Sstevel@tonic-gate break; 11277c478bd9Sstevel@tonic-gate case 'r': 11287c478bd9Sstevel@tonic-gate if (strncmp(arg, "-xregs=", 7) == 0) { 11297c478bd9Sstevel@tonic-gate xlate(h, arg + 7, xregs_tbl); 11307c478bd9Sstevel@tonic-gate break; 11317c478bd9Sstevel@tonic-gate } 11327c478bd9Sstevel@tonic-gate error(arg); 11337c478bd9Sstevel@tonic-gate break; 11347c478bd9Sstevel@tonic-gate case 's': 11357c478bd9Sstevel@tonic-gate if (strcmp(arg, "-xs") == 0 || 11367c478bd9Sstevel@tonic-gate strcmp(arg, "-xspace") == 0 || 11377c478bd9Sstevel@tonic-gate strcmp(arg, "-xstrconst") == 0) 11387c478bd9Sstevel@tonic-gate break; 11397c478bd9Sstevel@tonic-gate error(arg); 11407c478bd9Sstevel@tonic-gate break; 11417c478bd9Sstevel@tonic-gate case 't': 11427c478bd9Sstevel@tonic-gate if (strcmp(arg, "-xtransition") == 0) { 11437c478bd9Sstevel@tonic-gate newae(h, "-Wtransition"); 11447c478bd9Sstevel@tonic-gate break; 11457c478bd9Sstevel@tonic-gate } 11467c478bd9Sstevel@tonic-gate if (strcmp(arg, "-xtrigraphs=yes") == 0) { 11477c478bd9Sstevel@tonic-gate newae(h, "-trigraphs"); 11487c478bd9Sstevel@tonic-gate break; 11497c478bd9Sstevel@tonic-gate } 11507c478bd9Sstevel@tonic-gate if (strcmp(arg, "-xtrigraphs=no") == 0) { 11517c478bd9Sstevel@tonic-gate newae(h, "-notrigraphs"); 11527c478bd9Sstevel@tonic-gate break; 11537c478bd9Sstevel@tonic-gate } 11547c478bd9Sstevel@tonic-gate if (strncmp(arg, "-xtarget=", 9) == 0) { 11557c478bd9Sstevel@tonic-gate xlate(h, arg + 9, xtarget_tbl); 11567c478bd9Sstevel@tonic-gate break; 11577c478bd9Sstevel@tonic-gate } 11587c478bd9Sstevel@tonic-gate error(arg); 11597c478bd9Sstevel@tonic-gate break; 11607c478bd9Sstevel@tonic-gate case 'e': 11617c478bd9Sstevel@tonic-gate case 'h': 11627c478bd9Sstevel@tonic-gate case 'l': 11637c478bd9Sstevel@tonic-gate default: 11647c478bd9Sstevel@tonic-gate error(arg); 11657c478bd9Sstevel@tonic-gate break; 11667c478bd9Sstevel@tonic-gate } 11677c478bd9Sstevel@tonic-gate break; 11687c478bd9Sstevel@tonic-gate case 'Y': 11697c478bd9Sstevel@tonic-gate if (arglen == 1) { 11707c478bd9Sstevel@tonic-gate if ((arg = *++argv) == NULL || *arg == '\0') 11717c478bd9Sstevel@tonic-gate error("-Y"); 11727c478bd9Sstevel@tonic-gate argc--; 11737c478bd9Sstevel@tonic-gate arglen = strlen(arg + 1); 11747c478bd9Sstevel@tonic-gate } else { 11757c478bd9Sstevel@tonic-gate arg += 2; 11767c478bd9Sstevel@tonic-gate } 11777c478bd9Sstevel@tonic-gate /* Just ignore -YS,... for now */ 11787c478bd9Sstevel@tonic-gate if (strncmp(arg, "S,", 2) == 0) 11797c478bd9Sstevel@tonic-gate break; 11807c478bd9Sstevel@tonic-gate if (strncmp(arg, "l,", 2) == 0) { 11817c478bd9Sstevel@tonic-gate char *s = strdup(arg); 11827c478bd9Sstevel@tonic-gate s[0] = '-'; 11837c478bd9Sstevel@tonic-gate s[1] = 'B'; 11847c478bd9Sstevel@tonic-gate newae(h, s); 11857c478bd9Sstevel@tonic-gate free(s); 11867c478bd9Sstevel@tonic-gate break; 11877c478bd9Sstevel@tonic-gate } 11887c478bd9Sstevel@tonic-gate if (strncmp(arg, "I,", 2) == 0) { 11897c478bd9Sstevel@tonic-gate char *s = strdup(arg); 11907c478bd9Sstevel@tonic-gate s[0] = '-'; 11917c478bd9Sstevel@tonic-gate s[1] = 'I'; 11927c478bd9Sstevel@tonic-gate newae(h, "-nostdinc"); 11937c478bd9Sstevel@tonic-gate newae(h, s); 11947c478bd9Sstevel@tonic-gate free(s); 11957c478bd9Sstevel@tonic-gate break; 11967c478bd9Sstevel@tonic-gate } 11977c478bd9Sstevel@tonic-gate error(arg); 11987c478bd9Sstevel@tonic-gate break; 11997c478bd9Sstevel@tonic-gate case 'Q': 12007c478bd9Sstevel@tonic-gate /* 12017c478bd9Sstevel@tonic-gate * We could map -Qy into -Wl,-Qy etc. 12027c478bd9Sstevel@tonic-gate */ 12037c478bd9Sstevel@tonic-gate default: 12047c478bd9Sstevel@tonic-gate error(arg); 12057c478bd9Sstevel@tonic-gate break; 12067c478bd9Sstevel@tonic-gate } 12077c478bd9Sstevel@tonic-gate } 12087c478bd9Sstevel@tonic-gate 12097c478bd9Sstevel@tonic-gate if (model && !pic) 12107c478bd9Sstevel@tonic-gate newae(h, model); 12117c478bd9Sstevel@tonic-gate if (!nolibc) 12127c478bd9Sstevel@tonic-gate newae(h, "-lc"); 12137c478bd9Sstevel@tonic-gate } 12147c478bd9Sstevel@tonic-gate 12157c478bd9Sstevel@tonic-gate /* ARGSUSED4 */ 12167c478bd9Sstevel@tonic-gate static void 12177c478bd9Sstevel@tonic-gate do_cc(const char *dir, const char *cmd, int argc, char **argv, 12187c478bd9Sstevel@tonic-gate struct aelist *h, int cplusplus) 12197c478bd9Sstevel@tonic-gate { 12207c478bd9Sstevel@tonic-gate char *program; 12217c478bd9Sstevel@tonic-gate size_t len = strlen(dir) + strlen(cmd) + 2; 12227c478bd9Sstevel@tonic-gate 12237c478bd9Sstevel@tonic-gate program = malloc(len); 12247c478bd9Sstevel@tonic-gate (void) snprintf(program, len, "%s/%s", dir, cmd); 12257c478bd9Sstevel@tonic-gate 12267c478bd9Sstevel@tonic-gate /* 12277c478bd9Sstevel@tonic-gate * This is pretty simple. 12287c478bd9Sstevel@tonic-gate * We just have to recognize -V, -_noecho, -_compiler, -_cc= and -_gcc= 12297c478bd9Sstevel@tonic-gate */ 12307c478bd9Sstevel@tonic-gate newae(h, program); 12317c478bd9Sstevel@tonic-gate 12327c478bd9Sstevel@tonic-gate while (--argc > 0) { 12337c478bd9Sstevel@tonic-gate char *arg = *++argv; 12347c478bd9Sstevel@tonic-gate 12357c478bd9Sstevel@tonic-gate if (*arg != '-') { 12367c478bd9Sstevel@tonic-gate newae(h, arg); 12377c478bd9Sstevel@tonic-gate } else if (*(arg + 1) != '_') { 12387c478bd9Sstevel@tonic-gate if (strcmp(arg, "-V") == 0) 12397c478bd9Sstevel@tonic-gate echo = 0; 12407c478bd9Sstevel@tonic-gate newae(h, arg); 12417c478bd9Sstevel@tonic-gate } else if (strcmp(arg, "-_noecho") == 0) { 12427c478bd9Sstevel@tonic-gate echo = 0; 12437c478bd9Sstevel@tonic-gate } else if (strcmp(arg, "-_compiler") == 0) { 12447c478bd9Sstevel@tonic-gate (void) printf("%s\n", program); 12457c478bd9Sstevel@tonic-gate exit(0); 12467c478bd9Sstevel@tonic-gate } else if (strncmp(arg, "-_cc=", 5) == 0 || 12477c478bd9Sstevel@tonic-gate strncmp(arg, "-_CC=", 5) == 0) { 12487c478bd9Sstevel@tonic-gate newae(h, arg + 5); 12497c478bd9Sstevel@tonic-gate } else if (strncmp(arg, "-_gcc=", 6) != 0 && 12507c478bd9Sstevel@tonic-gate strncmp(arg, "-_g++=", 6) != 0) { 12517c478bd9Sstevel@tonic-gate (void) fprintf(stderr, 12527c478bd9Sstevel@tonic-gate "%s: invalid argument '%s'\n", progname, arg); 12537c478bd9Sstevel@tonic-gate exit(2); 12547c478bd9Sstevel@tonic-gate } 12557c478bd9Sstevel@tonic-gate } 12567c478bd9Sstevel@tonic-gate } 12577c478bd9Sstevel@tonic-gate 12587c478bd9Sstevel@tonic-gate int 12597c478bd9Sstevel@tonic-gate main(int argc, char **argv) 12607c478bd9Sstevel@tonic-gate { 12617c478bd9Sstevel@tonic-gate struct aelist *h = newael(); 12627c478bd9Sstevel@tonic-gate const char *dir; 12637c478bd9Sstevel@tonic-gate int ac; 12647c478bd9Sstevel@tonic-gate char **newargv; 12657c478bd9Sstevel@tonic-gate struct ae *a; 12667c478bd9Sstevel@tonic-gate char cc_buf[MAXPATHLEN], gcc_buf[MAXPATHLEN]; 12677c478bd9Sstevel@tonic-gate 12687c478bd9Sstevel@tonic-gate if ((progname = strrchr(argv[0], '/')) == NULL) 12697c478bd9Sstevel@tonic-gate progname = argv[0]; 12707c478bd9Sstevel@tonic-gate else 12717c478bd9Sstevel@tonic-gate progname++; 12727c478bd9Sstevel@tonic-gate 12737c478bd9Sstevel@tonic-gate default_cc_dir = DEFAULT_CC_DIR; 12747c478bd9Sstevel@tonic-gate default_gcc_dir = DEFAULT_GCC_DIR; 12757c478bd9Sstevel@tonic-gate default_cplusplus_dir = DEFAULT_CPLUSPLUS_DIR; 12767c478bd9Sstevel@tonic-gate default_gplusplus_dir = DEFAULT_GPLUSPLUS_DIR; 12777c478bd9Sstevel@tonic-gate 12787c478bd9Sstevel@tonic-gate /* 12797c478bd9Sstevel@tonic-gate * Figure out where to get our tools from. This depends on 12807c478bd9Sstevel@tonic-gate * the environment variables set at run time. 12817c478bd9Sstevel@tonic-gate */ 12827c478bd9Sstevel@tonic-gate if ((dir = getenv("SPRO_VROOT")) != NULL) { 12837c478bd9Sstevel@tonic-gate (void) snprintf(cc_buf, MAXPATHLEN, "%s/bin", dir); 12847c478bd9Sstevel@tonic-gate } else if ((dir = getenv("SPRO_ROOT")) != NULL) { 128535a86aa1Spetede (void) snprintf(cc_buf, MAXPATHLEN, "%s/SOS10/bin", dir); 12867c478bd9Sstevel@tonic-gate } else if ((dir = getenv("BUILD_TOOLS")) != NULL) { 12877c478bd9Sstevel@tonic-gate (void) snprintf(cc_buf, MAXPATHLEN, 128835a86aa1Spetede "%s/SUNWspro/SOS10/bin", dir); 12897c478bd9Sstevel@tonic-gate } 12907c478bd9Sstevel@tonic-gate if (dir != NULL) 12917c478bd9Sstevel@tonic-gate default_cc_dir = (char *)cc_buf; 12927c478bd9Sstevel@tonic-gate 12937c478bd9Sstevel@tonic-gate if ((dir = getenv("GNU_ROOT")) != NULL) { 12947c478bd9Sstevel@tonic-gate (void) snprintf(gcc_buf, MAXPATHLEN, "%s/bin", dir); 12957c478bd9Sstevel@tonic-gate default_gcc_dir = (char *)gcc_buf; 12967c478bd9Sstevel@tonic-gate } 12977c478bd9Sstevel@tonic-gate 12987c478bd9Sstevel@tonic-gate default_cplusplus_dir = default_cc_dir; 12997c478bd9Sstevel@tonic-gate default_gplusplus_dir = default_gcc_dir; 13007c478bd9Sstevel@tonic-gate 13017c478bd9Sstevel@tonic-gate /* 13027c478bd9Sstevel@tonic-gate * The first argument must be one of "-_cc", "-_gcc", "-_CC", or "-_g++" 13037c478bd9Sstevel@tonic-gate */ 13047c478bd9Sstevel@tonic-gate if (argc == 1) 13057c478bd9Sstevel@tonic-gate usage(); 13067c478bd9Sstevel@tonic-gate argc--; 13077c478bd9Sstevel@tonic-gate argv++; 13087c478bd9Sstevel@tonic-gate if (strcmp(argv[0], "-_cc") == 0) { 13097c478bd9Sstevel@tonic-gate if ((dir = getenv("CW_CC_DIR")) == NULL) 13107c478bd9Sstevel@tonic-gate dir = default_cc_dir; 13117c478bd9Sstevel@tonic-gate do_cc(dir, "cc", argc, argv, h, 0); 13127c478bd9Sstevel@tonic-gate } else if (strcmp(argv[0], "-_gcc") == 0) { 13137c478bd9Sstevel@tonic-gate if ((dir = getenv("CW_GCC_DIR")) == NULL) 13147c478bd9Sstevel@tonic-gate dir = default_gcc_dir; 13157c478bd9Sstevel@tonic-gate do_gcc(dir, "gcc", argc, argv, h, 0); 13167c478bd9Sstevel@tonic-gate } else if (strcmp(argv[0], "-_CC") == 0) { 13177c478bd9Sstevel@tonic-gate if ((dir = getenv("CW_CPLUSPLUS_DIR")) == NULL) 13187c478bd9Sstevel@tonic-gate dir = default_cplusplus_dir; 13197c478bd9Sstevel@tonic-gate do_cc(dir, "CC", argc, argv, h, 1); 13207c478bd9Sstevel@tonic-gate } else if (strcmp(argv[0], "-_g++") == 0) { 13217c478bd9Sstevel@tonic-gate if ((dir = getenv("CW_GPLUSPLUS_DIR")) == NULL) 13227c478bd9Sstevel@tonic-gate dir = default_gplusplus_dir; 13237c478bd9Sstevel@tonic-gate do_gcc(dir, "g++", argc, argv, h, 1); 13247c478bd9Sstevel@tonic-gate } else { 13257c478bd9Sstevel@tonic-gate /* assume "-_gcc" by default */ 13267c478bd9Sstevel@tonic-gate argc++; 13277c478bd9Sstevel@tonic-gate argv--; 13287c478bd9Sstevel@tonic-gate if ((dir = getenv("CW_GCC_DIR")) == NULL) 13297c478bd9Sstevel@tonic-gate dir = default_gcc_dir; 13307c478bd9Sstevel@tonic-gate do_gcc(dir, "gcc", argc, argv, h, 0); 13317c478bd9Sstevel@tonic-gate } 13327c478bd9Sstevel@tonic-gate 13337c478bd9Sstevel@tonic-gate newargv = calloc(sizeof (*newargv), newargc + 1); 13347c478bd9Sstevel@tonic-gate 13357c478bd9Sstevel@tonic-gate if (echo) 13367c478bd9Sstevel@tonic-gate (void) printf("+ "); 13377c478bd9Sstevel@tonic-gate 13387c478bd9Sstevel@tonic-gate for (ac = 0, a = h->ael_head; a; a = a->ae_next, ac++) { 13397c478bd9Sstevel@tonic-gate newargv[ac] = a->ae_arg; 13407c478bd9Sstevel@tonic-gate if (echo) 13417c478bd9Sstevel@tonic-gate (void) printf("%s ", a->ae_arg); 13427c478bd9Sstevel@tonic-gate if (a == h->ael_tail) 13437c478bd9Sstevel@tonic-gate break; 13447c478bd9Sstevel@tonic-gate } 13457c478bd9Sstevel@tonic-gate 13467c478bd9Sstevel@tonic-gate if (echo) { 13477c478bd9Sstevel@tonic-gate (void) printf("\n"); 13487c478bd9Sstevel@tonic-gate (void) fflush(stdout); 13497c478bd9Sstevel@tonic-gate } 13507c478bd9Sstevel@tonic-gate 13517c478bd9Sstevel@tonic-gate /* 13527c478bd9Sstevel@tonic-gate * Here goes .. 13537c478bd9Sstevel@tonic-gate */ 13547c478bd9Sstevel@tonic-gate (void) execvp(newargv[0], newargv); 13557c478bd9Sstevel@tonic-gate 13567c478bd9Sstevel@tonic-gate /* 13577c478bd9Sstevel@tonic-gate * execvp() returns only on error. 13587c478bd9Sstevel@tonic-gate */ 13597c478bd9Sstevel@tonic-gate perror("execvp"); 13607c478bd9Sstevel@tonic-gate (void) fprintf(stderr, "%s: couldn't run %s\n", 13617c478bd9Sstevel@tonic-gate progname, newargv[0]); 13627c478bd9Sstevel@tonic-gate return (4); 13637c478bd9Sstevel@tonic-gate } 1364