From eacf7f7ccd40a56d1fe761d3d30ced6c6acd58da Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 1 Nov 2018 13:00:16 +0200 Subject: Add support for rule-specific variables, use to fix cc.type data race --- build2/cc/common.cxx | 5 +++-- build2/cc/init.cxx | 18 +++++++++++------- build2/cc/link-rule.cxx | 4 ++-- 3 files changed, 16 insertions(+), 11 deletions(-) (limited to 'build2/cc') diff --git a/build2/cc/common.cxx b/build2/cc/common.cxx index ae125a5..a1a17f7 100644 --- a/build2/cc/common.cxx +++ b/build2/cc/common.cxx @@ -80,9 +80,10 @@ namespace build2 // See what type of library this is (C, C++, etc). Use it do decide // which x.libs variable name to use. If it's unknown, then we only - // look into prerequisites. + // look into prerequisites. Note: lookup starting from rule-specific + // variables (target should already be matched). // - const string* t (cast_null (l.vars[c_type])); + const string* t (cast_null (l.state[a][c_type])); bool impl (proc_impl && proc_impl (l, la)); bool cc (false), same (false); diff --git a/build2/cc/init.cxx b/build2/cc/init.cxx index 2f88542..bb0269c 100644 --- a/build2/cc/init.cxx +++ b/build2/cc/init.cxx @@ -78,6 +78,8 @@ namespace build2 // auto& v (var_pool.rw (rs)); + auto v_t (variable_visibility::target); + v.insert ("config.cc.poptions", true); v.insert ("config.cc.coptions", true); v.insert ("config.cc.loptions", true); @@ -106,24 +108,26 @@ namespace build2 v.insert ("cc.stdlib"); // Target type, for example, "C library" or "C++ library". Should be set - // on the target by the matching rule to the name of the module (e.g., - // "c", "cxx"). Currenly only set for libraries and is used to decide - // which *.libs to use during static linking. + // on the target as a rule-specific variable by the matching rule to the + // name of the module (e.g., "c", "cxx"). Currenly only set for + // libraries and is used to decide which *.libs to use during static + // linking. // // It can also be the special "cc" value which means a C-common library - // but specific language is not known. Used in import installed logic. + // but specific language is not known. Used in the import installed + // logic. // - v.insert ("cc.type"); + v.insert ("cc.type", v_t); // If set and is true, then this (imported) library has been found in a // system library search directory. // - v.insert ("cc.system"); + v.insert ("cc.system", v_t); // C++ module name. Should be set on the bmi*{} target by the matching // rule. // - v.insert ("cc.module_name"); + v.insert ("cc.module_name", v_t); // Ability to disable using preprocessed output for compilation. // diff --git a/build2/cc/link-rule.cxx b/build2/cc/link-rule.cxx index 230fc6f..ba6a22d 100644 --- a/build2/cc/link-rule.cxx +++ b/build2/cc/link-rule.cxx @@ -356,10 +356,10 @@ namespace build2 otype ot (lt.type); linfo li (link_info (bs, ot)); - // Set the library type (C, C++, etc). + // Set the library type (C, C++, etc) as rule-specific variable. // if (lt.library ()) - t.vars.assign (c_type) = string (x); + t.state[a].assign (c_type) = string (x); bool binless (lt.library ()); // Binary-less until proven otherwise. -- cgit v1.1