cw.c revision c3f177eadfdb30c8441fe9e19b825793f30c7272
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Wrapper for the GNU C compiler to make it accept the Sun C compiler
* arguments where possible.
*
* Since the translation is inexact, this is something of a work-in-progress.
*
*/
/* If you modify this file, you must increment CW_VERSION */
#define CW_VERSION "1.28"
/*
* -# Verbose mode
* -### Show compiler commands built by driver, no compilation
* -A<name[(tokens)]> Preprocessor predicate assertion
* -B<[static|dynamic]> Specify dynamic or static binding
* -C Prevent preprocessor from removing comments
* -c Compile only - produce .o files, suppress linking
* -cg92 Alias for -xtarget=ss1000
* -D<name[=token]> Associate name with token as if by #define
* -d[y|n] dynamic [-dy] or static [-dn] option to linker
* -E Compile source through preprocessor only, output to stdout
* -erroff=<t> Suppress warnings specified by tags t(%none, %all, <tag list>)
* -errtags=<a> Display messages with tags a(no, yes)
* -errwarn=<t> Treats warnings specified by tags t(%none, %all, <tag list>)
* as errors
* -fast Optimize using a selection of options
* -fd Report old-style function definitions and declarations
* -features=zla Allow zero-length arrays
* -flags Show this summary of compiler options
* -fnonstd Initialize floating-point hardware to non-standard preferences
* -fns[=<yes|no>] Select non-standard floating point mode
* -fprecision=<p> Set FP rounding precision mode p(single, double, extended)
* -fround=<r> Select the IEEE rounding mode in effect at startup
* -fsimple[=<n>] Select floating-point optimization preferences <n>
* -fsingle Use single-precision arithmetic (-Xt and -Xs modes only)
* -ftrap=<t> Select floating-point trapping mode in effect at startup
* -fstore force floating pt. values to target precision on assignment
* -G Build a dynamic shared library
* -g Compile for debugging
* -H Print path name of each file included during compilation
* -h <name> Assign <name> to generated dynamic shared library
* -I<dir> Add <dir> to preprocessor #include file search path
* -i Passed to linker to ignore any LD_LIBRARY_PATH setting
* -keeptmp Keep temporary files created during compilation
* -KPIC Compile position independent code with 32-bit addresses
* -Kpic Compile position independent code
* -L<dir> Pass to linker to add <dir> to the library search path
* -l<name> Link with library lib<name>.a or lib<name>.so
* -mc Remove duplicate strings from .comment section of output files
* -mr Remove all strings from .comment section of output files
* -mr,"string" Remove all strings and append "string" to .comment section
* -mt Specify options needed when compiling multi-threaded code
* -native Find available processor, generate code accordingly
* -nofstore Do not force floating pt. values to target precision
* on assignment
* -nolib Same as -xnolib
* -noqueue Disable queuing of compiler license requests
* -norunpath Do not build in a runtime path for shared libraries
* -O Use default optimization level (-xO2 or -xO3. Check man page.)
* -o <outputfile> Set name of output file to <outputfile>
* -P Compile source through preprocessor only, output to .i file
* -PIC Alias for -KPIC or -xcode=pic32
* -p Compile for profiling with prof
* -pic Alias for -Kpic or -xcode=pic13
* -qp Compile for profiling with prof
* -R<dir[:dir]> Build runtime search path list into executable
* -S Compile and only generate assembly code (.s)
* -s Strip symbol table from the executable file
* -t Turn off duplicate symbol warnings when linking
* -U<name> Delete initial definition of preprocessor symbol <name>
* -V Report version number of each compilation phase
* -v Do stricter semantic checking
* -W<c>,<arg> Pass <arg> to specified component <c> (a,l,m,p,0,2,h,i,u)
* -w Suppress compiler warning messages
* -Xa Compile assuming ANSI C conformance, allow K & R extensions
* (default mode)
* -Xc Compile assuming strict ANSI C conformance
* -Xs Compile assuming (pre-ANSI) K & R C style code
* -Xt Compile assuming K & R conformance, allow ANSI C
* -x386 Generate code for the 80386 processor
* -x486 Generate code for the 80486 processor
* -xarch=<a> Specify target architecture instruction set
* -xbuiltin[=<b>] When profitable inline, or substitute intrinisic functions
* for system functions, b={%all,%none}
* -xCC Accept C++ style comments
* -xchar_byte_order=<o> Specify multi-char byte order <o> (default, high, low)
* -xchip=<c> Specify the target processor for use by the optimizer
* -xcode=<c> Generate different code for forming addresses
* -xcrossfile[=<n>] Enable optimization and inlining across source files,
* n={0|1}
* -xF Compile for later mapfile reordering or unused section
* elimination
* -xhelp=<f> Display on-line help information f(flags, readme, errors)
* -xildoff Cancel -xildon
* -xildon Enable use of the incremental linker, ild
* -xinline=[<a>,...,<a>] Attempt inlining of specified user routines,
* <a>={%auto,func,no%func}
* -xlibmieee Force IEEE 754 return values for math routines in
* exceptional cases
* -xlibmil Inline selected libm math routines for optimization
* -xlic_lib=sunperf Link in the Sun supplied performance libraries
* -xlicinfo Show license server information
* -xM Generate makefile dependencies
* -xmaxopt=[off,1,2,3,4,5] maximum optimization level allowed on #pragma opt
* -xnolib Do not link with default system libraries
* -xnolibmil Cancel -xlibmil on command line
* -xO<n> Generate optimized code (n={1|2|3|4|5})
* -xP Print prototypes for function definitions
* -xpentium Generate code for the pentium processor
* -xpg Compile for profiling with gprof
* -xprofile=<p> Collect data for a profile or use a profile to optimize
* <p>={{collect,use}[:<path>],tcov}
* -xregs=<r> Control register allocation
* -xs Allow debugging without object (.o) files
* -xsb Compile for use with the WorkShop source browser
* -xsbfast Generate only WorkShop source browser info, no compilation
* -xsfpconst Represent unsuffixed floating point constants as single
* precision
* -xspace Do not do optimizations that increase code size
* -xstrconst Place string literals into read-only data segment
* -xtarget=<t> Specify target system for optimization
* -xtemp=<dir> Set directory for temporary files to <dir>
* -xtime Report the execution time for each compilation phase
* -xtransition Emit warnings for differences between K&R C and ANSI C
* -xtrigraphs[=<yes|no>] Enable|disable trigraph translation
* -xunroll=n Enable unrolling loops n times where possible
* -Y<c>,<dir> Specify <dir> for location of component <c> (a,l,m,p,0,h,i,u)
* -YA,<dir> Change default directory searched for components
* -YI,<dir> Change default directory searched for include files
* -YP,<dir> Change default directory for finding libraries files
* -YS,<dir> Change default directory for startup object files
*/
/*
* Translation table:
*/
/*
* -# -v
* -### error
* -A<name[(tokens)]> pass-thru
* -B<[static|dynamic]> pass-thru (syntax error for anything else)
* -C pass-thru
* -c pass-thru
* -cg92 -m32 -mcpu=v8 -mtune=supersparc (SPARC only)
* -D<name[=token]> pass-thru
* -dy or -dn -Wl,-dy or -Wl,-dn
* -E pass-thru
* -erroff=E_EMPTY_TRANSLATION_UNIT ignore
* -errtags=%all -Wall
* -errwarn=%all -Werror else -Wno-error
* -fast error
* -fd error
* -features=zla ignore
* -flags --help
* -fnonstd error
* -fns[=<yes|no>] error
* -fprecision=<p> error
* -fround=<r> error
* -fsimple[=<n>] error
* -fsingle[=<n>] error
* -ftrap=<t> error
* -fstore error
* -G pass-thru
* -g pass-thru
* -H pass-thru
* -h <name> pass-thru
* -I<dir> pass-thru
* -i pass-thru
* -keeptmp -save-temps
* -KPIC -fPIC
* -Kpic -fpic
* -L<dir> pass-thru
* -l<name> pass-thru
* -mc error
* -mr error
* -mr,"string" error
* -mt -D_REENTRANT
* -native error
* -nofstore error
* -nolib -nodefaultlibs
* -noqueue ignore
* -norunpath ignore
* -O -O1 (Check the man page to be certain)
* -o <outputfile> pass-thru
* -P -E -o filename.i (or error)
* -PIC -fPIC (C++ only)
* -p pass-thru
* -pic -fpic (C++ only)
* -Q[y|n] error
* -qp -p
* -R<dir[:dir]> pass-thru
* -S pass-thru
* -s -Wl,-s
* -t -Wl,-t
* -U<name> pass-thru
* -V --version
* -v -Wall
* -Wa,<arg> pass-thru
* -Wp,<arg> pass-thru except -xc99=<a>
* -Wl,<arg> pass-thru
* -Wu,-xmodel=kernel -ffreestanding -mcmodel=kernel -mno-red-zone
* -xmodel=kernel -ffreestanding -mcmodel=kernel -mno-red-zone
* -Wu,-save_args -msave-args
* -w pass-thru
* -Xa -std=iso9899:199409 or -ansi
* -Xc -ansi -pedantic
* -Xt error
* -Xs -traditional -std=c89
* -x386 -march=i386 (x86 only)
* -x486 -march=i486 (x86 only)
* -xarch=<a> table
* -xbuiltin[=<b>] -fbuiltin (-fno-builtin otherwise)
* -xCC ignore
* -xchar_byte_order=<o> error
* -xchip=<c> table
* -xcode=<c> table
* -xdebugformat=<format> ignore (always use dwarf-2 for gcc)
* -xcrossfile[=<n>] ignore
* -xe error
* -xF error
* -xhelp=<f> error
* -xildoff ignore
* -xildon ignore
* -xinline ignore
* -xlibmieee error
* -xlibmil error
* -xlic_lib=sunperf error
* -xM -M
* -xM1 -MM
* -xmaxopt=[...] error
* -xnolib -nodefaultlibs
* -xnolibmil error
* -xO<n> -O<n>
* -xP error
* -xpentium -march=pentium (x86 only)
* -xpg error
* -xprofile=<p> error
* -xregs=<r> table
* -xs error
* -xsb error
* -xsbfast error
* -xsfpconst error
* -xspace ignore (-not -Os)
* -xstrconst ignore
* -xtarget=<t> table
* -xtemp=<dir> error
* -xtime error
* -xtransition -Wtransition
* -xtrigraphs=<yes|no> -trigraphs -notrigraphs
* -xunroll=n error
* -W0,-xdbggen=no%usedonly -fno-eliminate-unused-debug-symbols
* -fno-eliminate-unused-debug-types
* -Y<c>,<dir> error
* -YA,<dir> error
* -YI,<dir> -nostdinc -I<dir>
* -YP,<dir> error
* -YS,<dir> error
*/
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <fcntl.h>
#include <errno.h>
#include <stdarg.h>
#include <sys/isa_defs.h>
#define CW_F_CXX 0x01
#define CW_F_SHADOW 0x02
#define CW_F_EXEC 0x04
#define CW_F_ECHO 0x08
#define CW_F_XLATE 0x10
#define CW_F_PROG 0x20
typedef enum cw_compiler {
CW_C_CC = 0,
static const char *cmds[] = {
"cc", "CC",
"gcc", "g++"
};
static const char *dirs[] = {
};
(ctx)->i_compiler)
typedef enum cw_op {
CW_O_NONE = 0,
} cw_op_t;
struct aelist {
struct ae {
char *ae_arg;
int ael_argc;
};
typedef struct cw_ictx {
int i_oldargc;
char **i_oldargv;
char i_discard[MAXPATHLEN];
char *i_stderr;
} cw_ictx_t;
/*
* Status values to indicate which Studio compiler and associated
* flags are being used.
*/
#define TRANS_ENTRY 5
/*
* Translation table definition for the -xarch= flag. The "x_arg"
* value is translated into the appropriate gcc flags according
* to the values in x_trans[n]. The x_flags indicates what compiler
* is being used and what flags have been set via the use of
* "x_arg".
*/
typedef struct xarch_table {
char *x_arg;
int x_flags;
char *x_trans[TRANS_ENTRY];
/*
* The translation table for the -xarch= flag used in the Studio compilers.
*/
static const xarch_table_t xtbl[] = {
#if defined(__x86)
{ "generic", SS11 },
"-mvis" } },
"-mvis" } },
#endif
};
static const char *progname;
static const char *xchip_tbl[] = {
#if defined(__x86)
#endif
};
static const char *xcode_tbl[] = {
#if defined(__sparc)
#endif
};
static const char *xtarget_tbl[] = {
#if defined(__x86)
#endif /* __x86 */
};
static const char *xregs_tbl[] = {
#if defined(__sparc)
#endif /* __sparc */
};
static void
nomem(void)
{
exit(1);
}
static void
{
int saved_errno = errno;
}
static void
{
nomem();
else
}
static cw_ictx_t *
newictx(void)
{
if (ctx)
return (NULL);
}
return (ctx);
}
static void
{
exit(2);
}
/*
* Add the current favourite set of warnings to the gcc invocation.
*/
static void
{
static int warningsonce;
if (warningsonce++)
return;
newae(h, "-Wall");
newae(h, "-Wno-unknown-pragmas");
newae(h, "-Wno-missing-braces");
newae(h, "-Wno-sign-compare");
newae(h, "-Wno-parentheses");
newae(h, "-Wno-uninitialized");
newae(h, "-Wno-implicit-function-declaration");
newae(h, "-Wno-unused");
newae(h, "-Wno-trigraphs");
newae(h, "-Wno-char-subscripts");
newae(h, "-Wno-switch");
}
static void
{
if (level >= 2) {
newae(h, "-fno-strict-aliasing");
newae(h, "-fno-unit-at-a-time");
newae(h, "-fno-optimize-sibling-calls");
}
}
/* ARGSUSED */
static void
{
}
static void
{
static int xconce;
if (xconce++)
return;
newae(h, "-ansi");
newae(h, "-pedantic-errors");
}
static void
{
static int xsonce;
if (xsonce++)
return;
newae(h, "-traditional");
newae(h, "-traditional-cpp");
}
static void
usage()
{
"usage: %s { -_cc | -_gcc | -_CC | -_g++ } [ -_compiler | ... ]\n",
progname);
exit(2);
}
static int
{
int i, j;
for (i = 0; i < xtbl_size; i++) {
break;
}
/*
* At the end of the table and so no matching "arg" entry
* found and so this must be a bad -xarch= flag.
*/
if (i == xtbl_size)
for (j = 0; j < TRANS_ENTRY; j++) {
else
break;
}
}
static void
{
table++;
table++;
}
table++;
table++;
}
}
static void
{
int c;
int mflag = 0;
return;
}
#if defined(__sparc)
/*
* The SPARC ldd and std instructions require 8-byte alignment of
* their address operand. gcc correctly uses them only when the
* ABI requires 8-byte alignment; unfortunately we have a number of
* pieces of buggy code that doesn't conform to the ABI. This
* flag makes gcc work more like Studio with -xmemalign=4.
*/
#endif
/*
* This is needed because 'u' is defined
* under a conditional on 'sun'. Should
* probably just remove the conditional,
* or make it be dependent on '__sun'.
*
* -Dunix is also missing in enhanced ANSI mode
*/
/*
* Walk the argument list, translating as we go ..
*/
if (*arg == '-') {
arglen--;
} else {
/*
* Discard inline files that gcc doesn't grok
*/
continue;
c_files++;
/*
* Otherwise, filenames and partial arguments
* are passed through for gcc to chew on. However,
* output is always discarded for the secondary
* compiler.
*/
else
in_output = 0;
continue;
}
/* discard -compat=4 and -compat=5 */
continue;
}
/* discard -Qoption and its two arguments */
continue;
}
/* turn warnings into errors */
continue;
}
/* no exceptions */
/* no run time type descriptor information */
continue;
}
pic = 1;
continue;
}
pic = 1;
continue;
}
/* gcc has no corresponding option */
continue;
}
/* -nodefaultlibs is on by default */
nolibc = 1;
continue;
}
#if defined(__sparc)
continue;
}
#endif /* __sparc */
}
switch ((c = arg[1])) {
case '_':
/* EMPTY */;
else
break;
case '#':
if (arglen == 1) {
break;
}
break;
case 'g':
break;
case 'E':
if (arglen == 1) {
nolibc = 1;
break;
}
break;
case 'c':
case 'S':
if (arglen == 1) {
op = CW_O_COMPILE;
nolibc = 1;
}
/* FALLTHROUGH */
case 'C':
case 'H':
case 'p':
if (arglen == 1) {
break;
}
break;
case 'A':
case 'h':
case 'I':
case 'i':
case 'L':
case 'l':
case 'R':
case 'U':
case 'u':
case 'w':
break;
case 'o':
seen_o = 1;
if (arglen == 1) {
in_output = 1;
} else {
}
break;
case 'D':
/*
* XXX Clearly a hack ... do we need _KADB too?
*/
break;
case 'd':
if (arglen == 2) {
break;
}
break;
}
}
/*
* -dalign forces alignment in some cases;
* gcc does not need any flag to do this.
*/
break;
}
break;
case 'e':
"-erroff=E_EMPTY_TRANSLATION_UNIT") == 0) {
/*
* Accept but ignore this -- gcc doesn't
* seem to complain about empty translation
* units
*/
break;
}
/* XX64 -- ignore all -erroff= options, for now */
break;
break;
}
break;
}
break;
case 'f':
break;
}
/*
* Accept but ignore this -- gcc allows
* zero length arrays.
*/
break;
}
break;
case 'G':
nolibc = 1;
break;
case 'k':
break;
}
break;
case 'K':
if (arglen == 1) {
*arg == '\0')
error("-K");
} else {
arg += 2;
}
pic = 1;
break;
}
pic = 1;
break;
}
error("-K");
break;
case 'm':
break;
}
#if defined(__x86)
#endif
break;
}
break;
}
break;
case 'B': /* linker options */
case 'M':
case 'z':
{
char *opt;
char *s;
if (arglen == 1) {
} else {
}
nomem();
free(s);
}
break;
case 'n':
/*
* Horrid license server stuff - n/a
*/
break;
}
break;
case 'O':
if (arglen == 1) {
break;
}
break;
case 'P':
/*
* We could do '-E -o filename.i', but that's hard,
* and we don't need it for the case that's triggering
* this addition. We'll require the user to specify
* -o in the Makefile. If they don't they'll find out
* in a hurry.
*/
nolibc = 1;
break;
case 'q':
break;
}
break;
case 's':
if (arglen == 1) {
break;
}
break;
case 't':
if (arglen == 1) {
break;
}
break;
case 'V':
if (arglen == 1) {
break;
}
break;
case 'v':
if (arglen == 1) {
break;
}
break;
case 'W':
/*
* gcc's preprocessor will accept c99
* regardless, so accept and ignore.
*/
break;
}
break;
}
/* (undocumented) enables _Pragma */
break;
}
/*
* This is a polite way of saying
* "no c99 constructs allowed!"
* For now, just accept and ignore this.
*/
break;
}
/*
* gcc doesn't prefix local symbols
* in debug mode, so this is not needed.
*/
break;
}
/*
* Generate tests at the top of loops.
* There is no direct gcc equivalent, ignore.
*/
break;
}
"-fno-eliminate-unused-debug-symbols");
"-fno-eliminate-unused-debug-types");
break;
}
/*
* Use the legacy behaviour (pre-SS11)
* for integer wrapping.
* gcc does not need this.
*/
break;
}
/*
* Elimination and expansion of conditionals;
* gcc has no direct equivalent.
*/
break;
}
/*
* Prevents optimizing away checks for
* unbound weak symbol addresses. gcc does
* not do this, so it's not needed.
*/
break;
}
pic = 1;
break;
}
/*
* Prevents insertion of register symbols.
* gcc doesn't do this, so ignore it.
*/
break;
}
/*
* Prevents optimizing away of static variables.
* gcc does not do this, so it's not needed.
*/
break;
}
#if defined(__x86)
break;
}
model = "-mcmodel=kernel";
nolibc = 1;
break;
}
break;
}
#endif /* __x86 */
break;
case 'X':
break;
}
break;
}
break;
}
break;
case 'x':
if (arglen == 1)
switch (arg[2]) {
#if defined(__x86)
case '3':
break;
}
break;
case '4':
break;
}
break;
#endif /* __x86 */
case 'a':
break;
}
break;
case 'b':
break;
}
break;
case 'C':
/* Accept C++ style comments -- ignore */
break;
break;
case 'c':
break;
}
break;
}
break;
}
pic = 1;
break;
}
break;
break;
break;
case 'd':
break;
break;
break;
case 'F':
/*
* Compile for mapfile reordering, or unused
* section elimination, syntax can be -xF or
* more complex, like -xF=%all -- ignore.
*/
break;
break;
case 'i':
/* No inlining; ignore */
break;
/* No incremental linking; ignore */
break;
break;
#if defined(__x86)
case 'm':
model = "-mcmodel=kernel";
nolibc = 1;
break;
}
break;
#endif /* __x86 */
case 'M':
break;
}
break;
}
break;
case 'n':
nolibc = 1;
break;
}
break;
case 'O':
char *s;
int c = *(arg + 3);
int level;
nomem();
if (level > 5)
if (level >= 2) {
/*
* For gcc-3.4.x at -O2 we
* need to disable optimizations
* that break ON.
*/
/*
* limit -xO3 to -O2 as well.
*/
level = 2;
}
free(s);
break;
}
break;
case 'p':
break;
}
break;
}
break;
case 'r':
break;
}
break;
case 's':
break;
break;
case 't':
break;
}
break;
}
break;
}
break;
}
break;
case 'e':
case 'h':
case 'l':
default:
break;
}
break;
case 'Y':
if (arglen == 1) {
*arg == '\0')
error("-Y");
} else {
arg += 2;
}
/* Just ignore -YS,... for now */
break;
s[0] = '-';
s[1] = 'B';
free(s);
break;
}
s[0] = '-';
s[1] = 'I';
free(s);
break;
}
break;
case 'Q':
/*
* We could map -Qy into -Wl,-Qy etc.
*/
default:
break;
}
}
op != CW_O_PREPROCESS) {
"allowed only with -E or -P\n", progname);
exit(2);
}
/*
* Make sure that we do not have any unintended interactions between
* the xarch options passed in and the version of the Studio compiler
* used.
*/
"Conflicting \"-xarch=\" flags (both Studio 11 and 12)\n");
exit(2);
}
switch (mflag) {
case 0:
/* FALLTHROUGH */
case M32:
#if defined(__sparc)
/*
* Only -m32 is defined and so put in the missing xarch
* translation.
*/
#endif
break;
case M64:
#if defined(__sparc)
/*
* Only -m64 is defined and so put in the missing xarch
* translation.
*/
#endif
break;
case SS12:
#if defined(__sparc)
/* no -m32/-m64 flag used - this is an error for sparc builds */
exit(2);
#endif
break;
case SS11:
/* FALLTHROUGH */
break;
#if defined(__sparc)
/*
* Need to add in further 32 bit options because with SS12
* the xarch=sparcvis option can be applied to 32 or 64
* bit, and so the translatation table (xtbl) cannot handle
* that.
*/
#endif
break;
break;
default:
exit(2);
}
exit(0);
if (!nolibc)
}
}
static void
{
return;
}
if (*arg != '-') {
} else {
in_output = 0;
}
continue;
}
switch (*(arg + 1)) {
case '_':
"%s: invalid argument '%s'\n", progname,
arg);
exit(2);
}
break;
case 'V':
break;
case 'o':
seen_o = 1;
in_output = 1;
} else {
}
break;
case 'c':
case 'S':
op = CW_O_COMPILE;
break;
case 'E':
case 'P':
/*FALLTHROUGH*/
default:
}
}
exit(0);
}
}
static void
{
char *program;
nomem();
}
return;
case CW_C_CC:
break;
case CW_C_GCC:
break;
}
}
static int
{
char **newargv;
int ac;
struct ae *a;
NULL)
nomem();
break;
}
}
return (0);
/*
* We must fix up the environment here so that the
* dependency files are not trampled by the shadow compiler.
*/
(unsetenv("SUNPRO_DEPENDENCIES") != 0 ||
unsetenv("DEPENDENCIES_OUTPUT") != 0)) {
return (-1);
}
return (-1);
}
static int
{
char buf[1024];
struct stat s;
/*
* Only wait for one specific child.
*/
return (-1);
do {
cw_perror("cannot reap child");
return (-1);
}
if (status != 0) {
if (WIFSIGNALED(status)) {
break;
break;
}
}
cw_perror("stat failed on child cleanup");
return (-1);
}
if (s.st_size != 0) {
FILE *f;
(void) fclose(f);
}
}
/*
* cc returns an error code when given -V; we want that to succeed.
*/
return (0);
return (ret);
}
static int
{
char *file;
/*
* To avoid offending cc's sensibilities, the name of its output
* file must end in '.o'.
*/
nomem();
return (-1);
}
nomem();
return (-1);
}
int fd;
0666)) < 0) {
cw_perror("open failed for standard error");
exit(1);
}
cw_perror("dup2 failed for standard error");
exit(1);
}
if (fd != 2)
exit(1);
}
}
cw_perror("fork failed");
return (1);
}
if (block)
return (0);
}
int
{
const char *dir;
int ret = 0;
else
progname++;
nomem();
/*
* Figure out where to get our tools from. This depends on
* the environment variables set at run time.
*/
}
}
}
/*
* The first argument must be one of "-_cc", "-_gcc", "-_CC", or "-_g++"
*/
if (argc == 1)
usage();
argc--;
argv++;
} else {
/* assume "-_gcc" by default */
argc++;
argv--;
}
/*
* -_compiler - tell us the path to the primary compiler only
*/
return (0);
}
/*
* -_versions - tell us the cw version, paths to all compilers, and
* ask each for its version if we know how.
*/
if (!do_shadow)
(void) printf(" (SHADOW MODE DISABLED)");
(void) printf("\n");
argc--;
argv++;
do_serial = 1;
}
if (do_shadow) {
}
if (!do_serial)
return (ret);
}