From ad9cb7fec5cc74697322620909e0ff1ba9ecb61b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 16 Feb 2018 11:38:24 +0200 Subject: Fix group link-up race in cc::link_rule::match() --- build2/cc/link-rule.cxx | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/build2/cc/link-rule.cxx b/build2/cc/link-rule.cxx index bdf75c7..04e2e7d 100644 --- a/build2/cc/link-rule.cxx +++ b/build2/cc/link-rule.cxx @@ -46,7 +46,8 @@ namespace build2 { tracer trace (x, "link_rule::match"); - // NOTE: may be called multiple times (see install rules). + // NOTE: may be called multiple times and for both inner and outer + // operations (see install rules). ltype lt (link_type (t)); otype ot (lt.type); @@ -54,10 +55,18 @@ namespace build2 // If this is a library, link-up to our group (this is the target group // protocol which means this can be done whether we match or not). // - if (lt.library () && t.group == nullptr) - t.group = &search (t, - lt.utility ? libu::static_type : lib::static_type, - t.dir, t.out, t.name); + // If we are called for the outer operation (see install rules), then + // use resolve_group() to delegate to inner. + // + if (lt.library ()) + { + if (a.outer ()) + resolve_group (a, t); + else if (t.group == nullptr) + t.group = &search (t, + lt.utility ? libu::static_type : lib::static_type, + t.dir, t.out, t.name); + } // Scan prerequisites and see if we can work with what we've got. Note // that X could be C. We handle this by always checking for X first. -- cgit v1.1