From d1fbcace59846d55c66e741dbc3d59e20ae3e5cf Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 26 Jun 2019 12:28:05 +0200 Subject: Fix C/C++ link rule matching ambiguity by seeing-through utility libraries --- build2/cc/utility.cxx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'build2/cc/utility.cxx') diff --git a/build2/cc/utility.cxx b/build2/cc/utility.cxx index 39f5c35..2751032 100644 --- a/build2/cc/utility.cxx +++ b/build2/cc/utility.cxx @@ -43,8 +43,8 @@ namespace build2 : v.size () > 1 && v[1] == "shared" ? lorder::a_s : lorder::a; } - const target& - link_member (const bin::libx& x, action a, linfo li) + const target* + link_member (const bin::libx& x, action a, linfo li, bool exist) { bool ul; @@ -72,12 +72,14 @@ namespace build2 // Called by the compile rule during execute. // - return phase == run_phase::match - ? search (x, tt, x.dir, x.out, x.name) - : *search_existing (tt, x.dir, x.out, x.name); + return phase == run_phase::match && !exist + ? &search (x, tt, x.dir, x.out, x.name) + : search_existing (tt, x.dir, x.out, x.name); } else { + assert (!exist); + const lib& l (x.as ()); // Make sure group members are resolved. @@ -107,7 +109,7 @@ namespace build2 } } - return *(ls ? static_cast (l.s) : l.a); + return ls ? static_cast (l.s) : l.a; } } } -- cgit v1.1