Print this page
make: ship the Joyent patch to enable parallel make (originally from rm)

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/make/bin/main.cc
          +++ new/usr/src/cmd/make/bin/main.cc
↓ open down ↓ 26 lines elided ↑ open up ↑
  27   27   *      main.cc
  28   28   *
  29   29   *      make program main routine plus some helper routines
  30   30   */
  31   31   
  32   32  /*
  33   33   * Included files
  34   34   */
  35   35  #if defined(TEAMWARE_MAKE_CMN)
  36   36  #       include <avo/intl.h>
  37      -#       include <avo/libcli.h>          /* libcli_init() */
  38      -#       include <avo/cli_license.h>     /* avo_cli_get_license() */
  39      -#       include <avo/find_dir.h>        /* avo_find_run_dir() */
  40      -#       include <avo/version_string.h>
  41      -#       include <avo/util.h>            /* avo_init() */
  42      -#       include <avo/cleanup.h>
  43   37  #endif
  44   38  
  45   39  #include <bsd/bsd.h>            /* bsd_signal() */
  46   40  
  47   41  #ifdef DISTRIBUTED
  48   42  #       include <dm/Avo_AcknowledgeMsg.h>
  49   43  #       include <rw/xdrstrea.h>
  50   44  #       include <dmrc/dmrc.h> /* dmakerc file processing */
  51   45  #endif
  52   46  
↓ open down ↓ 30 lines elided ↑ open up ↑
  83   77  
  84   78  #ifdef MAXJOBS_ADJUST_RFE4694000
  85   79  extern void job_adjust_fini();
  86   80  #endif /* MAXJOBS_ADJUST_RFE4694000 */
  87   81  #endif /* TEAMWARE_MAKE_CMN */
  88   82  
  89   83  
  90   84  /*
  91   85   * Defined macros
  92   86   */
  93      -#define LD_SUPPORT_ENV_VAR      NOCATGETS("SGS_SUPPORT")
       87 +#define MAKE_PREFIX             NOCATGETS("/usr")
       88 +#define LD_SUPPORT_ENV_VAR      NOCATGETS("SGS_SUPPORT_32")
       89 +#define LD_SUPPORT_ENV_VAR_32   NOCATGETS("SGS_SUPPORT_32")
       90 +#define LD_SUPPORT_ENV_VAR_64   NOCATGETS("SGS_SUPPORT_64")
  94   91  #define LD_SUPPORT_MAKE_LIB     NOCATGETS("libmakestate.so.1")
       92 +#define LD_SUPPORT_MAKE_LIB_DIR NOCATGETS("/lib")
       93 +#define LD_SUPPORT_MAKE_LIB_DIR_64      NOCATGETS("/64")
  95   94  
  96   95  /*
  97   96   * typedefs & structs
  98   97   */
  99   98  
 100   99  /*
 101  100   * Static variables
 102  101   */
 103  102  static  char            *argv_zero_string;
 104  103  static  Boolean         build_failed_ever_seen;
