Print this page
10051 cw(1) shouldn't have to translate -g


  20  * CDDL HEADER END
  21  */
  22 
  23 /*
  24  * Copyright 2018, Richard Lowe.
  25  */
  26 /*
  27  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  28  * Use is subject to license terms.
  29  */
  30 
  31 /*
  32  * Wrapper for the GNU C compiler to make it accept the Sun C compiler
  33  * arguments where possible.
  34  *
  35  * Since the translation is inexact, this is something of a work-in-progress.
  36  *
  37  */
  38 
  39 /* If you modify this file, you must increment CW_VERSION */
  40 #define CW_VERSION      "3.0"
  41 
  42 /*
  43  * -#           Verbose mode
  44  * -###         Show compiler commands built by driver, no compilation
  45  * -A<name[(tokens)]>     Preprocessor predicate assertion
  46  * -B<[static|dynamic]>   Specify dynamic or static binding
  47  * -C           Prevent preprocessor from removing comments
  48  * -c           Compile only - produce .o files, suppress linking
  49  * -cg92        Alias for -xtarget=ss1000
  50  * -D<name[=token]>       Associate name with token as if by #define
  51  * -d[y|n]      dynamic [-dy] or static [-dn] option to linker
  52  * -E           Compile source through preprocessor only, output to stdout
  53  * -erroff=<t>    Suppress warnings specified by tags t(%none, %all, <tag list>)
  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


 198  * -s                           -Wl,-s
 199  * -t                           -Wl,-t
 200  * -U<name>                       pass-thru
 201  * -V                           --version
 202  * -v                           -Wall
 203  * -Wa,<arg>                      pass-thru
 204  * -Wp,<arg>                      pass-thru except -xc99=<a>
 205  * -Wl,<arg>                      pass-thru
 206  * -W{m,0,2,h,i,u>           error/ignore
 207  * -xmodel=kernel               -ffreestanding -mcmodel=kernel -mno-red-zone
 208  * -Wu,-save_args               -msave-args
 209  * -w                           pass-thru
 210  * -Xa                          -std=iso9899:199409 or -ansi
 211  * -Xt                          error
 212  * -Xs                          -traditional -std=c89
 213  * -xarch=<a>                     table
 214  * -xbuiltin[=<b>]                -fbuiltin (-fno-builtin otherwise)
 215  * -xCC                         ignore
 216  * -xchip=<c>                     table
 217  * -xcode=<c>                     table
 218  * -xdebugformat=<format> ignore (always use dwarf-2 for gcc)
 219  * -xcrossfile[=<n>]              ignore
 220  * -xe                          error
 221  * -xF                          error
 222  * -xhelp=<f>                     error
 223  * -xildoff                     ignore
 224  * -xildon                      ignore
 225  * -xinline                     ignore
 226  * -xlibmieee                   error
 227  * -xlibmil                     error
 228  * -xlic_lib=sunperf            error
 229  * -xmaxopt=[...]               error
 230  * -xO<n>                 -O<n>
 231  * -xP                          error
 232  * -xprofile=<p>          error
 233  * -xregs=<r>                     table
 234  * -xs                          error
 235  * -xsb                         error
 236  * -xsbfast                     error
 237  * -xsfpconst                   error
 238  * -xspace                      ignore (-not -Os)


 715                             (strncmp(arg, "-_gcc=", 6) == 0) ||
 716                             (strncmp(arg, "-_gnu=", 6) == 0)) {
 717                                 newae(ctx->i_ae, strchr(arg, '=') + 1);
 718                         }
 719                         break;
 720                 case '#':
 721                         if (arglen == 1) {
 722                                 newae(ctx->i_ae, "-v");
 723                                 break;
 724                         }
 725                         error(arg);
 726                         break;
 727                 case 'f':
 728                         if ((strcmp(arg, "-fpic") == 0) ||
 729                             (strcmp(arg, "-fPIC") == 0)) {
 730                                 newae(ctx->i_ae, arg);
 731                                 break;
 732                         }
 733                         error(arg);
 734                         break;
 735                 case 'g':
 736                         newae(ctx->i_ae, "-gdwarf-2");
 737                         break;
 738                 case 'E':
 739                         if (arglen == 1) {
 740                                 newae(ctx->i_ae, "-xc");
 741                                 newae(ctx->i_ae, arg);
 742                                 op = CW_O_PREPROCESS;
 743                                 nolibc = 1;
 744                                 break;
 745                         }
 746                         error(arg);
 747                         break;
 748                 case 'c':
 749                 case 'S':
 750                         if (arglen == 1) {
 751                                 op = CW_O_COMPILE;
 752                                 nolibc = 1;
 753                         }
 754                         /* FALLTHROUGH */
 755                 case 'C':
 756                 case 'H':
 757                 case 'p':
 758                         if (arglen == 1) {
 759                                 newae(ctx->i_ae, arg);
 760                                 break;
 761                         }
 762                         error(arg);
 763                         break;
 764                 case 'A':

 765                 case 'h':
 766                 case 'I':
 767                 case 'i':
 768                 case 'L':
 769                 case 'l':
 770                 case 'R':
 771                 case 'U':
 772                 case 'u':
 773                 case 'w':
 774                         newae(ctx->i_ae, arg);
 775                         break;
 776                 case 'o':
 777                         seen_o = 1;
 778                         if (arglen == 1) {
 779                                 in_output = 1;
 780                                 newae(ctx->i_ae, arg);
 781                         } else if (ctx->i_flags & CW_F_SHADOW) {
 782                                 newae(ctx->i_ae, "-o");
 783                                 ctx->i_discard = discard_file_name(arg);
 784                                 newae(ctx->i_ae, ctx->i_discard);


1056                                 error(arg);
1057                                 break;
1058                         case 'c':
1059                                 if (strncmp(arg, "-xc99=%all", 10) == 0) {
1060                                         newae(ctx->i_ae, "-std=gnu99");
1061                                         break;
1062                                 }
1063                                 if (strncmp(arg, "-xc99=%none", 11) == 0) {
1064                                         newae(ctx->i_ae, "-std=gnu89");
1065                                         break;
1066                                 }
1067                                 if (strncmp(arg, "-xchip=", 7) == 0) {
1068                                         xlate(ctx->i_ae, arg + 7, xchip_tbl);
1069                                         break;
1070                                 }
1071                                 if (strncmp(arg, "-xcode=", 7) == 0) {
1072                                         xlate(ctx->i_ae, arg + 7, xcode_tbl);
1073                                         break;
1074                                 }
1075                                 if (strncmp(arg, "-xcrossfile", 11) == 0)
1076                                         break;
1077                                 error(arg);
1078                                 break;
1079                         case 'd':
1080                                 if (strncmp(arg, "-xdebugformat=", 14) == 0)
1081                                         break;
1082                                 error(arg);
1083                                 break;
1084                         case 'F':
1085                                 /*
1086                                  * Compile for mapfile reordering, or unused
1087                                  * section elimination, syntax can be -xF or
1088                                  * more complex, like -xF=%all -- ignore.
1089                                  */
1090                                 if (strncmp(arg, "-xF", 3) == 0)
1091                                         break;
1092                                 error(arg);
1093                                 break;
1094                         case 'i':
1095                                 if (strncmp(arg, "-xinline", 8) == 0)
1096                                         /* No inlining; ignore */
1097                                         break;
1098                                 if (strcmp(arg, "-xildon") == 0 ||
1099                                     strcmp(arg, "-xildoff") == 0)
1100                                         /* No incremental linking; ignore */




  20  * CDDL HEADER END
  21  */
  22 
  23 /*
  24  * Copyright 2018, Richard Lowe.
  25  */
  26 /*
  27  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  28  * Use is subject to license terms.
  29  */
  30 
  31 /*
  32  * Wrapper for the GNU C compiler to make it accept the Sun C compiler
  33  * arguments where possible.
  34  *
  35  * Since the translation is inexact, this is something of a work-in-progress.
  36  *
  37  */
  38 
  39 /* If you modify this file, you must increment CW_VERSION */
  40 #define CW_VERSION      "4.0"
  41 
  42 /*
  43  * -#           Verbose mode
  44  * -###         Show compiler commands built by driver, no compilation
  45  * -A<name[(tokens)]>     Preprocessor predicate assertion
  46  * -B<[static|dynamic]>   Specify dynamic or static binding
  47  * -C           Prevent preprocessor from removing comments
  48  * -c           Compile only - produce .o files, suppress linking
  49  * -cg92        Alias for -xtarget=ss1000
  50  * -D<name[=token]>       Associate name with token as if by #define
  51  * -d[y|n]      dynamic [-dy] or static [-dn] option to linker
  52  * -E           Compile source through preprocessor only, output to stdout
  53  * -erroff=<t>    Suppress warnings specified by tags t(%none, %all, <tag list>)
  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


 198  * -s                           -Wl,-s
 199  * -t                           -Wl,-t
 200  * -U<name>                       pass-thru
 201  * -V                           --version
 202  * -v                           -Wall
 203  * -Wa,<arg>                      pass-thru
 204  * -Wp,<arg>                      pass-thru except -xc99=<a>
 205  * -Wl,<arg>                      pass-thru
 206  * -W{m,0,2,h,i,u>           error/ignore
 207  * -xmodel=kernel               -ffreestanding -mcmodel=kernel -mno-red-zone
 208  * -Wu,-save_args               -msave-args
 209  * -w                           pass-thru
 210  * -Xa                          -std=iso9899:199409 or -ansi
 211  * -Xt                          error
 212  * -Xs                          -traditional -std=c89
 213  * -xarch=<a>                     table
 214  * -xbuiltin[=<b>]                -fbuiltin (-fno-builtin otherwise)
 215  * -xCC                         ignore
 216  * -xchip=<c>                     table
 217  * -xcode=<c>                     table

 218  * -xcrossfile[=<n>]              ignore
 219  * -xe                          error
 220  * -xF                          error
 221  * -xhelp=<f>                     error
 222  * -xildoff                     ignore
 223  * -xildon                      ignore
 224  * -xinline                     ignore
 225  * -xlibmieee                   error
 226  * -xlibmil                     error
 227  * -xlic_lib=sunperf            error
 228  * -xmaxopt=[...]               error
 229  * -xO<n>                 -O<n>
 230  * -xP                          error
 231  * -xprofile=<p>          error
 232  * -xregs=<r>                     table
 233  * -xs                          error
 234  * -xsb                         error
 235  * -xsbfast                     error
 236  * -xsfpconst                   error
 237  * -xspace                      ignore (-not -Os)


 714                             (strncmp(arg, "-_gcc=", 6) == 0) ||
 715                             (strncmp(arg, "-_gnu=", 6) == 0)) {
 716                                 newae(ctx->i_ae, strchr(arg, '=') + 1);
 717                         }
 718                         break;
 719                 case '#':
 720                         if (arglen == 1) {
 721                                 newae(ctx->i_ae, "-v");
 722                                 break;
 723                         }
 724                         error(arg);
 725                         break;
 726                 case 'f':
 727                         if ((strcmp(arg, "-fpic") == 0) ||
 728                             (strcmp(arg, "-fPIC") == 0)) {
 729                                 newae(ctx->i_ae, arg);
 730                                 break;
 731                         }
 732                         error(arg);
 733                         break;



 734                 case 'E':
 735                         if (arglen == 1) {
 736                                 newae(ctx->i_ae, "-xc");
 737                                 newae(ctx->i_ae, arg);
 738                                 op = CW_O_PREPROCESS;
 739                                 nolibc = 1;
 740                                 break;
 741                         }
 742                         error(arg);
 743                         break;
 744                 case 'c':
 745                 case 'S':
 746                         if (arglen == 1) {
 747                                 op = CW_O_COMPILE;
 748                                 nolibc = 1;
 749                         }
 750                         /* FALLTHROUGH */
 751                 case 'C':
 752                 case 'H':
 753                 case 'p':
 754                         if (arglen == 1) {
 755                                 newae(ctx->i_ae, arg);
 756                                 break;
 757                         }
 758                         error(arg);
 759                         break;
 760                 case 'A':
 761                 case 'g':
 762                 case 'h':
 763                 case 'I':
 764                 case 'i':
 765                 case 'L':
 766                 case 'l':
 767                 case 'R':
 768                 case 'U':
 769                 case 'u':
 770                 case 'w':
 771                         newae(ctx->i_ae, arg);
 772                         break;
 773                 case 'o':
 774                         seen_o = 1;
 775                         if (arglen == 1) {
 776                                 in_output = 1;
 777                                 newae(ctx->i_ae, arg);
 778                         } else if (ctx->i_flags & CW_F_SHADOW) {
 779                                 newae(ctx->i_ae, "-o");
 780                                 ctx->i_discard = discard_file_name(arg);
 781                                 newae(ctx->i_ae, ctx->i_discard);


1053                                 error(arg);
1054                                 break;
1055                         case 'c':
1056                                 if (strncmp(arg, "-xc99=%all", 10) == 0) {
1057                                         newae(ctx->i_ae, "-std=gnu99");
1058                                         break;
1059                                 }
1060                                 if (strncmp(arg, "-xc99=%none", 11) == 0) {
1061                                         newae(ctx->i_ae, "-std=gnu89");
1062                                         break;
1063                                 }
1064                                 if (strncmp(arg, "-xchip=", 7) == 0) {
1065                                         xlate(ctx->i_ae, arg + 7, xchip_tbl);
1066                                         break;
1067                                 }
1068                                 if (strncmp(arg, "-xcode=", 7) == 0) {
1069                                         xlate(ctx->i_ae, arg + 7, xcode_tbl);
1070                                         break;
1071                                 }
1072                                 if (strncmp(arg, "-xcrossfile", 11) == 0)





1073                                         break;
1074                                 error(arg);
1075                                 break;
1076                         case 'F':
1077                                 /*
1078                                  * Compile for mapfile reordering, or unused
1079                                  * section elimination, syntax can be -xF or
1080                                  * more complex, like -xF=%all -- ignore.
1081                                  */
1082                                 if (strncmp(arg, "-xF", 3) == 0)
1083                                         break;
1084                                 error(arg);
1085                                 break;
1086                         case 'i':
1087                                 if (strncmp(arg, "-xinline", 8) == 0)
1088                                         /* No inlining; ignore */
1089                                         break;
1090                                 if (strcmp(arg, "-xildon") == 0 ||
1091                                     strcmp(arg, "-xildoff") == 0)
1092                                         /* No incremental linking; ignore */