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/compile-rule.cxx | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'libbuild2/cc/compile-rule.cxx') diff --git a/libbuild2/cc/compile-rule.cxx b/libbuild2/cc/compile-rule.cxx index eba58fd..7cea9d6 100644 --- a/libbuild2/cc/compile-rule.cxx +++ b/libbuild2/cc/compile-rule.cxx @@ -768,18 +768,23 @@ namespace build2 { // Handle (phase two) imported libraries. We know that for such // libraries we don't need to do match() in order to get options - // (if any, they would be set by search_library()). + // (if any, they would be set by search_library()). But we do need + // to match it if we may need its modules (see search_modules() + // for details). // if (p.proj ()) { - if (search_library (a, - sys_lib_dirs, - usr_lib_dirs, - p.prerequisite) != nullptr) + pt = search_library (a, + sys_lib_dirs, + usr_lib_dirs, + p.prerequisite); + + if (pt != nullptr && !modules) continue; } - pt = &p.search (t); + if (pt == nullptr) + pt = &p.search (t); if (const libx* l = pt->is_a ()) pt = link_member (*l, a, li); @@ -836,7 +841,7 @@ namespace build2 // resolved and prerequisite_targets populated. So we match it but // then unmatch if it is safe. And thanks to the two-pass prerequisite // match in link::apply() it will be safe unless someone is building - // an obj?{} target directory. + // an obj?{} target directly. // pair mr ( build2::match ( @@ -5588,6 +5593,11 @@ namespace build2 // The module names should be specified but if not assume // something else is going on and ignore. // + // Note also that besides modules, prerequisite_targets may + // contain libraries which are interface dependencies of this + // library and which may be called to resolve its module + // dependencies. + // const string* n (cast_null (bt->vars[c_module_name])); if (n == nullptr) -- cgit v1.1