From e85e618a1b918f7279133eb1f446c1af871f5dd2 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 3 Dec 2020 11:00:24 +0200 Subject: Fix modules support for installed libraries --- libbuild2/cc/common.cxx | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'libbuild2/cc/common.cxx') diff --git a/libbuild2/cc/common.cxx b/libbuild2/cc/common.cxx index 7d2fd63..a1bee8c 100644 --- a/libbuild2/cc/common.cxx +++ b/libbuild2/cc/common.cxx @@ -855,8 +855,20 @@ namespace build2 if (s != nullptr) lt->s = s; } - target_lock al (a != nullptr ? lock (act, *a) : target_lock ()); - target_lock sl (s != nullptr ? lock (act, *s) : target_lock ()); + target_lock al (a != nullptr ? lock (act, *a, false) : target_lock ()); + target_lock sl (s != nullptr ? lock (act, *s, false) : target_lock ()); + + if (al && al.offset == target::offset_matched) + { + assert ((*a)[act].rule == &file_rule::rule_match); + al.unlock (); + } + + if (sl && sl.offset == target::offset_matched) + { + assert ((*s)[act].rule == &file_rule::rule_match); + sl.unlock (); + } if (!al) a = nullptr; if (!sl) s = nullptr; @@ -953,11 +965,17 @@ namespace build2 } // If we have the lock (meaning this is the first time), set the - // traget's recipe to noop. Failed that we will keep re-locking it, + // traget's rule/recipe. Failed that we will keep re-locking it, // updating its members, etc. // - if (al) match_recipe (al, noop_recipe); - if (sl) match_recipe (sl, noop_recipe); + // For members, use the fallback file rule instead of noop since we may + // need their prerequisites matched (used for modules support; see + // pkgconfig_load(), search_modules() for details). + // + // Note also that these calls clear target data. + // + if (al) match_rule (al, file_rule::rule_match); + if (sl) match_rule (sl, file_rule::rule_match); if (ll) match_recipe (ll, noop_recipe); return r; -- cgit v1.1