aboutsummaryrefslogtreecommitdiff
path: root/build2/cc/link-rule.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-01-09 13:09:18 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-01-09 13:09:18 +0200
commit8e904346350cff0453c8bcd524a40a631fc05485 (patch)
treef096ad1e87d8a814c6e00c179c8849ed646e0989 /build2/cc/link-rule.cxx
parentba8ce9226af026f873883b7d4e29079bbfece586 (diff)
Tighten cc rules matching
Specifically, make sure the rule does not match if there is a c-common prerequisites that it doesn't recognize.
Diffstat (limited to 'build2/cc/link-rule.cxx')
-rw-r--r--build2/cc/link-rule.cxx20
1 files changed, 13 insertions, 7 deletions
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<cc> ())
+ else if (p.is_a<cc> () && !p.is_a<h> ())
+ {
+ l4 ([&]{trace << "non-" << x_lang << " prerequisite " << p
+ << " for target " << t;});
return false;
+ }
}
if (!(seen_x || seen_c || seen_obj || seen_lib))