↓ open down ↓ 19 lines elided ↑ open up ↑
 124  123  static  Boolean         trace_status;                   /* `-p' */
 125  124  
 126  125  #ifdef DMAKE_STATISTICS
 127  126  static  Boolean         getname_stat = false;
 128  127  #endif
 129  128  
 130  129  #if defined(TEAMWARE_MAKE_CMN)
 131  130          static  time_t          start_time;
 132  131          static  int             g_argc;
 133  132          static  char            **g_argv;
 134      -        static  Avo_cleanup     *cleanup = NULL;
 135  133  #endif
 136  134  
 137  135  /*
 138  136   * File table of contents
 139  137   */
 140  138          extern "C" void         cleanup_after_exit(void);
 141  139  
 142  140  #ifdef TEAMWARE_MAKE_CMN
 143  141  extern "C" {
 144  142          extern  void            dmake_exit_callback(void);
↓ open down ↓ 22 lines elided ↑ open up ↑
 167  165  
 168  166  extern void expand_value(Name, register String , Boolean);
 169  167  
 170  168  #ifdef DISTRIBUTED
 171  169          extern  int             dmake_ofd;
 172  170          extern  FILE*           dmake_ofp;
 173  171          extern  int             rxmPid;
 174  172          extern  XDR             xdrs_out;
 175  173  #endif
 176  174  #ifdef TEAMWARE_MAKE_CMN
 177      -        extern  char            verstring[];
      175 +        static const char       verstring[] = "illumos make";
 178  176  #endif
 179  177  
 180  178  jmp_buf jmpbuffer;
 181  179  extern nl_catd catd;
 182  180  
 183  181  /*
 184  182   *      main(argc, argv)
 185  183   *
 186  184   *      Parameters:
 187  185   *              argc                    You know what this is
↓ open down ↓ 34 lines elided ↑ open up ↑
 222  220          char                    def_dmakerc_path[MAXPATHLEN];
 223  221          Name                    dmake_name, dmake_name2;
 224  222          Name                    dmake_value, dmake_value2;
 225  223          Property                prop, prop2;
 226  224          struct stat             statbuf;
 227  225          int                     statval;
 228  226  #endif
 229  227  
 230  228          struct stat             out_stat, err_stat;
 231  229          hostid = gethostid();
 232      -#ifdef TEAMWARE_MAKE_CMN
 233      -        avo_get_user(NULL, NULL); // Initialize user name
 234      -#endif
 235  230          bsd_signals();
 236  231  
 237  232          (void) setlocale(LC_ALL, "");
 238  233  
 239  234  
 240  235  #ifdef DMAKE_STATISTICS
 241  236          if (getenv(NOCATGETS("DMAKE_STATISTICS"))) {
 242  237                  getname_stat = true;
 243  238          }
 244  239  #endif
 245  240  
 246      -
 247      -        /*
 248      -         * avo_init() sets the umask to 0.  Save it here and restore
 249      -         * it after the avo_init() call.
 250      -         */
 251      -#if defined(TEAMWARE_MAKE_CMN) || defined(MAKETOOL)
 252      -        um = umask(0);
 253      -        avo_init(argv[0]);
 254      -        umask(um);
 255      -
 256      -        cleanup = new Avo_cleanup(NOCATGETS("dmake"), argc, argv);
 257      -#endif
 258      -
 259  241  #if defined(TEAMWARE_MAKE_CMN)
 260  242          catd = catopen(AVO_DOMAIN_DMAKE, NL_CAT_LOCALE);
 261      -        libcli_init();
 262  243  #endif
 263  244  
 264  245  // ---> fprintf(stderr, catgets(catd, 15, 666, "--- SUN make ---\n"));
 265  246  
 266  247  
 267  248  #if defined(TEAMWARE_MAKE_CMN) || defined(MAKETOOL)
 268  249  /*
 269  250   * I put libmksdmsi18n_init() under #ifdef because it requires avo_i18n_init()
 270  251   * from avo_util library. 
 271  252   */
↓ open down ↓ 253 lines elided ↑ open up ↑
 525  506                                          putenv(NOCATGETS("DMAKE_DEF_PRINTED=TRUE"));
 526  507                                          (void) fprintf(stdout, catgets(catd, 1, 302, "dmake: defaulting to parallel mode.\n"));
 527  508                                          (void) fprintf(stdout, catgets(catd, 1, 303, "See the man page dmake(1) for more information on setting up the .dmakerc file.\n"));
 528  509                                  }
 529  510                                  dmake_mode_type = parallel_mode;
 530  511                                  no_parallel = false;
 531  512                          }
 532  513                  }
 533  514  #else
 534  515                  if(dmake_mode_type == distributed_mode) {
 535      -                        (void) fprintf(stdout, NOCATGETS("dmake: Distributed mode not implemented.\n"));
 536      -                        (void) fprintf(stdout, NOCATGETS("       Defaulting to parallel mode.\n"));
 537  516                          dmake_mode_type = parallel_mode;
 538  517                          no_parallel = false;
 539  518                  }
 540  519  #endif  /* DISTRIBUTED */
 541  520          }
 542  521      }
 543  522  #endif
 544  523  
 545  524  #ifdef TEAMWARE_MAKE_CMN
 546  525          parallel_flag = true;
 547      -        /* XXX - This is a major hack for DMake/Licensing. */
 548      -        if (getenv(NOCATGETS("DMAKE_CHILD")) == NULL) {
 549      -                if (!avo_cli_search_license(argv[0], dmake_exit_callback, TRUE, dmake_message_callback)) {
 550      -                        /*
 551      -                         * If the user can not get a TeamWare license,
 552      -                         * default to serial mode.
 553      -                         */
 554      -                        dmake_mode_type = serial_mode;
 555      -                        no_parallel = true;
 556      -                } else {
 557      -                        putenv(NOCATGETS("DMAKE_CHILD=TRUE"));
 558      -                }
 559      -                start_time = time(NULL);
 560      -                /*
 561      -                 * XXX - Hack to disable SIGALRM's from licensing library's
 562      -                 *       setitimer().
 563      -                 */
 564      -                value.it_interval.tv_sec = 0;
 565      -                value.it_interval.tv_usec = 0;
 566      -                value.it_value.tv_sec = 0;
 567      -                value.it_value.tv_usec = 0;
 568      -                (void) setitimer(ITIMER_REAL, &value, NULL);
 569      -        }
      526 +        putenv(strdup(NOCATGETS("DMAKE_CHILD=TRUE")));
 570  527  
 571  528  //
 572  529  // If dmake is running with -t option, set dmake_mode_type to serial.
 573  530  // This is done because doname() calls touch_command() that runs serially.
 574  531  // If we do not do that, maketool will have problems. 
 575  532  //
 576  533          if(touch) {
 577  534                  dmake_mode_type = serial_mode;
 578  535                  no_parallel = true;
 579  536          }
