aboutsummaryrefslogtreecommitdiff
path: root/build2
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-04-28 19:48:16 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-04-28 19:48:16 +0200
commit2fd0863c6a1689180e032681dd574810b7e83c5f (patch)
tree469e29f20efaa981468f9d7dbbbed6a409b9a9fc /build2
parentb337a810939559ed8ee49c77f9918e5be76dd7b9 (diff)
Fix buildfile loading race
Diffstat (limited to 'build2')
-rw-r--r--build2/target.cxx12
1 files changed, 12 insertions, 0 deletions
diff --git a/build2/target.cxx b/build2/target.cxx
index e1712b9..1922570 100644
--- a/build2/target.cxx
+++ b/build2/target.cxx
@@ -811,6 +811,18 @@ namespace build2
//
phase_switch ps (run_phase::load);
+ // This is subtle: while we were fussing around another thread may
+ // have loaded the buildfile. So re-test now that we are in exclusive
+ // phase.
+ //
+ if (t == nullptr)
+ t = search_existing_target (pk);
+
+ if (t != nullptr && !t->implied)
+ return t;
+
+ // Ok, no luck, switch the scope.
+ //
pair<scope&, scope*> sp (
switch_scope (*s.rw ().root_scope (), out_base));