aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build2/c/init.cxx2
-rw-r--r--build2/cc/common.hxx2
-rw-r--r--build2/cc/guess.hxx4
-rw-r--r--build2/cc/init.cxx11
-rw-r--r--build2/cc/module.cxx49
-rw-r--r--build2/cxx/init.cxx2
6 files changed, 50 insertions, 20 deletions
diff --git a/build2/c/init.cxx b/build2/c/init.cxx
index 3ab91d4..bc97266 100644
--- a/build2/c/init.cxx
+++ b/build2/c/init.cxx
@@ -202,6 +202,8 @@ namespace build2
v.insert<string> ("c.signature"),
v.insert<string> ("c.checksum"),
+ v.insert<string> ("c.pattern"),
+
v.insert<target_triplet> ("c.target"),
v.insert<string> ("c.target.cpu"),
diff --git a/build2/cc/common.hxx b/build2/cc/common.hxx
index ad550e1..f4cd0c7 100644
--- a/build2/cc/common.hxx
+++ b/build2/cc/common.hxx
@@ -94,6 +94,8 @@ namespace build2
const variable& x_signature;
const variable& x_checksum;
+ const variable& x_pattern;
+
const variable& x_target;
const variable& x_target_cpu;
const variable& x_target_vendor;
diff --git a/build2/cc/guess.hxx b/build2/cc/guess.hxx
index 2eaa9d7..e3a4d8c 100644
--- a/build2/cc/guess.hxx
+++ b/build2/cc/guess.hxx
@@ -133,7 +133,7 @@ namespace build2
// unlike all the preceding fields, this one takes into account the
// compile options (e.g., -m32).
//
- // The cc_pattern is the toolchain program pattern that could sometimes be
+ // The pattern is the toolchain program pattern that could sometimes be
// derived for some toolchains. For example, i686-w64-mingw32-*-4.9.
//
// The bin_pattern is the binutils program pattern that could sometimes be
@@ -151,7 +151,7 @@ namespace build2
string signature;
string checksum;
string target;
- string cc_pattern;
+ string pattern;
string bin_pattern;
};
diff --git a/build2/cc/init.cxx b/build2/cc/init.cxx
index 90821ae..7a3e99e 100644
--- a/build2/cc/init.cxx
+++ b/build2/cc/init.cxx
@@ -96,6 +96,7 @@ namespace build2
// Hint variables (not overridable).
//
v.insert<string> ("config.cc.id");
+ v.insert<string> ("config.cc.hinter"); // Hinting module.
v.insert<string> ("config.cc.pattern");
v.insert<target_triplet> ("config.cc.target");
@@ -156,12 +157,14 @@ namespace build2
if (!cast_false<bool> (rs["cc.core.vars.loaded"]))
load_module (rs, rs, "cc.core.vars", loc);
- // config.cc.id
+ // config.cc.{id,hinter}
//
{
- // This value must be hinted.
+ // These values must be hinted.
//
rs.assign<string> ("cc.id") = cast<string> (hints["config.cc.id"]);
+ rs.assign<string> ("cc.hinter") =
+ cast<string> (hints["config.cc.hinter"]);
}
// config.cc.target
@@ -188,8 +191,8 @@ namespace build2
{
// This value could be hinted.
//
- if (auto l = hints["config.cc.pattern"])
- rs.assign<string> ("cc.pattern") = cast<string> (l);
+ rs.assign<string> ("cc.pattern") =
+ cast_empty<string> (hints["config.cc.pattern"]);
}
return true;
diff --git a/build2/cc/module.cxx b/build2/cc/module.cxx
index 74238c3..d806583 100644
--- a/build2/cc/module.cxx
+++ b/build2/cc/module.cxx
@@ -167,6 +167,8 @@ namespace build2
rs.assign (x_target) = move (tt);
+ rs.assign (x_pattern) = ci.pattern;
+
new_ = p.second;
// Load cc.core.guess.
@@ -180,10 +182,11 @@ namespace build2
// Note that all these variables have already been registered.
//
h.assign ("config.cc.id") = cast<string> (rs[x_id]);
+ h.assign ("config.cc.hinter") = string (x);
h.assign ("config.cc.target") = cast<target_triplet> (rs[x_target]);
- if (!ci.cc_pattern.empty ())
- h.assign ("config.cc.pattern") = ci.cc_pattern;
+ if (!ci.pattern.empty ())
+ h.assign ("config.cc.pattern") = ci.pattern;
load_module (rs, rs, "cc.core.guess", loc, false, h);
}
@@ -193,18 +196,36 @@ namespace build2
// matched ours since it could have been loaded by another c-family
// module.
//
- // Note that we don't require that patterns match. Presumably, if the
- // toolchain id and target are the same, then where exactly the tools
- // come from doesn't really matter.
- //
+ const auto& h (cast<string> (rs["cc.hinter"]));
+
{
const auto& cv (cast<string> (rs["cc.id"]));
const auto& xv (cast<string> (rs[x_id]));
if (cv != xv)
- fail (loc) << "cc and " << x << " module toolchain mismatch" <<
- info << "cc.id is " << cv <<
- info << x_id.name << " is " << xv;
+ fail (loc) << h << " and " << x << " module toolchain mismatch" <<
+ info << h << " is " << cv <<
+ info << x << " is " << xv <<
+ info << "consider explicitly specifying config." << h
+ << " and config." << x;
+ }
+
+ // We used to not require that patterns match assuming that if the
+ // toolchain id and target are the same, then where exactly the tools
+ // come from doesn't really matter. But in most cases it will be the
+ // g++-7 vs gcc kind of mistakes. So now we warn since even if
+ // intentional, it is still a bad idea.
+ //
+ {
+ const auto& cv (cast<string> (rs["cc.pattern"]));
+ const auto& xv (cast<string> (rs[x_pattern]));
+
+ if (cv != xv)
+ warn (loc) << h << " and " << x << " toolchain pattern mismatch" <<
+ info << h << " is '" << cv << "'" <<
+ info << x << " is '" << xv << "'" <<
+ info << "consider explicitly specifying config." << h
+ << " and config." << x;
}
{
@@ -212,9 +233,9 @@ namespace build2
const auto& xv (cast<target_triplet> (rs[x_target]));
if (cv != xv)
- fail (loc) << "cc and " << x << " module target mismatch" <<
- info << "cc.target is " << cv <<
- info << x_target.name << " is " << xv;
+ fail (loc) << h << " and " << x << " module target mismatch" <<
+ info << h << " target is " << cv <<
+ info << x << " target is " << xv;
}
}
}
@@ -326,9 +347,9 @@ namespace build2
for (const string& o: tstd) dr << ' ' << o;
}
- if (!ci.cc_pattern.empty ()) // bin_pattern printed by bin
+ if (!ci.pattern.empty ()) // Note: bin_pattern printed by bin
{
- dr << "\n pattern " << ci.cc_pattern;
+ dr << "\n pattern " << ci.pattern;
}
if (verb >= 3 && !inc_dirs.empty ())
diff --git a/build2/cxx/init.cxx b/build2/cxx/init.cxx
index ea3bf79..5eefa53 100644
--- a/build2/cxx/init.cxx
+++ b/build2/cxx/init.cxx
@@ -397,6 +397,8 @@ namespace build2
v.insert<string> ("cxx.signature"),
v.insert<string> ("cxx.checksum"),
+ v.insert<string> ("cxx.pattern"),
+
v.insert<target_triplet> ("cxx.target"),
v.insert<string> ("cxx.target.cpu"),