↓ open down ↓ 287 lines elided ↑ open up ↑
 867  824   */
 868  825          }
 869  826          /* Remove the statefile lock file if the file has been locked */
 870  827          if ((make_state_lockfile != NULL) && (make_state_locked)) {
 871  828                  (void) unlink(make_state_lockfile);
 872  829                  make_state_lockfile = NULL;
 873  830                  make_state_locked = false;
 874  831          }
 875  832          /* Write .make.state */
 876  833          write_state_file(1, (Boolean) 1);
 877      -
 878      -#ifdef TEAMWARE_MAKE_CMN
 879      -        // Deleting the usage tracking object sends the usage mail 
 880      -        cleanup->set_exit_status(exit_status);
 881      -        delete cleanup;
 882      -#endif
 883      -
 884  834  /*
 885  835  #ifdef DISTRIBUTED
 886  836      }
 887  837  #endif
 888  838   */
 889  839  
 890  840  #if defined (TEAMWARE_MAKE_CMN) && defined (MAXJOBS_ADJUST_RFE4694000)
 891  841          job_adjust_fini();
 892  842  #endif
 893  843  
↓ open down ↓ 968 lines elided ↑ open up ↑
1862 1812          }
1863 1813  }
1864 1814  
1865 1815  /*
1866 1816   *      set_sgs_support()
1867 1817   *
1868 1818   *      Add the libmakestate.so.1 lib to the env var SGS_SUPPORT
1869 1819   *        if it's not already in there.
1870 1820   *      The SGS_SUPPORT env var and libmakestate.so.1 is used by
1871 1821   *        the linker ld to report .make.state info back to make.
     1822 + *
     1823 + * In the new world we always will set the 32-bit and 64-bit versions of this
     1824 + * variable explicitly so that we can take into account the correct isa and our
     1825 + * prefix. So say that the prefix was /opt/local. Then we would want to search
     1826 + * /opt/local/lib/libmakestate.so.1:libmakestate.so.1. We still want to search
     1827 + * the original location just as a safety measure.
1872 1828   */
1873 1829  static void
1874 1830  set_sgs_support()
1875 1831  {
1876 1832          int             len;
1877      -        char            *newpath;
1878      -        char            *oldpath;
1879      -        static char     *prev_path;
     1833 +        char            *newpath, *newpath64;
     1834 +        char            *oldpath, *oldpath64;
     1835 +        static char     *prev_path, *prev_path64;
1880 1836  
1881      -        oldpath = getenv(LD_SUPPORT_ENV_VAR);
     1837 +        oldpath = getenv(LD_SUPPORT_ENV_VAR_32);
1882 1838          if (oldpath == NULL) {
1883      -                len = strlen(LD_SUPPORT_ENV_VAR) + 1 +
1884      -                        strlen(LD_SUPPORT_MAKE_LIB) + 1;
     1839 +                len = snprintf(NULL, 0, "%s=%s/%s/%s:%s",
     1840 +                    LD_SUPPORT_ENV_VAR_32,
     1841 +                    MAKE_PREFIX,
     1842 +                    LD_SUPPORT_MAKE_LIB_DIR,
     1843 +                    LD_SUPPORT_MAKE_LIB, LD_SUPPORT_MAKE_LIB) + 1;
1885 1844                  newpath = (char *) malloc(len);
1886      -                sprintf(newpath, "%s=", LD_SUPPORT_ENV_VAR);
     1845 +                sprintf(newpath, "%s=%s/%s/%s:%s",
     1846 +                    LD_SUPPORT_ENV_VAR_32,
     1847 +                    MAKE_PREFIX,
     1848 +                    LD_SUPPORT_MAKE_LIB_DIR,
     1849 +                    LD_SUPPORT_MAKE_LIB, LD_SUPPORT_MAKE_LIB);
1887 1850          } else {
1888      -                len = strlen(LD_SUPPORT_ENV_VAR) + 1 + strlen(oldpath) + 1 +
1889      -                        strlen(LD_SUPPORT_MAKE_LIB) + 1;
     1851 +                len = snprintf(NULL, 0, "%s=%s:%s/%s/%s:%s",
     1852 +                    LD_SUPPORT_ENV_VAR_32, oldpath, MAKE_PREFIX,
     1853 +                    LD_SUPPORT_MAKE_LIB_DIR, LD_SUPPORT_MAKE_LIB,
     1854 +                    LD_SUPPORT_MAKE_LIB) + 1;
1890 1855                  newpath = (char *) malloc(len);
1891      -                sprintf(newpath, "%s=%s", LD_SUPPORT_ENV_VAR, oldpath);
1892      -        }
1893      -
1894      -#if defined(TEAMWARE_MAKE_CMN)
1895      -
1896      -        /* function maybe_append_str_to_env_var() is defined in avo_util library
1897      -         * Serial make should not use this library !!!
1898      -         */
1899      -        maybe_append_str_to_env_var(newpath, LD_SUPPORT_MAKE_LIB);
1900      -#else
1901      -        if (oldpath == NULL) {
1902      -                sprintf(newpath, "%s%s", newpath, LD_SUPPORT_MAKE_LIB);
     1856 +                sprintf(newpath, "%s=%s:%s/%s/%s:%s",
     1857 +                    LD_SUPPORT_ENV_VAR_32, oldpath, MAKE_PREFIX,
     1858 +                    LD_SUPPORT_MAKE_LIB_DIR, LD_SUPPORT_MAKE_LIB,
     1859 +                    LD_SUPPORT_MAKE_LIB);
     1860 +        }
     1861 +
     1862 +        oldpath64 = getenv(LD_SUPPORT_ENV_VAR_64);
     1863 +        if (oldpath64 == NULL) {
     1864 +                len = snprintf(NULL, 0, "%s=%s/%s/%s/%s:%s",
     1865 +                    LD_SUPPORT_ENV_VAR_64, MAKE_PREFIX, LD_SUPPORT_MAKE_LIB_DIR,
     1866 +                    LD_SUPPORT_MAKE_LIB_DIR_64, LD_SUPPORT_MAKE_LIB,
     1867 +                    LD_SUPPORT_MAKE_LIB) + 1;
     1868 +                newpath64 = (char *) malloc(len);
     1869 +                sprintf(newpath64, "%s=%s/%s/%s/%s:%s",
     1870 +                    LD_SUPPORT_ENV_VAR_64, MAKE_PREFIX, LD_SUPPORT_MAKE_LIB_DIR,
     1871 +                    LD_SUPPORT_MAKE_LIB_DIR_64, LD_SUPPORT_MAKE_LIB,
     1872 +                    LD_SUPPORT_MAKE_LIB);
1903 1873          } else {
1904      -                sprintf(newpath, "%s:%s", newpath, LD_SUPPORT_MAKE_LIB);
     1874 +                len = snprintf(NULL, 0, "%s=%s:%s/%s/%s/%s:%s",
     1875 +                    LD_SUPPORT_ENV_VAR_64, oldpath64, MAKE_PREFIX,
     1876 +                    LD_SUPPORT_MAKE_LIB_DIR, LD_SUPPORT_MAKE_LIB_DIR_64,
     1877 +                    LD_SUPPORT_MAKE_LIB, LD_SUPPORT_MAKE_LIB) + 1;
     1878 +                newpath64 = (char *) malloc(len);
     1879 +                sprintf(newpath64, "%s=%s:%s/%s/%s/%s:%s",
     1880 +                    LD_SUPPORT_ENV_VAR_64, oldpath64, MAKE_PREFIX,
     1881 +                    LD_SUPPORT_MAKE_LIB_DIR, LD_SUPPORT_MAKE_LIB_DIR_64,
     1882 +                    LD_SUPPORT_MAKE_LIB, LD_SUPPORT_MAKE_LIB);
1905 1883          }
1906      -#endif
     1884 +
1907 1885          putenv(newpath);
1908 1886          if (prev_path) {
1909 1887                  free(prev_path);
1910 1888          }
1911 1889          prev_path = newpath;
     1890 +
     1891 +        putenv(newpath64);
     1892 +        if (prev_path64) {
     1893 +                free(prev_path64);
     1894 +        }
     1895 +        prev_path64 = newpath64;
1912 1896  }
1913 1897  
1914 1898  /*
1915 1899   *      read_files_and_state(argc, argv)
1916 1900   *
1917 1901   *      Read the makefiles we care about and the environment
1918 1902   *      Also read the = style command line options
1919 1903   *
1920 1904   *      Parameters:
1921 1905   *              argc            You know what this is
↓ open down ↓ 1626 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX