cw.c revision 7fbf8d036e729a0a92f63050f569185313bc597f
* -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 * -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 * -Q[y|n] Emit/don't emit identification info to output file * -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 * -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, * -xF Compile for later mapfile reordering or unused section * -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 * -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 * -xM1 Generate makefile dependencies, but exclude /usr/include * -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 * -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 * -A<name[(tokens)]> pass-thru * -B<[static|dynamic]> pass-thru (syntax error for anything else) * -cg92 -m32 -mcpu=v8 -mtune=supersparc (SPARC only) * -D<name[=token]> pass-thru * -dy or -dn -Wl,-dy or -Wl,-dn * -erroff=E_EMPTY_TRANSLATION_UNIT ignore * -errwarn=%all -Werror else -Wno-error * -O -O1 (Check the man page to be certain) * -o <outputfile> pass-thru * -P -E -o filename.i (or error) * -R<dir[:dir]> pass-thru * -Wp,<arg> pass-thru except -xc99=<a> * -Wu,-xmodel=kernel -ffreestanding -mcmodel=kernel -mno-red-zone * -xmodel=kernel -ffreestanding -mcmodel=kernel -mno-red-zone * -Wu,-save_args -msave-args * -Xa -std=iso9899:199409 or -ansi * -Xs -traditional -std=c89 * -x386 -march=i386 (x86 only) * -x486 -march=i486 (x86 only) * -xbuiltin[=<b>] -fbuiltin (-fno-builtin otherwise) * -xchar_byte_order=<o> error * -xdebugformat=<format> ignore (always use dwarf-2 for gcc) * -xcrossfile[=<n>] ignore * -xlic_lib=sunperf error * -xpentium -march=pentium (x86 only) * -xspace ignore (-not -Os) * -xtransition -Wtransition * -xtrigraphs=<yes|no> -trigraphs -notrigraphs * -W0,-xdbggen=no%usedonly -fno-eliminate-unused-debug-symbols * -fno-eliminate-unused-debug-types * -YI,<dir> -nostdinc -I<dir> static const char *
cmds[] = {
* Status values to indicate which Studio compiler and associated #
define M32 0x01 /* -m32 - only on Studio 12 */#
define M64 0x02 /* -m64 - only on Studio 12 */#
define SS11 0x100 /* Studio 11 */#
define SS12 0x200 /* Studio 12 */ * 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 * The translation table for the -xarch= flag used in the Studio compilers. {
"generic64", (
SS11|
M64), {
"-m64",
"-mtune=opteron" } },
{
"amd64", (
SS11|
M64), {
"-m64",
"-mtune=opteron" } },
{
"386",
SS11, {
"-march=i386" } },
{
"pentium_pro",
SS11, {
"-march=pentiumpro" } },
{
"generic", (
SS11|
M32), {
"-m32",
"-mcpu=v8" } },
{
"generic64", (
SS11|
M64), {
"-m64",
"-mcpu=v9" } },
{
"v8", (
SS11|
M32), {
"-m32",
"-mcpu=v8",
"-mno-v8plus" } },
{
"v8plus", (
SS11|
M32), {
"-m32",
"-mcpu=v9",
"-mv8plus" } },
{
"v8plusa", (
SS11|
M32), {
"-m32",
"-mcpu=ultrasparc",
"-mv8plus",
{
"v8plusb", (
SS11|
M32), {
"-m32",
"-mcpu=ultrasparc3",
"-mv8plus",
{
"v9", (
SS11|
M64), {
"-m64",
"-mcpu=v9" } },
{
"v9a", (
SS11|
M64), {
"-m64",
"-mcpu=ultrasparc",
"-mvis" } },
{
"v9b", (
SS11|
M64), {
"-m64",
"-mcpu=ultrasparc3",
"-mvis" } },
{
"sparc",
SS12, {
"-mcpu=v9",
"-mv8plus" } },
{
"sparcvis",
SS12, {
"-mcpu=ultrasparc",
"-mvis" } },
{
"sparcvis2",
SS12, {
"-mcpu=ultrasparc3",
"-mvis" } }
"386",
"-mtune=i386",
NULL,
"486",
"-mtune=i486",
NULL,
"pentium",
"-mtune=pentium",
NULL,
"pentium_pro",
"-mtune=pentiumpro",
NULL,
"super",
"-mtune=supersparc",
NULL,
"ultra",
"-mtune=ultrasparc",
NULL,
"ultra3",
"-mtune=ultrasparc3",
NULL,
"abs32",
"-fno-pic",
"-mcmodel=medlow",
NULL,
"abs44",
"-fno-pic",
"-mcmodel=medmid",
NULL,
"abs64",
"-fno-pic",
"-mcmodel=medany",
NULL,
"pentium_pro",
"-march=pentiumpro",
NULL,
"appl",
"-mapp-regs",
NULL,
"no%appl",
"-mno-app-regs",
NULL,
"no%float",
"-mno-fpu",
NULL,
"%s: error: mapping failed at or near arg '%s'\n",
progname,
arg);
* Add the current favourite set of warnings to the gcc invocation. 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-trigraphs");
newae(h,
"-Wno-char-subscripts");
newae(h,
"-fno-strict-aliasing");
newae(h,
"-fno-unit-at-a-time");
newae(h,
"-fno-optimize-sibling-calls");
newae(h,
"-pedantic-errors");
newae(h,
"-traditional");
newae(h,
"-traditional-cpp");
"usage: %s { -_cc | -_gcc | -_CC | -_g++ } [ -_compiler | ... ]\n",
* At the end of the table and so no matching "arg" entry * found and so this must be a bad -xarch= flag. * 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. * 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 .. * Discard inline files that gcc doesn't grok * Otherwise, filenames and partial arguments * are passed through for gcc to chew on. However, * output is always discarded for the secondary /* discard -compat=4 and -compat=5 */ /* discard -Qoption and its two arguments */ /* turn warnings into errors */ /* no run time type descriptor information */ /* gcc has no corresponding option */ /* -nodefaultlibs is on by default */ * XXX Clearly a hack ... do we need _KADB too? * -dalign forces alignment in some cases; * gcc does not need any flag to do this. "-erroff=E_EMPTY_TRANSLATION_UNIT") == 0) {
* Accept but ignore this -- gcc doesn't * seem to complain about empty translation /* XX64 -- ignore all -erroff= options, for now */ * Accept but ignore this -- gcc allows case 'B':
/* linker options */ * Horrid license server stuff - n/a * 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 * gcc's preprocessor will accept c99 * regardless, so accept and ignore. /* (undocumented) enables _Pragma */ * This is a polite way of saying * "no c99 constructs allowed!" * For now, just accept and ignore this. * gcc doesn't prefix local symbols * in debug mode, so this is not needed. * Generate tests at the top of loops. * There is no direct gcc equivalent, ignore. if (
strcmp(
arg,
"-W0,-xdbggen=no%usedonly") == 0) {
"-fno-eliminate-unused-debug-symbols");
"-fno-eliminate-unused-debug-types");
* Use the legacy behaviour (pre-SS11) * gcc does not need this. * Elimination and expansion of conditionals; * gcc has no direct equivalent. if (
strcmp(
arg,
"-Wd,-xsafe=unboundsym") == 0) {
* Prevents optimizing away checks for * unbound weak symbol addresses. gcc does * not do this, so it's not needed. * Prevents insertion of register symbols. * gcc doesn't do this, so ignore it. if (
strcmp(
arg,
"-Wc,-Qassembler-ounrefsym=0") == 0) {
* Prevents optimizing away of static variables. * gcc does not do this, so it's not needed. if (
strcmp(
arg,
"-Wu,-xmodel=kernel") == 0) {
model =
"-mcmodel=kernel";
/* Accept C++ style comments -- ignore */ * Compile for mapfile reordering, or unused * section elimination, syntax can be -xF or * more complex, like -xF=%all -- ignore. /* No inlining; ignore */ /* No incremental linking; ignore */ model =
"-mcmodel=kernel";
* For gcc-3.4.x at -O2 we * need to disable optimizations * limit -xO3 to -O2 as well. /* Just ignore -YS,... for now */ * We could map -Qy into -Wl,-Qy etc. "allowed only with -E or -P\n",
progname);
* Make sure that we do not have any unintended interactions between * the xarch options passed in and the version of the Studio compiler "Conflicting \"-xarch=\" flags (both Studio 11 and 12)\n");
* Only -m32 is defined and so put in the missing xarch * Only -m64 is defined and so put in the missing xarch /* no -m32/-m64 flag used - this is an error for sparc builds */ * 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 "Incompatible -xarch= and/or -m32/-m64 options used.\n");
"%s: invalid argument '%s'\n",
progname,
* 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)) {
* Only wait for one specific child. * cc returns an error code when given -V; we want that to succeed. * To avoid offending cc's sensibilities, the name of its output * 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++" /* assume "-_gcc" by default */ * -_compiler - tell us the path to the primary compiler only * -_versions - tell us the cw version, paths to all compilers, and * ask each for its version if we know how. (
void)
printf(
" (SHADOW MODE DISABLED)");