From 8e904346350cff0453c8bcd524a40a631fc05485 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 9 Jan 2019 13:09:18 +0200 Subject: Tighten cc rules matching Specifically, make sure the rule does not match if there is a c-common prerequisites that it doesn't recognize. --- build2/cc/link-rule.cxx | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'build2/cc/link-rule.cxx') diff --git a/build2/cc/link-rule.cxx b/build2/cc/link-rule.cxx index c24655a..b7ecd85 100644 --- a/build2/cc/link-rule.cxx +++ b/build2/cc/link-rule.cxx @@ -71,7 +71,8 @@ namespace build2 } // 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. + // that X could be C (as in language). We handle this by always checking + // for X first. // // Note also that we treat bmi{} as obj{}. // @@ -84,9 +85,9 @@ namespace build2 if (include (a, t, p) != include_type::normal) continue; - if (p.is_a (x_src) || - (lt.library () && p.is_a (*x_hdr[0])) || // Header-only library. - (x_mod != nullptr && p.is_a (*x_mod))) + if (p.is_a (x_src) || + (x_mod != nullptr && p.is_a (*x_mod)) || + (lt.library () && x_header (p))) // Header-only library. { seen_x = seen_x || true; } @@ -127,11 +128,16 @@ namespace build2 { seen_lib = seen_lib || true; } - // If this is some other c-common source (say C++ in a C rule), then - // it will most definitely need to be compiled but we can't do that. + // If this is some other c-common header/source (say C++ in a C rule), + // then we shouldn't try to handle that (it may need to be compiled, + // etc). But we assume everyone can handle a C header. // - else if (p.is_a ()) + else if (p.is_a () && !p.is_a ()) + { + l4 ([&]{trace << "non-" << x_lang << " prerequisite " << p + << " for target " << t;}); return false; + } } if (!(seen_x || seen_c || seen_obj || seen_lib)) -- cgit v1.1