Ticket #1112: make-4.2-upstream_fixes-1.patch

File make-4.2-upstream_fixes-1.patch, 6.7 KB (added by chris@…, 8 years ago)
  • filedef.h

    Submitted By: Ken Moffat <ken at linuxfromscratch dot org>
    Date: 2016-06-05
    Initial Package5 Version: 4.2
    Upstream Status: Applied
    Origin: Upstream
    Description: fixes build failures where a double-colon rule is used
    with -jN - among others, in building git and firefox.
    
    From 4762480ae9cb8df4878286411f178d32db14eff0 Mon Sep 17 00:00:00 2001
    From: Paul Smith <psmith@gnu.org>
    Date: Tue, 31 May 2016 06:56:51 +0000
    Subject: [SV 47995] Ensure forced double-colon rules work with -j.
    
    The fix for SV 44742 had a side-effect that some double-colon targets
    were skipped.  This happens because the "considered" facility assumed
    that all targets would be visited on each walk through the dependency
    graph: we used a bit for considered and toggled it on each pass; if
    we didn't walk the entire graph on every pass the bit would get out
    of sync.  The new behavior after SV 44742 might return early without
    walking the entire graph.  To fix this I changed the considered value
    to an integer which is monotonically increasing: it is then never
    possible to incorrectly determine that a previous pass through the
    graph already considered the current target.
    
    * filedef.h (struct file): make CONSIDERED an unsigned int.
    * main.c (main): No longer need to reset CONSIDERED.
    * remake.c (update_goal_chain): increment CONSIDERED rather than
    inverting it between 0<->1.
    (update_file_1): Reset CONSIDERED to 0 so it's re-considered.
    (check_dep): Ditto.
    * tests/scripts/features/double_colon: Add a regression test.
    ---
    diff --git a/filedef.h b/filedef.h
    index 507a027..14b4187 100644
    a b struct file 
    5858    FILE_TIMESTAMP last_mtime;  /* File's modtime, if already known.  */
    5959    FILE_TIMESTAMP mtime_before_update; /* File's modtime before any updating
    6060                                           has been performed.  */
     61    unsigned int considered;    /* equal to 'considered' if file has been
     62                                   considered on current scan of goal chain */
    6163    int command_flags;          /* Flags OR'd in for cmds; see commands.h.  */
    6264    enum update_status          /* Status of the last attempt to update.  */
    6365      {
    struct file 
    9698    unsigned int ignore_vpath:1;/* Nonzero if we threw out VPATH name.  */
    9799    unsigned int pat_searched:1;/* Nonzero if we already searched for
    98100                                   pattern-specific variables.  */
    99     unsigned int considered:1;  /* equal to 'considered' if file has been
    100                                    considered on current scan of goal chain */
    101101    unsigned int no_diag:1;     /* True if the file failed to update and no
    102102                                   diagnostics has been issued (dontcare). */
    103103  };
  • main.c

    diff --git a/main.c b/main.c
    index 576f2e9..e606488 100644
    a b main (int argc, char **argv, char **envp) 
    22622262
    22632263            for (i = 0, d = read_files; d != 0; ++i, d = d->next)
    22642264              {
    2265                 /* Reset the considered flag; we may need to look at the file
    2266                    again to print an error.  */
    2267                 d->file->considered = 0;
    2268 
    22692265                if (d->file->updated)
    22702266                  {
    22712267                    /* This makefile was updated.  */
  • remake.c

    diff --git a/remake.c b/remake.c
    index df1a9e0..5d5d67a 100644
    a b unsigned int commands_started = 0; 
    5757static struct goaldep *goal_list;
    5858static struct dep *goal_dep;
    5959
    60 /* Current value for pruning the scan of the goal chain (toggle 0/1).  */
    61 static unsigned int considered;
     60/* Current value for pruning the scan of the goal chain.
     61   All files start with considered == 0.  */
     62static unsigned int considered = 0;
    6263
    6364static enum update_status update_file (struct file *file, unsigned int depth);
    6465static enum update_status update_file_1 (struct file *file, unsigned int depth);
    update_goal_chain (struct goaldep *goaldeps) 
    9091
    9192  goal_list = rebuilding_makefiles ? goaldeps : NULL;
    9293
    93   /* All files start with the considered bit 0, so the global value is 1.  */
    94   considered = 1;
    95 
    9694#define MTIME(file) (rebuilding_makefiles ? file_mtime_no_search (file) \
    9795                     : file_mtime (file))
    9896
     97  /* Start a fresh batch of consideration.  */
     98  ++considered;
     99
    99100  /* Update all the goals until they are all finished.  */
    100101
    101102  while (goals != 0)
    update_goal_chain (struct goaldep *goaldeps) 
    247248            }
    248249        }
    249250
    250       /* If we reached the end of the dependency graph toggle the considered
    251          flag for the next pass.  */
     251      /* If we reached the end of the dependency graph update CONSIDERED
     252         for the next pass.  */
    252253      if (g == 0)
    253         considered = !considered;
     254        ++considered;
    254255    }
    255256
    256257  if (rebuilding_makefiles)
    update_file_1 (struct file *file, unsigned int depth) 
    615616            break;
    616617
    617618          if (!running)
    618             /* The prereq is considered changed if the timestamp has changed while
    619                it was built, OR it doesn't exist.  */
     619            /* The prereq is considered changed if the timestamp has changed
     620               while it was built, OR it doesn't exist.  */
    620621            d->changed = ((file_mtime (d->file) != mtime)
    621622                          || (mtime == NONEXISTENT_MTIME));
    622623
    update_file_1 (struct file *file, unsigned int depth) 
    650651            /* We may have already considered this file, when we didn't know
    651652               we'd need to update it.  Force update_file() to consider it and
    652653               not prune it.  */
    653             d->file->considered = !considered;
     654            d->file->considered = 0;
    654655
    655656            new = update_file (d->file, depth);
    656657            if (new > dep_status)
    check_dep (struct file *file, unsigned int depth, 
    10871088              /* If the target was waiting for a dependency it has to be
    10881089                 reconsidered, as that dependency might have finished.  */
    10891090              if (file->command_state == cs_deps_running)
    1090                 file->considered = !considered;
     1091                file->considered = 0;
    10911092
    10921093              set_command_state (file, cs_not_started);
    10931094            }
  • tests/scripts/features/double_colon

    diff --git a/tests/scripts/features/double_colon b/tests/scripts/features/double_colon
    index 80ddb31..58f126f 100644
    a b all:: 3 
    197197',
    198198              '-rs -j2 1 2 root', "all_one\nall_two\nroot\n");
    199199
     200# SV 47995 : Parallel double-colon rules with FORCE
     201
     202run_make_test('
     203all:: ; @echo one
     204
     205all:: joe ; @echo four
     206
     207joe: FORCE ; touch joe-is-forced
     208
     209FORCE:
     210',
     211              '-j5', "one\ntouch joe-is-forced\nfour\n");
     212
     213unlink('joe-is-forced');
     214
    200215# This tells the test driver that the perl test script executed properly.
    2012161;
    202217