aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/cc
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2/cc')
-rw-r--r--libbuild2/cc/common.hxx4
-rw-r--r--libbuild2/cc/compile-rule.cxx7
-rw-r--r--libbuild2/cc/link-rule.cxx11
-rw-r--r--libbuild2/cc/module.cxx14
-rw-r--r--libbuild2/cc/module.hxx2
5 files changed, 33 insertions, 5 deletions
diff --git a/libbuild2/cc/common.hxx b/libbuild2/cc/common.hxx
index 612d081..758c675 100644
--- a/libbuild2/cc/common.hxx
+++ b/libbuild2/cc/common.hxx
@@ -170,6 +170,8 @@ namespace build2
const string& tsys; // x.target.system
const string& tclass; // x.target.class
+ const string& env_checksum; // config_module::env_checksum
+
bool modules; // x.features.modules
bool symexport; // x.features.symexport
@@ -230,6 +232,7 @@ namespace build2
const process_path& path,
const strings& mode,
const target_triplet& tgt,
+ const string& env_cs,
bool fm,
bool fs,
const dir_paths& sld,
@@ -250,6 +253,7 @@ namespace build2
cmaj (mj), cmin (mi),
cpath (path), cmode (mode),
ctgt (tgt), tsys (ctgt.system), tclass (ctgt.class_),
+ env_checksum (env_cs),
modules (fm),
symexport (fs),
importable_headers (nullptr),
diff --git a/libbuild2/cc/compile-rule.cxx b/libbuild2/cc/compile-rule.cxx
index b5016bc..ce586bb 100644
--- a/libbuild2/cc/compile-rule.cxx
+++ b/libbuild2/cc/compile-rule.cxx
@@ -197,7 +197,7 @@ namespace build2
compile_rule::
compile_rule (data&& d)
: common (move (d)),
- rule_id (string (x) += ".compile 4")
+ rule_id (string (x) += ".compile 5")
{
static_assert (sizeof (match_data) <= target::data_size,
"insufficient space");
@@ -929,6 +929,11 @@ namespace build2
if (dd.expect (cast<string> (rs[x_checksum])) != nullptr)
l4 ([&]{trace << "compiler mismatch forcing update of " << t;});
+ // Then the compiler environment checksum.
+ //
+ if (dd.expect (env_checksum) != nullptr)
+ l4 ([&]{trace << "environment mismatch forcing update of " << t;});
+
// Then the options checksum.
//
// The idea is to keep them exactly as they are passed to the compiler
diff --git a/libbuild2/cc/link-rule.cxx b/libbuild2/cc/link-rule.cxx
index 9c72969..0ab61b1 100644
--- a/libbuild2/cc/link-rule.cxx
+++ b/libbuild2/cc/link-rule.cxx
@@ -37,7 +37,7 @@ namespace build2
link_rule::
link_rule (data&& d)
: common (move (d)),
- rule_id (string (x) += ".link 2")
+ rule_id (string (x) += ".link 3")
{
static_assert (sizeof (match_data) <= target::data_size,
"insufficient space");
@@ -2427,10 +2427,13 @@ namespace build2
l4 ([&]{trace << "linker mismatch forcing update of " << t;});
}
- // Hash and compare any changes to the environment.
+ // Then the linker environment checksum (original and our modifications).
//
- if (dd.expect (env_cs.string ()) != nullptr)
- l4 ([&]{trace << "environment mismatch forcing update of " << t;});
+ {
+ bool e (dd.expect (env_checksum) != nullptr);
+ if (dd.expect (env_cs.string ()) != nullptr || e)
+ l4 ([&]{trace << "environment mismatch forcing update of " << t;});
+ }
// Next check the target. While it might be incorporated into the linker
// checksum, it also might not (e.g., VC link.exe).
diff --git a/libbuild2/cc/module.cxx b/libbuild2/cc/module.cxx
index 5bb3f60..7ef8cd5 100644
--- a/libbuild2/cc/module.cxx
+++ b/libbuild2/cc/module.cxx
@@ -202,8 +202,22 @@ namespace build2
}
}
+ // Hash the environment (used for change detection).
+ //
+ // Note that for simplicity we use the combined checksum for both
+ // compilation and linking (which may compile, think LTO).
+ //
+ {
+ sha256 cs;
+ hash_environment (cs, xi.compiler_environment);
+ hash_environment (cs, xi.platform_environment);
+ env_checksum = cs.string ();
+ }
+
// Assign values to variables that describe the compiler.
//
+ // @@ TODO: env_checksum.
+ //
rs.assign (x_path) = process_path_ex (xi.path, x_name, xi.checksum);
const strings& xm (cast<strings> (rs.assign (x_mode) = move (mode)));
diff --git a/libbuild2/cc/module.hxx b/libbuild2/cc/module.hxx
index f9d435d..ed6ec41 100644
--- a/libbuild2/cc/module.hxx
+++ b/libbuild2/cc/module.hxx
@@ -59,6 +59,8 @@ namespace build2
const compiler_info* x_info;
+ string env_checksum; // Environment checksum (also in x.path).
+
// Temporary storage for data::sys_*_dirs_*.
//
size_t sys_lib_dirs_mode;