54 * -errtags=<a> Display messages with tags a(no, yes)
55 * -errwarn=<t> Treats warnings specified by tags t(%none, %all, <tag list>)
56 * as errors
57 * -fast Optimize using a selection of options
58 * -fd Report old-style function definitions and declarations
59 * -fnonstd Initialize floating-point hardware to non-standard preferences
60 * -fns[=<yes|no>] Select non-standard floating point mode
61 * -fprecision=<p> Set FP rounding precision mode p(single, double, extended)
62 * -fround=<r> Select the IEEE rounding mode in effect at startup
63 * -fsimple[=<n>] Select floating-point optimization preferences <n>
64 * -fsingle Use single-precision arithmetic (-Xt and -Xs modes only)
65 * -ftrap=<t> Select floating-point trapping mode in effect at startup
66 * -fstore force floating pt. values to target precision on assignment
67 * -G Build a dynamic shared library
68 * -g Compile for debugging
69 * -H Print path name of each file included during compilation
70 * -h <name> Assign <name> to generated dynamic shared library
71 * -I<dir> Add <dir> to preprocessor #include file search path
72 * -i Passed to linker to ignore any LD_LIBRARY_PATH setting
73 * -keeptmp Keep temporary files created during compilation
74 * -KPIC Compile position independent code with 32-bit addresses
75 * -Kpic Compile position independent code
76 * -L<dir> Pass to linker to add <dir> to the library search path
77 * -l<name> Link with library lib<name>.a or lib<name>.so
78 * -mc Remove duplicate strings from .comment section of output files
79 * -mr Remove all strings from .comment section of output files
80 * -mr,"string" Remove all strings and append "string" to .comment section
81 * -mt Specify options needed when compiling multi-threaded code
82 * -native Find available processor, generate code accordingly
83 * -nofstore Do not force floating pt. values to target precision
84 * on assignment
85 * -norunpath Do not build in a runtime path for shared libraries
86 * -O Use default optimization level (-xO2 or -xO3. Check man page.)
87 * -o <outputfile> Set name of output file to <outputfile>
88 * -P Compile source through preprocessor only, output to .i file
89 * -p Compile for profiling with prof
90 * -Q[y|n] Emit/don't emit identification info to output file
91 * -R<dir[:dir]> Build runtime search path list into executable
92 * -S Compile and only generate assembly code (.s)
93 * -s Strip symbol table from the executable file
94 * -t Turn off duplicate symbol warnings when linking
95 * -U<name> Delete initial definition of preprocessor symbol <name>
163 * -erroff=E_EMPTY_TRANSLATION_UNIT ignore
164 * -errtags=%all -Wall
165 * -errwarn=%all -Werror else -Wno-error
166 * -fast error
167 * -fd error
168 * -fnonstd error
169 * -fns[=<yes|no>] error
170 * -fprecision=<p> error
171 * -fround=<r> error
172 * -fsimple[=<n>] error
173 * -fsingle[=<n>] error
174 * -ftrap=<t> error
175 * -fstore error
176 * -G pass-thru
177 * -g pass-thru
178 * -H pass-thru
179 * -h <name> pass-thru
180 * -I<dir> pass-thru
181 * -i pass-thru
182 * -keeptmp -save-temps
183 * -KPIC -fPIC
184 * -Kpic -fpic
185 * -L<dir> pass-thru
186 * -l<name> pass-thru
187 * -mc error
188 * -mr error
189 * -mr,"string" error
190 * -mt -D_REENTRANT
191 * -native error
192 * -nofstore error
193 * -nolib -nodefaultlibs
194 * -norunpath ignore
195 * -O -O1 (Check the man page to be certain)
196 * -o <outputfile> pass-thru
197 * -P -E -o filename.i (or error)
198 * -p pass-thru
199 * -Q[y|n] error
200 * -R<dir[:dir]> pass-thru
201 * -S pass-thru
202 * -s -Wl,-s
203 * -t -Wl,-t
204 * -U<name> pass-thru
550 while (*table != NULL)
551 table++;
552 table++;
553 }
554
555 if (*table == NULL)
556 error(xarg);
557
558 table++;
559
560 while (*table != NULL) {
561 newae(h, *table);
562 table++;
563 }
564 }
565
566 static void
567 do_gcc(cw_ictx_t *ctx)
568 {
569 int c;
570 int pic = 0, nolibc = 0;
571 int in_output = 0, seen_o = 0, c_files = 0;
572 cw_op_t op = CW_O_LINK;
573 char *model = NULL;
574 char *nameflag;
575 int mflag = 0;
576
577 if (ctx->i_flags & CW_F_PROG) {
578 newae(ctx->i_ae, "--version");
579 return;
580 }
581
582 newae(ctx->i_ae, "-fident");
583 newae(ctx->i_ae, "-finline");
584 newae(ctx->i_ae, "-fno-inline-functions");
585 newae(ctx->i_ae, "-fno-builtin");
586 newae(ctx->i_ae, "-fno-asm");
587 newae(ctx->i_ae, "-fdiagnostics-show-option");
588 newae(ctx->i_ae, "-nodefaultlibs");
589
590 #if defined(__sparc)
686 continue;
687 }
688 #endif /* __sparc */
689 }
690
691 switch ((c = arg[1])) {
692 case '_':
693 if ((strncmp(arg, nameflag, strlen(nameflag)) == 0) ||
694 (strncmp(arg, "-_gcc=", 6) == 0) ||
695 (strncmp(arg, "-_gnu=", 6) == 0)) {
696 newae(ctx->i_ae, strchr(arg, '=') + 1);
697 }
698 break;
699 case '#':
700 if (arglen == 1) {
701 newae(ctx->i_ae, "-v");
702 break;
703 }
704 error(arg);
705 break;
706 case 'g':
707 newae(ctx->i_ae, "-gdwarf-2");
708 break;
709 case 'E':
710 if (arglen == 1) {
711 newae(ctx->i_ae, "-xc");
712 newae(ctx->i_ae, arg);
713 op = CW_O_PREPROCESS;
714 nolibc = 1;
715 break;
716 }
717 error(arg);
718 break;
719 case 'c':
720 case 'S':
721 if (arglen == 1) {
722 op = CW_O_COMPILE;
723 nolibc = 1;
724 }
725 /* FALLTHROUGH */
802 warnings(ctx->i_ae);
803 break;
804 }
805 if (strcmp(arg, "-errwarn=%all") == 0) {
806 newae(ctx->i_ae, "-Werror");
807 break;
808 }
809 error(arg);
810 break;
811 case 'G':
812 newae(ctx->i_ae, "-shared");
813 nolibc = 1;
814 break;
815 case 'k':
816 if (strcmp(arg, "-keeptmp") == 0) {
817 newae(ctx->i_ae, "-save-temps");
818 break;
819 }
820 error(arg);
821 break;
822 case 'K':
823 if (arglen == 1) {
824 if ((arg = *++ctx->i_oldargv) == NULL ||
825 *arg == '\0')
826 error("-K");
827 ctx->i_oldargc--;
828 } else {
829 arg += 2;
830 }
831 if (strcmp(arg, "pic") == 0) {
832 newae(ctx->i_ae, "-fpic");
833 pic = 1;
834 break;
835 }
836 if (strcmp(arg, "PIC") == 0) {
837 newae(ctx->i_ae, "-fPIC");
838 pic = 1;
839 break;
840 }
841 error("-K");
842 break;
843 case 'm':
844 if (strcmp(arg, "-mt") == 0) {
845 newae(ctx->i_ae, "-D_REENTRANT");
846 break;
847 }
848 if (strcmp(arg, "-m64") == 0) {
849 newae(ctx->i_ae, "-m64");
850 #if defined(__x86)
851 newae(ctx->i_ae, "-mtune=opteron");
852 #endif
853 mflag |= M64;
854 break;
855 }
856 if (strcmp(arg, "-m32") == 0) {
857 newae(ctx->i_ae, "-m32");
858 mflag |= M32;
859 break;
860 }
861 error(arg);
862 break;
969 break;
970 }
971 if (strcmp(arg, "-W2,-xwrap_int") == 0) {
972 /*
973 * Use the legacy behaviour (pre-SS11)
974 * for integer wrapping.
975 * gcc does not need this.
976 */
977 break;
978 }
979 if (strcmp(arg, "-Wd,-xsafe=unboundsym") == 0) {
980 /*
981 * Prevents optimizing away checks for
982 * unbound weak symbol addresses. gcc does
983 * not do this, so it's not needed.
984 */
985 break;
986 }
987 if (strncmp(arg, "-Wc,-xcode=", 11) == 0) {
988 xlate(ctx->i_ae, arg + 11, xcode_tbl);
989 if (strncmp(arg + 11, "pic", 3) == 0)
990 pic = 1;
991 break;
992 }
993 if (strncmp(arg, "-Wc,-Qiselect", 13) == 0) {
994 /*
995 * Prevents insertion of register symbols.
996 * gcc doesn't do this, so ignore it.
997 */
998 break;
999 }
1000 if (strcmp(arg, "-Wc,-Qassembler-ounrefsym=0") == 0) {
1001 /*
1002 * Prevents optimizing away of static variables.
1003 * gcc does not do this, so it's not needed.
1004 */
1005 break;
1006 }
1007 #if defined(__x86)
1008 if (strcmp(arg, "-Wu,-save_args") == 0) {
1009 newae(ctx->i_ae, "-msave-args");
1010 break;
1047 /* Accept C++ style comments -- ignore */
1048 if (strcmp(arg, "-xCC") == 0)
1049 break;
1050 error(arg);
1051 break;
1052 case 'c':
1053 if (strncmp(arg, "-xc99=%all", 10) == 0) {
1054 newae(ctx->i_ae, "-std=gnu99");
1055 break;
1056 }
1057 if (strncmp(arg, "-xc99=%none", 11) == 0) {
1058 newae(ctx->i_ae, "-std=gnu89");
1059 break;
1060 }
1061 if (strncmp(arg, "-xchip=", 7) == 0) {
1062 xlate(ctx->i_ae, arg + 7, xchip_tbl);
1063 break;
1064 }
1065 if (strncmp(arg, "-xcode=", 7) == 0) {
1066 xlate(ctx->i_ae, arg + 7, xcode_tbl);
1067 if (strncmp(arg + 7, "pic", 3) == 0)
1068 pic = 1;
1069 break;
1070 }
1071 if (strncmp(arg, "-xcrossfile", 11) == 0)
1072 break;
1073 error(arg);
1074 break;
1075 case 'd':
1076 if (strncmp(arg, "-xdebugformat=", 14) == 0)
1077 break;
1078 error(arg);
1079 break;
1080 case 'F':
1081 /*
1082 * Compile for mapfile reordering, or unused
1083 * section elimination, syntax can be -xF or
1084 * more complex, like -xF=%all -- ignore.
1085 */
1086 if (strncmp(arg, "-xF", 3) == 0)
1087 break;
1088 error(arg);
1271 * Need to add in further 32 bit options because with SS12
1272 * the xarch=sparcvis option can be applied to 32 or 64
1273 * bit, and so the translatation table (xtbl) cannot handle
1274 * that.
1275 */
1276 newae(ctx->i_ae, "-mv8plus");
1277 #endif
1278 break;
1279 case (SS12|M64):
1280 break;
1281 default:
1282 (void) fprintf(stderr,
1283 "Incompatible -xarch= and/or -m32/-m64 options used.\n");
1284 exit(2);
1285 }
1286
1287 if ((op == CW_O_LINK || op == CW_O_PREPROCESS) &&
1288 (ctx->i_flags & CW_F_SHADOW))
1289 exit(0);
1290
1291 if (model && !pic)
1292 newae(ctx->i_ae, model);
1293 if (!nolibc)
1294 newae(ctx->i_ae, "-lc");
1295 if (!seen_o && (ctx->i_flags & CW_F_SHADOW)) {
1296 newae(ctx->i_ae, "-o");
1297 newae(ctx->i_ae, ctx->i_discard);
1298 }
1299 }
1300
1301 static void
1302 do_cc(cw_ictx_t *ctx)
1303 {
1304 int in_output = 0, seen_o = 0;
1305 cw_op_t op = CW_O_LINK;
1306 char *nameflag;
1307
1308 if (ctx->i_flags & CW_F_PROG) {
1309 newae(ctx->i_ae, "-V");
1310 return;
1311 }
|
54 * -errtags=<a> Display messages with tags a(no, yes)
55 * -errwarn=<t> Treats warnings specified by tags t(%none, %all, <tag list>)
56 * as errors
57 * -fast Optimize using a selection of options
58 * -fd Report old-style function definitions and declarations
59 * -fnonstd Initialize floating-point hardware to non-standard preferences
60 * -fns[=<yes|no>] Select non-standard floating point mode
61 * -fprecision=<p> Set FP rounding precision mode p(single, double, extended)
62 * -fround=<r> Select the IEEE rounding mode in effect at startup
63 * -fsimple[=<n>] Select floating-point optimization preferences <n>
64 * -fsingle Use single-precision arithmetic (-Xt and -Xs modes only)
65 * -ftrap=<t> Select floating-point trapping mode in effect at startup
66 * -fstore force floating pt. values to target precision on assignment
67 * -G Build a dynamic shared library
68 * -g Compile for debugging
69 * -H Print path name of each file included during compilation
70 * -h <name> Assign <name> to generated dynamic shared library
71 * -I<dir> Add <dir> to preprocessor #include file search path
72 * -i Passed to linker to ignore any LD_LIBRARY_PATH setting
73 * -keeptmp Keep temporary files created during compilation
74 * -L<dir> Pass to linker to add <dir> to the library search path
75 * -l<name> Link with library lib<name>.a or lib<name>.so
76 * -mc Remove duplicate strings from .comment section of output files
77 * -mr Remove all strings from .comment section of output files
78 * -mr,"string" Remove all strings and append "string" to .comment section
79 * -mt Specify options needed when compiling multi-threaded code
80 * -native Find available processor, generate code accordingly
81 * -nofstore Do not force floating pt. values to target precision
82 * on assignment
83 * -norunpath Do not build in a runtime path for shared libraries
84 * -O Use default optimization level (-xO2 or -xO3. Check man page.)
85 * -o <outputfile> Set name of output file to <outputfile>
86 * -P Compile source through preprocessor only, output to .i file
87 * -p Compile for profiling with prof
88 * -Q[y|n] Emit/don't emit identification info to output file
89 * -R<dir[:dir]> Build runtime search path list into executable
90 * -S Compile and only generate assembly code (.s)
91 * -s Strip symbol table from the executable file
92 * -t Turn off duplicate symbol warnings when linking
93 * -U<name> Delete initial definition of preprocessor symbol <name>
161 * -erroff=E_EMPTY_TRANSLATION_UNIT ignore
162 * -errtags=%all -Wall
163 * -errwarn=%all -Werror else -Wno-error
164 * -fast error
165 * -fd error
166 * -fnonstd error
167 * -fns[=<yes|no>] error
168 * -fprecision=<p> error
169 * -fround=<r> error
170 * -fsimple[=<n>] error
171 * -fsingle[=<n>] error
172 * -ftrap=<t> error
173 * -fstore error
174 * -G pass-thru
175 * -g pass-thru
176 * -H pass-thru
177 * -h <name> pass-thru
178 * -I<dir> pass-thru
179 * -i pass-thru
180 * -keeptmp -save-temps
181 * -L<dir> pass-thru
182 * -l<name> pass-thru
183 * -mc error
184 * -mr error
185 * -mr,"string" error
186 * -mt -D_REENTRANT
187 * -native error
188 * -nofstore error
189 * -nolib -nodefaultlibs
190 * -norunpath ignore
191 * -O -O1 (Check the man page to be certain)
192 * -o <outputfile> pass-thru
193 * -P -E -o filename.i (or error)
194 * -p pass-thru
195 * -Q[y|n] error
196 * -R<dir[:dir]> pass-thru
197 * -S pass-thru
198 * -s -Wl,-s
199 * -t -Wl,-t
200 * -U<name> pass-thru
546 while (*table != NULL)
547 table++;
548 table++;
549 }
550
551 if (*table == NULL)
552 error(xarg);
553
554 table++;
555
556 while (*table != NULL) {
557 newae(h, *table);
558 table++;
559 }
560 }
561
562 static void
563 do_gcc(cw_ictx_t *ctx)
564 {
565 int c;
566 int nolibc = 0;
567 int in_output = 0, seen_o = 0, c_files = 0;
568 cw_op_t op = CW_O_LINK;
569 char *model = NULL;
570 char *nameflag;
571 int mflag = 0;
572
573 if (ctx->i_flags & CW_F_PROG) {
574 newae(ctx->i_ae, "--version");
575 return;
576 }
577
578 newae(ctx->i_ae, "-fident");
579 newae(ctx->i_ae, "-finline");
580 newae(ctx->i_ae, "-fno-inline-functions");
581 newae(ctx->i_ae, "-fno-builtin");
582 newae(ctx->i_ae, "-fno-asm");
583 newae(ctx->i_ae, "-fdiagnostics-show-option");
584 newae(ctx->i_ae, "-nodefaultlibs");
585
586 #if defined(__sparc)
682 continue;
683 }
684 #endif /* __sparc */
685 }
686
687 switch ((c = arg[1])) {
688 case '_':
689 if ((strncmp(arg, nameflag, strlen(nameflag)) == 0) ||
690 (strncmp(arg, "-_gcc=", 6) == 0) ||
691 (strncmp(arg, "-_gnu=", 6) == 0)) {
692 newae(ctx->i_ae, strchr(arg, '=') + 1);
693 }
694 break;
695 case '#':
696 if (arglen == 1) {
697 newae(ctx->i_ae, "-v");
698 break;
699 }
700 error(arg);
701 break;
702 case 'f':
703 if ((strcmp(arg, "-fpic") == 0) ||
704 (strcmp(arg, "-fPIC") == 0)) {
705 newae(ctx->i_ae, arg);
706 break;
707 }
708 error(arg);
709 break;
710 case 'g':
711 newae(ctx->i_ae, "-gdwarf-2");
712 break;
713 case 'E':
714 if (arglen == 1) {
715 newae(ctx->i_ae, "-xc");
716 newae(ctx->i_ae, arg);
717 op = CW_O_PREPROCESS;
718 nolibc = 1;
719 break;
720 }
721 error(arg);
722 break;
723 case 'c':
724 case 'S':
725 if (arglen == 1) {
726 op = CW_O_COMPILE;
727 nolibc = 1;
728 }
729 /* FALLTHROUGH */
806 warnings(ctx->i_ae);
807 break;
808 }
809 if (strcmp(arg, "-errwarn=%all") == 0) {
810 newae(ctx->i_ae, "-Werror");
811 break;
812 }
813 error(arg);
814 break;
815 case 'G':
816 newae(ctx->i_ae, "-shared");
817 nolibc = 1;
818 break;
819 case 'k':
820 if (strcmp(arg, "-keeptmp") == 0) {
821 newae(ctx->i_ae, "-save-temps");
822 break;
823 }
824 error(arg);
825 break;
826 case 'm':
827 if (strcmp(arg, "-mt") == 0) {
828 newae(ctx->i_ae, "-D_REENTRANT");
829 break;
830 }
831 if (strcmp(arg, "-m64") == 0) {
832 newae(ctx->i_ae, "-m64");
833 #if defined(__x86)
834 newae(ctx->i_ae, "-mtune=opteron");
835 #endif
836 mflag |= M64;
837 break;
838 }
839 if (strcmp(arg, "-m32") == 0) {
840 newae(ctx->i_ae, "-m32");
841 mflag |= M32;
842 break;
843 }
844 error(arg);
845 break;
952 break;
953 }
954 if (strcmp(arg, "-W2,-xwrap_int") == 0) {
955 /*
956 * Use the legacy behaviour (pre-SS11)
957 * for integer wrapping.
958 * gcc does not need this.
959 */
960 break;
961 }
962 if (strcmp(arg, "-Wd,-xsafe=unboundsym") == 0) {
963 /*
964 * Prevents optimizing away checks for
965 * unbound weak symbol addresses. gcc does
966 * not do this, so it's not needed.
967 */
968 break;
969 }
970 if (strncmp(arg, "-Wc,-xcode=", 11) == 0) {
971 xlate(ctx->i_ae, arg + 11, xcode_tbl);
972 break;
973 }
974 if (strncmp(arg, "-Wc,-Qiselect", 13) == 0) {
975 /*
976 * Prevents insertion of register symbols.
977 * gcc doesn't do this, so ignore it.
978 */
979 break;
980 }
981 if (strcmp(arg, "-Wc,-Qassembler-ounrefsym=0") == 0) {
982 /*
983 * Prevents optimizing away of static variables.
984 * gcc does not do this, so it's not needed.
985 */
986 break;
987 }
988 #if defined(__x86)
989 if (strcmp(arg, "-Wu,-save_args") == 0) {
990 newae(ctx->i_ae, "-msave-args");
991 break;
1028 /* Accept C++ style comments -- ignore */
1029 if (strcmp(arg, "-xCC") == 0)
1030 break;
1031 error(arg);
1032 break;
1033 case 'c':
1034 if (strncmp(arg, "-xc99=%all", 10) == 0) {
1035 newae(ctx->i_ae, "-std=gnu99");
1036 break;
1037 }
1038 if (strncmp(arg, "-xc99=%none", 11) == 0) {
1039 newae(ctx->i_ae, "-std=gnu89");
1040 break;
1041 }
1042 if (strncmp(arg, "-xchip=", 7) == 0) {
1043 xlate(ctx->i_ae, arg + 7, xchip_tbl);
1044 break;
1045 }
1046 if (strncmp(arg, "-xcode=", 7) == 0) {
1047 xlate(ctx->i_ae, arg + 7, xcode_tbl);
1048 break;
1049 }
1050 if (strncmp(arg, "-xcrossfile", 11) == 0)
1051 break;
1052 error(arg);
1053 break;
1054 case 'd':
1055 if (strncmp(arg, "-xdebugformat=", 14) == 0)
1056 break;
1057 error(arg);
1058 break;
1059 case 'F':
1060 /*
1061 * Compile for mapfile reordering, or unused
1062 * section elimination, syntax can be -xF or
1063 * more complex, like -xF=%all -- ignore.
1064 */
1065 if (strncmp(arg, "-xF", 3) == 0)
1066 break;
1067 error(arg);
1250 * Need to add in further 32 bit options because with SS12
1251 * the xarch=sparcvis option can be applied to 32 or 64
1252 * bit, and so the translatation table (xtbl) cannot handle
1253 * that.
1254 */
1255 newae(ctx->i_ae, "-mv8plus");
1256 #endif
1257 break;
1258 case (SS12|M64):
1259 break;
1260 default:
1261 (void) fprintf(stderr,
1262 "Incompatible -xarch= and/or -m32/-m64 options used.\n");
1263 exit(2);
1264 }
1265
1266 if ((op == CW_O_LINK || op == CW_O_PREPROCESS) &&
1267 (ctx->i_flags & CW_F_SHADOW))
1268 exit(0);
1269
1270 if (model != NULL)
1271 newae(ctx->i_ae, model);
1272 if (!nolibc)
1273 newae(ctx->i_ae, "-lc");
1274 if (!seen_o && (ctx->i_flags & CW_F_SHADOW)) {
1275 newae(ctx->i_ae, "-o");
1276 newae(ctx->i_ae, ctx->i_discard);
1277 }
1278 }
1279
1280 static void
1281 do_cc(cw_ictx_t *ctx)
1282 {
1283 int in_output = 0, seen_o = 0;
1284 cw_op_t op = CW_O_LINK;
1285 char *nameflag;
1286
1287 if (ctx->i_flags & CW_F_PROG) {
1288 newae(ctx->i_ae, "-V");
1289 return;
1290 }
|