aboutsummaryrefslogtreecommitdiff
path: root/build2/cc/module.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-01-04 15:35:57 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-01-05 15:10:01 +0200
commit76de594667b370094f5da5c0871c155d788d135e (patch)
tree610d67fc2350a4fdeaa2de7b6583f5da9067bc24 /build2/cc/module.cxx
parentd6427addaf7de41d401dd2a871b4789022e5f7cf (diff)
Initial support for c/cxx runtime/stdlib detection
Diffstat (limited to 'build2/cc/module.cxx')
-rw-r--r--build2/cc/module.cxx100
1 files changed, 49 insertions, 51 deletions
diff --git a/build2/cc/module.cxx b/build2/cc/module.cxx
index d4962a4..5b1a79a 100644
--- a/build2/cc/module.cxx
+++ b/build2/cc/module.cxx
@@ -143,24 +143,6 @@ namespace build2
}
}
- // For some compilers we have to remap the target to something more
- // appropriate.
- //
- if (tt.system == "windows-msvc") // Clang on Windows targeting MSVC.
- {
- // Remap to the same triplet as used for MSVC.
- //
- // @@ This should probably be done in guess(), especially since we may
- // need to extra extra info from the compiler (like the runtime
- // version). Perhaps have original_target in compiler_info (so can
- // print it in report below)?
- //
- tt.vendor = "microsoft";
- tt.system = "win32-msvc";
- tt.version = "14.1"; //@@ TMP hardcoded.
- assert (tt.class_ == "windows");
- }
-
// Assign values to variables that describe the compiler.
//
rs.assign (x_id) = ci.id.string ();
@@ -188,6 +170,9 @@ namespace build2
rs.assign (x_pattern) = ci.pattern;
+ if (!x_stdlib.aliases (c_stdlib))
+ rs.assign (x_stdlib) = move (ci.x_stdlib);
+
new_ = p.second;
// Load cc.core.guess.
@@ -207,6 +192,9 @@ namespace build2
if (!ci.pattern.empty ())
h.assign ("config.cc.pattern") = ci.pattern;
+ h.assign (c_runtime) = ci.runtime;
+ h.assign (c_stdlib) = ci.c_stdlib;
+
load_module (rs, rs, "cc.core.guess", loc, false, h);
}
else
@@ -217,45 +205,49 @@ namespace build2
//
const auto& h (cast<string> (rs["cc.hinter"]));
+ auto check = [&loc, &h, this] (const auto& cv,
+ const auto& xv,
+ const char* what,
+ bool error = true)
{
- const auto& cv (cast<string> (rs["cc.id"]));
- const auto& xv (cast<string> (rs[x_id]));
-
if (cv != 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;
- }
+ {
+ diag_record dr (error ? fail (loc) : warn (loc));
+
+ dr << h << " and " << x << " module " << what << " mismatch" <<
+ info << h << " is '" << cv << "'" <<
+ info << x << " is '" << xv << "'" <<
+ info << "consider explicitly specifying config." << h
+ << " and config." << x;
+ }
+ };
+
+ check (cast<string> (rs["cc.id"]),
+ cast<string> (rs[x_id]),
+ "toolchain");
// 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.
+ // intentional, it is still probably 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;
- }
-
- {
- const auto& cv (cast<target_triplet> (rs["cc.target"]));
- const auto& xv (cast<target_triplet> (rs[x_target]));
-
- if (cv != xv)
- fail (loc) << h << " and " << x << " module target mismatch" <<
- info << h << " target is " << cv <<
- info << x << " target is " << xv;
- }
+ check (cast<string> (rs["cc.pattern"]),
+ cast<string> (rs[x_pattern]),
+ "toolchain pattern",
+ false);
+
+ check (cast<target_triplet> (rs["cc.target"]),
+ cast<target_triplet> (rs[x_target]),
+ "target");
+
+ check (cast<string> (rs["cc.runtime"]),
+ ci.runtime,
+ "runtime");
+
+ check (cast<string> (rs["cc.stdlib"]),
+ ci.c_stdlib,
+ "c standard library");
}
}
@@ -356,8 +348,14 @@ namespace build2
<< " checksum " << ci.checksum << '\n'
<< " target " << ct;
- if (ct != ci.target)
- dr << " (" << ci.target << ")";
+ if (ct != ci.original_target)
+ dr << " (" << ci.original_target << ")";
+
+
+ // @@ Print c_stdlib?
+ //
+ dr << "\n runtime " << ci.runtime
+ << "\n stdlib " << ci.x_stdlib;
}
if (!tstd.empty ())